CMakeLists.txt 5.5 KB

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