CMakeLists.txt 6.0 KB

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