CMakeLists.txt 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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("${CMAKE_VERSION}" VERSION_LESS 2.8.12)
  56. # Executables fail to build with Qt 5 in the default configuration
  57. # without -fPIE. We add that here.
  58. set(CMAKE_CXX_FLAGS "${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS} ${CMAKE_CXX_FLAGS}")
  59. endif()
  60. qt5_wrap_ui(launcher_UI_HEADERS ${launcher_FORMS})
  61. if(WIN32)
  62. set(launcher_ICON VCMI_launcher.rc)
  63. endif()
  64. add_executable(vcmilauncher WIN32 ${launcher_SRCS} ${launcher_HEADERS} ${launcher_UI_HEADERS} ${launcher_ICON})
  65. if(WIN32)
  66. set_target_properties(vcmilauncher
  67. PROPERTIES
  68. OUTPUT_NAME "VCMI_launcher"
  69. PROJECT_LABEL "VCMI_launcher"
  70. )
  71. # FIXME: Can't to get CMP0020 working with Vcpkg and CMake 3.8.2
  72. # So far I tried:
  73. # - cmake_minimum_required set to 2.8.11 globally and in this file
  74. # - cmake_policy in all possible places
  75. # - used NO_POLICY_SCOPE to make sure no other parts reset policies
  76. # Still nothing worked, warning kept appearing and WinMain didn't link automatically
  77. target_link_libraries(vcmilauncher Qt5::WinMain)
  78. endif()
  79. if(APPLE)
  80. # This makes Xcode project prettier by moving vcmilauncher_autogen directory into vcmiclient subfolder
  81. set_property(GLOBAL PROPERTY AUTOGEN_TARGETS_FOLDER vcmilauncher)
  82. endif()
  83. target_link_libraries(vcmilauncher vcmi Qt5::Widgets Qt5::Network)
  84. target_include_directories(vcmilauncher
  85. PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
  86. PRIVATE ${Qt5Widgets_INCLUDE_DIRS}
  87. PRIVATE ${Qt5Network_INCLUDE_DIRS}
  88. )
  89. vcmi_set_output_dir(vcmilauncher "")
  90. # temporary(?) disabled - generation of PCH takes too much time since cotire is trying to collect all Qt headers
  91. #set_target_properties(vcmilauncher PROPERTIES ${PCH_PROPERTIES})
  92. #cotire(vcmilauncher)
  93. # Copy to build directory for easier debugging
  94. add_custom_command(TARGET vcmilauncher POST_BUILD
  95. COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/launcher/icons
  96. COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/launcher/icons ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/launcher/icons
  97. )
  98. install(TARGETS vcmilauncher DESTINATION ${BIN_DIR})
  99. # copy whole directory
  100. install(DIRECTORY icons DESTINATION ${DATA_DIR}/launcher)
  101. # Install icons and desktop file on Linux
  102. if(NOT WIN32 AND NOT APPLE)
  103. install(FILES "vcmilauncher.desktop" DESTINATION share/applications)
  104. endif()