CMakeLists.txt 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. set(launcher_SRCS
  2. StdInc.cpp
  3. aboutProject/aboutproject_moc.cpp
  4. modManager/cdownloadmanager_moc.cpp
  5. modManager/cmodlist.cpp
  6. modManager/cmodlistmodel_moc.cpp
  7. modManager/cmodlistview_moc.cpp
  8. modManager/cmodmanager.cpp
  9. modManager/imageviewer_moc.cpp
  10. settingsView/csettingsview_moc.cpp
  11. firstLaunch/firstlaunch_moc.cpp
  12. main.cpp
  13. mainwindow_moc.cpp
  14. languages.cpp
  15. launcherdirs.cpp
  16. jsonutils.cpp
  17. updatedialog_moc.cpp
  18. )
  19. set(launcher_HEADERS
  20. StdInc.h
  21. aboutProject/aboutproject_moc.h
  22. modManager/cdownloadmanager_moc.h
  23. modManager/cmodlist.h
  24. modManager/cmodlistmodel_moc.h
  25. modManager/cmodlistview_moc.h
  26. modManager/cmodmanager.h
  27. modManager/imageviewer_moc.h
  28. settingsView/csettingsview_moc.h
  29. firstLaunch/firstlaunch_moc.h
  30. mainwindow_moc.h
  31. languages.h
  32. launcherdirs.h
  33. jsonutils.h
  34. updatedialog_moc.h
  35. main.h
  36. )
  37. set(launcher_FORMS
  38. aboutProject/aboutproject_moc.ui
  39. modManager/cmodlistview_moc.ui
  40. modManager/imageviewer_moc.ui
  41. settingsView/csettingsview_moc.ui
  42. firstLaunch/firstlaunch_moc.ui
  43. mainwindow_moc.ui
  44. updatedialog_moc.ui
  45. )
  46. set(launcher_TS
  47. translation/chinese.ts
  48. translation/czech.ts
  49. translation/english.ts
  50. translation/french.ts
  51. translation/german.ts
  52. translation/polish.ts
  53. translation/russian.ts
  54. translation/spanish.ts
  55. translation/ukrainian.ts
  56. translation/vietnamese.ts
  57. )
  58. if(APPLE_IOS)
  59. list(APPEND launcher_SRCS
  60. ios/main.m
  61. )
  62. endif()
  63. assign_source_group(${launcher_SRCS} ${launcher_HEADERS} VCMI_launcher.rc)
  64. # Tell CMake to run moc when necessary:
  65. set(CMAKE_AUTOMOC ON)
  66. if(POLICY CMP0071)
  67. cmake_policy(SET CMP0071 NEW)
  68. endif()
  69. # As moc files are generated in the binary dir, tell CMake
  70. # to always look for includes there:
  71. set(CMAKE_INCLUDE_CURRENT_DIR ON)
  72. if(TARGET Qt6::Core)
  73. qt_wrap_ui(launcher_UI_HEADERS ${launcher_FORMS})
  74. else()
  75. qt5_wrap_ui(launcher_UI_HEADERS ${launcher_FORMS})
  76. if(ENABLE_TRANSLATIONS)
  77. set_source_files_properties(${launcher_TS} PROPERTIES OUTPUT_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/translation)
  78. qt5_add_translation( launcher_QM ${launcher_TS} )
  79. endif()
  80. endif()
  81. if(WIN32)
  82. set(launcher_ICON VCMI_launcher.rc)
  83. endif()
  84. if(ENABLE_SINGLE_APP_BUILD)
  85. add_library(vcmilauncher STATIC ${launcher_QM} ${launcher_SRCS} ${launcher_HEADERS} ${launcher_UI_HEADERS})
  86. else()
  87. add_executable(vcmilauncher WIN32 ${launcher_QM} ${launcher_SRCS} ${launcher_HEADERS} ${launcher_UI_HEADERS} ${launcher_ICON})
  88. endif()
  89. if(TARGET Qt6::Core)
  90. if(ENABLE_TRANSLATIONS)
  91. set_source_files_properties(${launcher_TS} PROPERTIES OUTPUT_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/translation)
  92. qt_add_translations(vcmilauncher
  93. TS_FILES ${launcher_TS}
  94. QM_FILES_OUTPUT_VARIABLE launcher_QM
  95. INCLUDE_DIRECTORIES
  96. ${CMAKE_CURRENT_BINARY_DIR})
  97. endif()
  98. endif()
  99. if(WIN32)
  100. set_target_properties(vcmilauncher
  101. PROPERTIES
  102. OUTPUT_NAME "VCMI_launcher"
  103. PROJECT_LABEL "VCMI_launcher"
  104. )
  105. # FIXME: Can't to get CMP0020 working with Vcpkg and CMake 3.8.2
  106. # So far I tried:
  107. # - cmake_minimum_required set to 2.8.11 globally and in this file
  108. # - cmake_policy in all possible places
  109. # - used NO_POLICY_SCOPE to make sure no other parts reset policies
  110. # Still nothing worked, warning kept appearing and WinMain didn't link automatically
  111. target_link_libraries(vcmilauncher Qt${QT_VERSION_MAJOR}::WinMain)
  112. endif()
  113. if(APPLE)
  114. # This makes Xcode project prettier by moving vcmilauncher_autogen directory into vcmiclient subfolder
  115. set_property(GLOBAL PROPERTY AUTOGEN_TARGETS_FOLDER vcmilauncher)
  116. endif()
  117. if (NOT APPLE_IOS AND NOT ANDROID)
  118. target_link_libraries(vcmilauncher SDL2::SDL2)
  119. endif()
  120. target_link_libraries(vcmilauncher ${VCMI_LIB_TARGET} Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Network)
  121. target_include_directories(vcmilauncher
  122. PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
  123. )
  124. vcmi_set_output_dir(vcmilauncher "")
  125. enable_pch(vcmilauncher)
  126. if(APPLE_IOS)
  127. set(RESOURCES_DESTINATION ${DATA_DIR})
  128. # TODO: remove after fixing Conan's Qt recipe
  129. if(XCODE_VERSION VERSION_GREATER_EQUAL 14.0)
  130. target_link_libraries(vcmilauncher "-framework IOKit")
  131. endif()
  132. # workaround https://github.com/conan-io/conan-center-index/issues/13332
  133. if(USING_CONAN)
  134. file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/QIOSIntegrationPlugin.h
  135. "#include <QtPlugin>\nQ_IMPORT_PLUGIN(QIOSIntegrationPlugin)"
  136. )
  137. # target_include_directories(vcmilauncher PRIVATE ${CMAKE_BINARY_DIR})
  138. target_link_libraries(vcmilauncher
  139. Qt${QT_VERSION_MAJOR}::QIOSIntegrationPlugin
  140. qt::QIOSIntegrationPlugin
  141. )
  142. endif()
  143. else()
  144. set(RESOURCES_DESTINATION ${DATA_DIR}/launcher)
  145. # Link to build directory for easier debugging
  146. add_custom_command(TARGET vcmilauncher POST_BUILD
  147. COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/launcher
  148. COMMAND ${CMAKE_COMMAND} -P ${CMAKE_SOURCE_DIR}/cmake_modules/create_link.cmake ${CMAKE_SOURCE_DIR}/launcher/icons ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/launcher/icons
  149. COMMAND ${CMAKE_COMMAND} -P ${CMAKE_SOURCE_DIR}/cmake_modules/create_link.cmake ${CMAKE_CURRENT_BINARY_DIR}/translation ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/launcher/translation
  150. )
  151. install(TARGETS vcmilauncher DESTINATION ${BIN_DIR})
  152. # Install icons and desktop file on Linux
  153. if(NOT WIN32 AND NOT APPLE)
  154. install(FILES "vcmilauncher.desktop" DESTINATION share/applications)
  155. install(FILES "eu.vcmi.VCMI.metainfo.xml" DESTINATION share/metainfo)
  156. endif()
  157. endif()
  158. install(DIRECTORY icons DESTINATION ${RESOURCES_DESTINATION})
  159. if(ENABLE_TRANSLATIONS)
  160. install(FILES ${launcher_QM} DESTINATION ${RESOURCES_DESTINATION}/translation)
  161. endif()