CMakeLists.txt 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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/portuguese.ts
  115. translation/russian.ts
  116. translation/spanish.ts
  117. translation/ukrainian.ts
  118. translation/vietnamese.ts
  119. )
  120. assign_source_group(${editor_SRCS} ${editor_HEADERS} mapeditor.rc)
  121. # Tell CMake to run moc when necessary:
  122. set(CMAKE_AUTOMOC ON)
  123. if(POLICY CMP0071)
  124. cmake_policy(SET CMP0071 NEW)
  125. endif()
  126. # As moc files are generated in the binary dir, tell CMake
  127. # to always look for includes there:
  128. set(CMAKE_INCLUDE_CURRENT_DIR ON)
  129. if(TARGET Qt6::Core)
  130. qt_wrap_ui(editor_UI_HEADERS ${editor_FORMS})
  131. else()
  132. qt5_wrap_ui(editor_UI_HEADERS ${editor_FORMS})
  133. if(ENABLE_TRANSLATIONS)
  134. set_source_files_properties(${editor_TS} PROPERTIES OUTPUT_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/translation)
  135. qt5_add_translation( editor_QM ${editor_TS} )
  136. endif()
  137. endif()
  138. if(WIN32)
  139. set(editor_ICON mapeditor.rc)
  140. endif()
  141. add_executable(vcmieditor WIN32 ${editor_QM} ${editor_SRCS} ${editor_HEADERS} ${editor_UI_HEADERS} ${editor_ICON})
  142. if(TARGET Qt6::Core)
  143. if(ENABLE_TRANSLATIONS)
  144. set_source_files_properties(${editor_TS} PROPERTIES OUTPUT_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/translation)
  145. qt_add_translations(vcmieditor
  146. TS_FILES ${editor_TS}
  147. QM_FILES_OUTPUT_VARIABLE editor_QM
  148. INCLUDE_DIRECTORIES
  149. ${CMAKE_CURRENT_BINARY_DIR})
  150. endif()
  151. endif()
  152. if(WIN32)
  153. set_target_properties(vcmieditor
  154. PROPERTIES
  155. OUTPUT_NAME "VCMI_mapeditor"
  156. PROJECT_LABEL "VCMI_mapeditor"
  157. )
  158. # FIXME: Can't to get CMP0020 working with Vcpkg and CMake 3.8.2
  159. # So far I tried:
  160. # - cmake_minimum_required set to 2.8.11 globally and in this file
  161. # - cmake_policy in all possible places
  162. # - used NO_POLICY_SCOPE to make sure no other parts reset policies
  163. # Still nothing worked, warning kept appearing and WinMain didn't link automatically
  164. target_link_libraries(vcmieditor Qt${QT_VERSION_MAJOR}::WinMain)
  165. endif()
  166. if(APPLE)
  167. # This makes Xcode project prettier by moving mapeditor_autogen directory into vcmiclient subfolder
  168. set_property(GLOBAL PROPERTY AUTOGEN_TARGETS_FOLDER vcmieditor)
  169. endif()
  170. target_link_libraries(vcmieditor vcmi Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Network)
  171. target_include_directories(vcmieditor
  172. PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
  173. )
  174. vcmi_set_output_dir(vcmieditor "")
  175. enable_pch(vcmieditor)
  176. # Copy to build directory for easier debugging
  177. add_custom_command(TARGET vcmieditor POST_BUILD
  178. COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/mapeditor/
  179. 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
  180. 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
  181. )
  182. install(TARGETS vcmieditor DESTINATION ${BIN_DIR})
  183. # copy whole directory
  184. install(DIRECTORY icons DESTINATION ${DATA_DIR}/mapeditor)
  185. install(FILES ${editor_QM} DESTINATION ${DATA_DIR}/mapeditor/translation)
  186. # Install icons and desktop file on Linux
  187. if(NOT WIN32 AND NOT APPLE)
  188. install(FILES "vcmieditor.desktop" DESTINATION share/applications)
  189. install(FILES "icons/mapeditor.32x32.png" DESTINATION share/icons/hicolor/32x32/apps RENAME vcmieditor.png)
  190. install(FILES "icons/mapeditor.48x48.png" DESTINATION share/icons/hicolor/48x48/apps RENAME vcmieditor.png)
  191. install(FILES "icons/mapeditor.64x64.png" DESTINATION share/icons/hicolor/64x64/apps RENAME vcmieditor.png)
  192. install(FILES "icons/mapeditor.128x128.png" DESTINATION share/icons/hicolor/128x128/apps RENAME vcmieditor.png)
  193. install(FILES "icons/mapeditor.256x256.png" DESTINATION share/icons/hicolor/256x256/apps RENAME vcmieditor.png)
  194. endif()