CMakeLists.txt 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. )
  33. set(launcher_HEADERS
  34. StdInc.h
  35. ${launcher_modmanager_HEADERS}
  36. ${launcher_settingsview_HEADERS}
  37. mainwindow_moc.h
  38. launcherdirs.h
  39. jsonutils.h
  40. updatedialog_moc.h
  41. )
  42. set(launcher_FORMS
  43. modManager/cmodlistview_moc.ui
  44. modManager/imageviewer_moc.ui
  45. settingsView/csettingsview_moc.ui
  46. mainwindow_moc.ui
  47. updatedialog_moc.ui
  48. )
  49. if(APPLE_IOS)
  50. set(launcher_SRCS ${launcher_SRCS} ios/mainwindow_moc.mm)
  51. endif()
  52. assign_source_group(${launcher_SRCS} ${launcher_HEADERS} VCMI_launcher.rc)
  53. # Tell CMake to run moc when necessary:
  54. set(CMAKE_AUTOMOC ON)
  55. if(POLICY CMP0071)
  56. cmake_policy(SET CMP0071 NEW)
  57. endif()
  58. # As moc files are generated in the binary dir, tell CMake
  59. # to always look for includes there:
  60. set(CMAKE_INCLUDE_CURRENT_DIR ON)
  61. if(TARGET Qt6::Core)
  62. qt_wrap_ui(launcher_UI_HEADERS ${launcher_FORMS})
  63. else()
  64. qt5_wrap_ui(launcher_UI_HEADERS ${launcher_FORMS})
  65. endif()
  66. if(WIN32)
  67. set(launcher_ICON VCMI_launcher.rc)
  68. endif()
  69. if(BUILD_SINGLE_APP)
  70. add_library(vcmilauncher STATIC ${launcher_SRCS} ${launcher_HEADERS} ${launcher_UI_HEADERS})
  71. else()
  72. add_executable(vcmilauncher WIN32 ${launcher_SRCS} ${launcher_HEADERS} ${launcher_UI_HEADERS} ${launcher_ICON})
  73. endif()
  74. if(WIN32)
  75. set_target_properties(vcmilauncher
  76. PROPERTIES
  77. OUTPUT_NAME "VCMI_launcher"
  78. PROJECT_LABEL "VCMI_launcher"
  79. )
  80. # FIXME: Can't to get CMP0020 working with Vcpkg and CMake 3.8.2
  81. # So far I tried:
  82. # - cmake_minimum_required set to 2.8.11 globally and in this file
  83. # - cmake_policy in all possible places
  84. # - used NO_POLICY_SCOPE to make sure no other parts reset policies
  85. # Still nothing worked, warning kept appearing and WinMain didn't link automatically
  86. target_link_libraries(vcmilauncher Qt${QT_VERSION_MAJOR}::WinMain)
  87. endif()
  88. if(APPLE)
  89. # This makes Xcode project prettier by moving vcmilauncher_autogen directory into vcmiclient subfolder
  90. set_property(GLOBAL PROPERTY AUTOGEN_TARGETS_FOLDER vcmilauncher)
  91. endif()
  92. if(BUILD_SINGLE_APP)
  93. set(VCMI_LIB_TARGET vcmi_lib_client)
  94. else()
  95. set(VCMI_LIB_TARGET vcmi)
  96. endif()
  97. target_link_libraries(vcmilauncher ${VCMI_LIB_TARGET} Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Network)
  98. target_include_directories(vcmilauncher
  99. PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
  100. )
  101. vcmi_set_output_dir(vcmilauncher "")
  102. enable_pch(vcmilauncher)
  103. if(APPLE_IOS)
  104. set(ICONS_DESTINATION ${DATA_DIR})
  105. else()
  106. set(ICONS_DESTINATION ${DATA_DIR}/launcher)
  107. # Copy to build directory for easier debugging
  108. add_custom_command(TARGET vcmilauncher POST_BUILD
  109. COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/launcher/icons
  110. COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/launcher/icons ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/launcher/icons
  111. )
  112. install(TARGETS vcmilauncher DESTINATION ${BIN_DIR})
  113. # Install icons and desktop file on Linux
  114. if(NOT WIN32 AND NOT APPLE)
  115. install(FILES "vcmilauncher.desktop" DESTINATION share/applications)
  116. install(FILES "eu.vcmi.VCMI.metainfo.xml" DESTINATION share/metainfo)
  117. endif()
  118. endif()
  119. install(DIRECTORY icons DESTINATION ${ICONS_DESTINATION})