CMakeLists.txt 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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. lobby/lobby.cpp
  19. lobby/lobby_moc.cpp
  20. lobby/lobbyroomrequest_moc.cpp
  21. lobby/chat_moc.cpp
  22. )
  23. set(launcher_HEADERS
  24. StdInc.h
  25. aboutProject/aboutproject_moc.h
  26. modManager/cdownloadmanager_moc.h
  27. modManager/cmodlist.h
  28. modManager/cmodlistmodel_moc.h
  29. modManager/cmodlistview_moc.h
  30. modManager/cmodmanager.h
  31. modManager/imageviewer_moc.h
  32. settingsView/csettingsview_moc.h
  33. firstLaunch/firstlaunch_moc.h
  34. mainwindow_moc.h
  35. languages.h
  36. launcherdirs.h
  37. jsonutils.h
  38. updatedialog_moc.h
  39. lobby/lobby.h
  40. lobby/lobby_moc.h
  41. lobby/lobbyroomrequest_moc.h
  42. lobby/chat_moc.h
  43. main.h
  44. )
  45. set(launcher_FORMS
  46. aboutProject/aboutproject_moc.ui
  47. modManager/cmodlistview_moc.ui
  48. modManager/imageviewer_moc.ui
  49. settingsView/csettingsview_moc.ui
  50. firstLaunch/firstlaunch_moc.ui
  51. mainwindow_moc.ui
  52. updatedialog_moc.ui
  53. lobby/lobby_moc.ui
  54. lobby/lobbyroomrequest_moc.ui
  55. lobby/chat_moc.ui
  56. )
  57. set(launcher_TS
  58. translation/chinese.ts
  59. translation/english.ts
  60. translation/french.ts
  61. translation/german.ts
  62. translation/polish.ts
  63. translation/russian.ts
  64. translation/spanish.ts
  65. translation/ukrainian.ts
  66. )
  67. if(APPLE_IOS)
  68. list(APPEND launcher_SRCS
  69. ios/main.m
  70. )
  71. endif()
  72. assign_source_group(${launcher_SRCS} ${launcher_HEADERS} VCMI_launcher.rc)
  73. # Tell CMake to run moc when necessary:
  74. set(CMAKE_AUTOMOC ON)
  75. if(POLICY CMP0071)
  76. cmake_policy(SET CMP0071 NEW)
  77. endif()
  78. # As moc files are generated in the binary dir, tell CMake
  79. # to always look for includes there:
  80. set(CMAKE_INCLUDE_CURRENT_DIR ON)
  81. if(TARGET Qt6::Core)
  82. qt_wrap_ui(launcher_UI_HEADERS ${launcher_FORMS})
  83. else()
  84. qt5_wrap_ui(launcher_UI_HEADERS ${launcher_FORMS})
  85. if(ENABLE_TRANSLATIONS)
  86. set_source_files_properties(${launcher_TS} PROPERTIES OUTPUT_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/translation)
  87. qt5_add_translation( launcher_QM ${launcher_TS} )
  88. endif()
  89. endif()
  90. if(WIN32)
  91. set(launcher_ICON VCMI_launcher.rc)
  92. endif()
  93. if(ENABLE_SINGLE_APP_BUILD)
  94. add_library(vcmilauncher STATIC ${launcher_QM} ${launcher_SRCS} ${launcher_HEADERS} ${launcher_UI_HEADERS})
  95. else()
  96. add_executable(vcmilauncher WIN32 ${launcher_QM} ${launcher_SRCS} ${launcher_HEADERS} ${launcher_UI_HEADERS} ${launcher_ICON})
  97. endif()
  98. if(TARGET Qt6::Core)
  99. if(ENABLE_TRANSLATIONS)
  100. set_source_files_properties(${launcher_TS} PROPERTIES OUTPUT_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/translation)
  101. qt_add_translations(vcmilauncher
  102. TS_FILES ${launcher_TS}
  103. QM_FILES_OUTPUT_VARIABLE launcher_QM
  104. INCLUDE_DIRECTORIES
  105. ${CMAKE_CURRENT_BINARY_DIR})
  106. endif()
  107. endif()
  108. if(WIN32)
  109. set_target_properties(vcmilauncher
  110. PROPERTIES
  111. OUTPUT_NAME "VCMI_launcher"
  112. PROJECT_LABEL "VCMI_launcher"
  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(vcmilauncher Qt${QT_VERSION_MAJOR}::WinMain)
  121. endif()
  122. if(APPLE)
  123. # This makes Xcode project prettier by moving vcmilauncher_autogen directory into vcmiclient subfolder
  124. set_property(GLOBAL PROPERTY AUTOGEN_TARGETS_FOLDER vcmilauncher)
  125. endif()
  126. if (NOT APPLE_IOS AND NOT ANDROID)
  127. target_link_libraries(vcmilauncher SDL2::SDL2)
  128. endif()
  129. target_link_libraries(vcmilauncher ${VCMI_LIB_TARGET} Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Network)
  130. target_include_directories(vcmilauncher
  131. PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
  132. )
  133. vcmi_set_output_dir(vcmilauncher "")
  134. enable_pch(vcmilauncher)
  135. if(APPLE_IOS)
  136. set(RESOURCES_DESTINATION ${DATA_DIR})
  137. # TODO: remove after fixing Conan's Qt recipe
  138. if(XCODE_VERSION VERSION_GREATER_EQUAL 14.0)
  139. target_link_libraries(vcmilauncher "-framework IOKit")
  140. endif()
  141. # workaround https://github.com/conan-io/conan-center-index/issues/13332
  142. if(USING_CONAN)
  143. file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/QIOSIntegrationPlugin.h
  144. "#include <QtPlugin>\nQ_IMPORT_PLUGIN(QIOSIntegrationPlugin)"
  145. )
  146. # target_include_directories(vcmilauncher PRIVATE ${CMAKE_BINARY_DIR})
  147. target_link_libraries(vcmilauncher
  148. Qt${QT_VERSION_MAJOR}::QIOSIntegrationPlugin
  149. qt::QIOSIntegrationPlugin
  150. )
  151. endif()
  152. else()
  153. set(RESOURCES_DESTINATION ${DATA_DIR}/launcher)
  154. # Copy to build directory for easier debugging
  155. add_custom_command(TARGET vcmilauncher POST_BUILD
  156. COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/launcher
  157. COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_SOURCE_DIR}/launcher/icons ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/launcher/icons
  158. COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_BINARY_DIR}/translation ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/launcher/translation
  159. )
  160. install(TARGETS vcmilauncher DESTINATION ${BIN_DIR})
  161. # Install icons and desktop file on Linux
  162. if(NOT WIN32 AND NOT APPLE)
  163. install(FILES "vcmilauncher.desktop" DESTINATION share/applications)
  164. install(FILES "eu.vcmi.VCMI.metainfo.xml" DESTINATION share/metainfo)
  165. endif()
  166. endif()
  167. install(DIRECTORY icons DESTINATION ${RESOURCES_DESTINATION})
  168. if(ENABLE_TRANSLATIONS)
  169. install(FILES ${launcher_QM} DESTINATION ${RESOURCES_DESTINATION}/translation)
  170. endif()