CMakeLists.txt 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. set(launcher_modmanager_SRCS
  2. modManager/cdownloadmanager_moc.cpp
  3. modManager/cmodlist.cpp
  4. modManager/cmodlistmodel_moc.cpp
  5. modManager/cmodlistview_moc.cpp
  6. modManager/cmodmanager.cpp
  7. modManager/imageviewer_moc.cpp
  8. )
  9. set(launcher_modmanager_HEADERS
  10. modManager/cdownloadmanager_moc.h
  11. modManager/cmodlist.h
  12. modManager/cmodlistmodel_moc.h
  13. modManager/cmodlistview_moc.h
  14. modManager/cmodmanager.h
  15. modManager/imageviewer_moc.h
  16. )
  17. set(launcher_settingsview_SRCS
  18. settingsView/csettingsview_moc.cpp
  19. )
  20. set(launcher_settingsview_HEADERS
  21. settingsView/csettingsview_moc.h
  22. )
  23. set(launcher_SRCS
  24. StdInc.cpp
  25. ${launcher_modmanager_SRCS}
  26. ${launcher_settingsview_SRCS}
  27. main.cpp
  28. mainwindow_moc.cpp
  29. launcherdirs.cpp
  30. jsonutils.cpp
  31. updatedialog_moc.cpp
  32. lobby/lobby.cpp
  33. lobby/lobby_moc.cpp
  34. lobby/lobbyroomrequest_moc.cpp
  35. )
  36. set(launcher_HEADERS
  37. StdInc.h
  38. ${launcher_modmanager_HEADERS}
  39. ${launcher_settingsview_HEADERS}
  40. mainwindow_moc.h
  41. launcherdirs.h
  42. jsonutils.h
  43. updatedialog_moc.h
  44. lobby/lobby.h
  45. lobby/lobby_moc.h
  46. lobby/lobbyroomrequest_moc.h
  47. main.h
  48. )
  49. set(launcher_FORMS
  50. modManager/cmodlistview_moc.ui
  51. modManager/imageviewer_moc.ui
  52. settingsView/csettingsview_moc.ui
  53. mainwindow_moc.ui
  54. updatedialog_moc.ui
  55. lobby/lobby_moc.ui
  56. lobby/lobbyroomrequest_moc.ui
  57. )
  58. set(launcher_TS
  59. translation/english.ts
  60. translation/german.ts
  61. translation/polish.ts
  62. translation/russian.ts
  63. translation/ukrainian.ts)
  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. qt_add_translation( launcher_QM ${launcher_TS} )
  81. else()
  82. set_source_files_properties(${launcher_TS} PROPERTIES OUTPUT_LOCATION ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/launcher/translations)
  83. qt5_wrap_ui(launcher_UI_HEADERS ${launcher_FORMS})
  84. qt5_add_translation( launcher_QM ${launcher_TS} )
  85. endif()
  86. if(WIN32)
  87. set(launcher_ICON VCMI_launcher.rc)
  88. endif()
  89. if(BUILD_SINGLE_APP)
  90. add_library(vcmilauncher STATIC ${launcher_SRCS} ${launcher_HEADERS} ${launcher_UI_HEADERS})
  91. else()
  92. add_executable(vcmilauncher WIN32 ${launcher_QM} ${launcher_SRCS} ${launcher_HEADERS} ${launcher_UI_HEADERS} ${launcher_ICON})
  93. endif()
  94. if(WIN32)
  95. set_target_properties(vcmilauncher
  96. PROPERTIES
  97. OUTPUT_NAME "VCMI_launcher"
  98. PROJECT_LABEL "VCMI_launcher"
  99. )
  100. # FIXME: Can't to get CMP0020 working with Vcpkg and CMake 3.8.2
  101. # So far I tried:
  102. # - cmake_minimum_required set to 2.8.11 globally and in this file
  103. # - cmake_policy in all possible places
  104. # - used NO_POLICY_SCOPE to make sure no other parts reset policies
  105. # Still nothing worked, warning kept appearing and WinMain didn't link automatically
  106. target_link_libraries(vcmilauncher Qt${QT_VERSION_MAJOR}::WinMain)
  107. endif()
  108. if(APPLE)
  109. # This makes Xcode project prettier by moving vcmilauncher_autogen directory into vcmiclient subfolder
  110. set_property(GLOBAL PROPERTY AUTOGEN_TARGETS_FOLDER vcmilauncher)
  111. endif()
  112. target_link_libraries(vcmilauncher ${VCMI_LIB_TARGET} Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Network)
  113. target_include_directories(vcmilauncher
  114. PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
  115. )
  116. vcmi_set_output_dir(vcmilauncher "")
  117. enable_pch(vcmilauncher)
  118. if(APPLE_IOS)
  119. set(RESOURCES_DESTINATION ${DATA_DIR})
  120. # workaround https://github.com/conan-io/conan-center-index/issues/13332
  121. if(USING_CONAN)
  122. file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/QIOSIntegrationPlugin.h
  123. "#include <QtPlugin>\nQ_IMPORT_PLUGIN(QIOSIntegrationPlugin)"
  124. )
  125. # target_include_directories(vcmilauncher PRIVATE ${CMAKE_BINARY_DIR})
  126. target_link_libraries(vcmilauncher
  127. Qt${QT_VERSION_MAJOR}::QIOSIntegrationPlugin
  128. qt::QIOSIntegrationPlugin
  129. )
  130. endif()
  131. else()
  132. set(RESOURCES_DESTINATION ${DATA_DIR}/launcher)
  133. # Copy to build directory for easier debugging
  134. add_custom_command(TARGET vcmilauncher POST_BUILD
  135. COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/launcher/icons
  136. COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/launcher/icons ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/launcher/icons
  137. )
  138. install(TARGETS vcmilauncher DESTINATION ${BIN_DIR})
  139. # Install icons and desktop file on Linux
  140. if(NOT WIN32 AND NOT APPLE)
  141. install(FILES "vcmilauncher.desktop" DESTINATION share/applications)
  142. install(FILES "eu.vcmi.VCMI.metainfo.xml" DESTINATION share/metainfo)
  143. endif()
  144. endif()
  145. install(DIRECTORY icons DESTINATION ${RESOURCES_DESTINATION})
  146. install(DIRECTORY ts DESTINATION ${RESOURCES_DESTINATION})