CMakeLists.txt 4.9 KB

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