CMakeLists.txt 6.1 KB

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