CMakeLists.txt 6.3 KB

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