CMakeLists.txt 3.3 KB

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