CMakeLists.txt 5.3 KB

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