CMakeLists.txt 5.6 KB

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