CMakeLists.txt 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. if(ENABLE_TRANSLATIONS)
  88. set_source_files_properties(${editor_TS} PROPERTIES OUTPUT_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/translation)
  89. # TODO: consider using qt_add_translations: https://doc.qt.io/qt-6/qtlinguist-cmake-qt-add-translations.html
  90. qt_add_translation( editor_QM ${editor_TS} )
  91. endif()
  92. else()
  93. qt5_wrap_ui(editor_UI_HEADERS ${editor_FORMS})
  94. if(ENABLE_TRANSLATIONS)
  95. set_source_files_properties(${editor_TS} PROPERTIES OUTPUT_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/translation)
  96. qt5_add_translation( editor_QM ${editor_TS} )
  97. endif()
  98. endif()
  99. if(WIN32)
  100. set(editor_ICON mapeditor.rc)
  101. endif()
  102. add_executable(vcmieditor WIN32 ${editor_QM} ${editor_SRCS} ${editor_HEADERS} ${editor_UI_HEADERS} ${editor_ICON})
  103. if(WIN32)
  104. set_target_properties(vcmieditor
  105. PROPERTIES
  106. OUTPUT_NAME "VCMI_mapeditor"
  107. PROJECT_LABEL "VCMI_mapeditor"
  108. )
  109. # FIXME: Can't to get CMP0020 working with Vcpkg and CMake 3.8.2
  110. # So far I tried:
  111. # - cmake_minimum_required set to 2.8.11 globally and in this file
  112. # - cmake_policy in all possible places
  113. # - used NO_POLICY_SCOPE to make sure no other parts reset policies
  114. # Still nothing worked, warning kept appearing and WinMain didn't link automatically
  115. target_link_libraries(vcmieditor Qt${QT_VERSION_MAJOR}::WinMain)
  116. endif()
  117. if(APPLE)
  118. # This makes Xcode project prettier by moving mapeditor_autogen directory into vcmiclient subfolder
  119. set_property(GLOBAL PROPERTY AUTOGEN_TARGETS_FOLDER vcmieditor)
  120. endif()
  121. target_link_libraries(vcmieditor ${VCMI_LIB_TARGET} Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Network)
  122. target_include_directories(vcmieditor
  123. PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
  124. )
  125. vcmi_set_output_dir(vcmieditor "")
  126. enable_pch(vcmieditor)
  127. # Copy to build directory for easier debugging
  128. add_custom_command(TARGET vcmieditor POST_BUILD
  129. COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/mapeditor/
  130. COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_SOURCE_DIR}/mapeditor/icons ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/mapeditor/icons
  131. COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_BINARY_DIR}/translation ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/mapeditor/translation
  132. )
  133. install(TARGETS vcmieditor DESTINATION ${BIN_DIR})
  134. # copy whole directory
  135. install(DIRECTORY icons DESTINATION ${DATA_DIR}/mapeditor)
  136. install(FILES ${editor_QM} DESTINATION ${DATA_DIR}/mapeditor/translation)
  137. # Install icons and desktop file on Linux
  138. if(NOT WIN32 AND NOT APPLE)
  139. install(FILES "vcmieditor.desktop" DESTINATION share/applications)
  140. install(FILES "icons/mapeditor.32x32.png" DESTINATION share/icons/hicolor/32x32/apps RENAME vcmieditor.png)
  141. install(FILES "icons/mapeditor.48x48.png" DESTINATION share/icons/hicolor/48x48/apps RENAME vcmieditor.png)
  142. install(FILES "icons/mapeditor.64x64.png" DESTINATION share/icons/hicolor/64x64/apps RENAME vcmieditor.png)
  143. install(FILES "icons/mapeditor.128x128.png" DESTINATION share/icons/hicolor/128x128/apps RENAME vcmieditor.png)
  144. install(FILES "icons/mapeditor.256x256.png" DESTINATION share/icons/hicolor/256x256/apps RENAME vcmieditor.png)
  145. endif()