CMakeLists.txt 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. set(editor_SRCS
  2. StdInc.cpp
  3. main.cpp
  4. launcherdirs.cpp
  5. jsonutils.cpp
  6. mainwindow.cpp
  7. BitmapHandler.cpp
  8. maphandler.cpp
  9. Animation.cpp
  10. graphics.cpp
  11. windownewmap.cpp
  12. generatorprogress.cpp
  13. mapview.cpp
  14. objectbrowser.cpp
  15. mapsettings/abstractsettings.cpp
  16. mapsettings/mapsettings.cpp
  17. mapsettings/generalsettings.cpp
  18. mapsettings/modsettings.cpp
  19. mapsettings/timedevent.cpp
  20. mapsettings/victoryconditions.cpp
  21. mapsettings/loseconditions.cpp
  22. mapsettings/eventsettings.cpp
  23. mapsettings/rumorsettings.cpp
  24. playersettings.cpp
  25. playerparams.cpp
  26. scenelayer.cpp
  27. mapcontroller.cpp
  28. validator.cpp
  29. inspector/inspector.cpp
  30. inspector/townbulidingswidget.cpp
  31. inspector/armywidget.cpp
  32. inspector/messagewidget.cpp
  33. inspector/rewardswidget.cpp
  34. inspector/questwidget.cpp
  35. inspector/heroskillswidget.cpp
  36. resourceExtractor/ResourceConverter.cpp
  37. )
  38. set(editor_HEADERS
  39. StdInc.h
  40. launcherdirs.h
  41. jsonutils.h
  42. mainwindow.h
  43. BitmapHandler.h
  44. maphandler.h
  45. Animation.h
  46. graphics.h
  47. windownewmap.h
  48. generatorprogress.h
  49. mapview.h
  50. objectbrowser.h
  51. mapsettings/abstractsettings.h
  52. mapsettings/mapsettings.h
  53. mapsettings/generalsettings.h
  54. mapsettings/modsettings.h
  55. mapsettings/timedevent.h
  56. mapsettings/victoryconditions.h
  57. mapsettings/loseconditions.h
  58. mapsettings/eventsettings.h
  59. mapsettings/rumorsettings.h
  60. playersettings.h
  61. playerparams.h
  62. scenelayer.h
  63. mapcontroller.h
  64. validator.h
  65. inspector/inspector.h
  66. inspector/townbulidingswidget.h
  67. inspector/armywidget.h
  68. inspector/messagewidget.h
  69. inspector/rewardswidget.h
  70. inspector/questwidget.h
  71. inspector/heroskillswidget.h
  72. resourceExtractor/ResourceConverter.h
  73. )
  74. set(editor_FORMS
  75. mainwindow.ui
  76. windownewmap.ui
  77. generatorprogress.ui
  78. mapsettings/mapsettings.ui
  79. mapsettings/generalsettings.ui
  80. mapsettings/modsettings.ui
  81. mapsettings/timedevent.ui
  82. mapsettings/victoryconditions.ui
  83. mapsettings/loseconditions.ui
  84. mapsettings/eventsettings.ui
  85. mapsettings/rumorsettings.ui
  86. playersettings.ui
  87. playerparams.ui
  88. validator.ui
  89. inspector/townbulidingswidget.ui
  90. inspector/armywidget.ui
  91. inspector/messagewidget.ui
  92. inspector/rewardswidget.ui
  93. inspector/questwidget.ui
  94. inspector/heroskillswidget.ui
  95. )
  96. set(editor_TS
  97. translation/english.ts
  98. translation/french.ts
  99. translation/german.ts
  100. translation/polish.ts
  101. translation/russian.ts
  102. translation/spanish.ts
  103. translation/ukrainian.ts
  104. translation/vietnamese.ts
  105. )
  106. assign_source_group(${editor_SRCS} ${editor_HEADERS} mapeditor.rc)
  107. # Tell CMake to run moc when necessary:
  108. set(CMAKE_AUTOMOC ON)
  109. if(POLICY CMP0071)
  110. cmake_policy(SET CMP0071 NEW)
  111. endif()
  112. # As moc files are generated in the binary dir, tell CMake
  113. # to always look for includes there:
  114. set(CMAKE_INCLUDE_CURRENT_DIR ON)
  115. if(TARGET Qt6::Core)
  116. qt_wrap_ui(editor_UI_HEADERS ${editor_FORMS})
  117. else()
  118. qt5_wrap_ui(editor_UI_HEADERS ${editor_FORMS})
  119. if(ENABLE_TRANSLATIONS)
  120. set_source_files_properties(${editor_TS} PROPERTIES OUTPUT_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/translation)
  121. qt5_add_translation( editor_QM ${editor_TS} )
  122. endif()
  123. endif()
  124. if(WIN32)
  125. set(editor_ICON mapeditor.rc)
  126. endif()
  127. add_executable(vcmieditor WIN32 ${editor_QM} ${editor_SRCS} ${editor_HEADERS} ${editor_UI_HEADERS} ${editor_ICON})
  128. if(TARGET Qt6::Core)
  129. if(ENABLE_TRANSLATIONS)
  130. set_source_files_properties(${editor_TS} PROPERTIES OUTPUT_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/translation)
  131. qt_add_translations(vcmieditor
  132. TS_FILES ${editor_TS}
  133. QM_FILES_OUTPUT_VARIABLE editor_QM
  134. INCLUDE_DIRECTORIES
  135. ${CMAKE_CURRENT_BINARY_DIR})
  136. endif()
  137. endif()
  138. if(WIN32)
  139. set_target_properties(vcmieditor
  140. PROPERTIES
  141. OUTPUT_NAME "VCMI_mapeditor"
  142. PROJECT_LABEL "VCMI_mapeditor"
  143. )
  144. # FIXME: Can't to get CMP0020 working with Vcpkg and CMake 3.8.2
  145. # So far I tried:
  146. # - cmake_minimum_required set to 2.8.11 globally and in this file
  147. # - cmake_policy in all possible places
  148. # - used NO_POLICY_SCOPE to make sure no other parts reset policies
  149. # Still nothing worked, warning kept appearing and WinMain didn't link automatically
  150. target_link_libraries(vcmieditor Qt${QT_VERSION_MAJOR}::WinMain)
  151. endif()
  152. if(APPLE)
  153. # This makes Xcode project prettier by moving mapeditor_autogen directory into vcmiclient subfolder
  154. set_property(GLOBAL PROPERTY AUTOGEN_TARGETS_FOLDER vcmieditor)
  155. endif()
  156. target_link_libraries(vcmieditor ${VCMI_LIB_TARGET} Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Network)
  157. target_include_directories(vcmieditor
  158. PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
  159. )
  160. vcmi_set_output_dir(vcmieditor "")
  161. enable_pch(vcmieditor)
  162. # Copy to build directory for easier debugging
  163. add_custom_command(TARGET vcmieditor POST_BUILD
  164. COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/mapeditor/
  165. COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_SOURCE_DIR}/mapeditor/icons ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/mapeditor/icons
  166. COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_BINARY_DIR}/translation ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/mapeditor/translation
  167. )
  168. install(TARGETS vcmieditor DESTINATION ${BIN_DIR})
  169. # copy whole directory
  170. install(DIRECTORY icons DESTINATION ${DATA_DIR}/mapeditor)
  171. install(FILES ${editor_QM} DESTINATION ${DATA_DIR}/mapeditor/translation)
  172. # Install icons and desktop file on Linux
  173. if(NOT WIN32 AND NOT APPLE)
  174. install(FILES "vcmieditor.desktop" DESTINATION share/applications)
  175. install(FILES "icons/mapeditor.32x32.png" DESTINATION share/icons/hicolor/32x32/apps RENAME vcmieditor.png)
  176. install(FILES "icons/mapeditor.48x48.png" DESTINATION share/icons/hicolor/48x48/apps RENAME vcmieditor.png)
  177. install(FILES "icons/mapeditor.64x64.png" DESTINATION share/icons/hicolor/64x64/apps RENAME vcmieditor.png)
  178. install(FILES "icons/mapeditor.128x128.png" DESTINATION share/icons/hicolor/128x128/apps RENAME vcmieditor.png)
  179. install(FILES "icons/mapeditor.256x256.png" DESTINATION share/icons/hicolor/256x256/apps RENAME vcmieditor.png)
  180. endif()