CMakeLists.txt 5.7 KB

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