CMakeLists.txt 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. # Detailed information about CMake compatibility available on Qt website
  2. # https://doc.qt.io/qt-5/cmake-manual.html
  3. include_directories(${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/include ${CMAKE_CURRENT_SOURCE_DIR})
  4. include_directories(${ZLIB_INCLUDE_DIR} ${Boost_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS})
  5. include_directories(${SDL_INCLUDE_DIR})
  6. set(launcher_modmanager_SRCS
  7. modManager/cdownloadmanager_moc.cpp
  8. modManager/cmodlist.cpp
  9. modManager/cmodlistmodel_moc.cpp
  10. modManager/cmodlistview_moc.cpp
  11. modManager/cmodmanager.cpp
  12. modManager/imageviewer_moc.cpp
  13. )
  14. set(launcher_modmanager_HEADERS
  15. modManager/cdownloadmanager_moc.h
  16. modManager/cmodlist.h
  17. modManager/cmodlistmodel_moc.h
  18. modManager/cmodlistview_moc.h
  19. modManager/cmodmanager.h
  20. modManager/imageviewer_moc.h
  21. )
  22. set(launcher_settingsview_SRCS
  23. settingsView/csettingsview_moc.cpp
  24. )
  25. set(launcher_settingsview_HEADERS
  26. settingsView/csettingsview_moc.h
  27. )
  28. set(launcher_SRCS
  29. StdInc.cpp
  30. ${launcher_modmanager_SRCS}
  31. ${launcher_settingsview_SRCS}
  32. main.cpp
  33. mainwindow_moc.cpp
  34. launcherdirs.cpp
  35. jsonutils.cpp
  36. sdldisplayquery.cpp
  37. )
  38. set(launcher_HEADERS
  39. StdInc.h
  40. ${launcher_modmanager_HEADERS}
  41. ${launcher_settingsview_HEADERS}
  42. mainwindow_moc.h
  43. launcherdirs.h
  44. jsonutils.h
  45. sdldisplayquery.h
  46. )
  47. set(launcher_FORMS
  48. modManager/cmodlistview_moc.ui
  49. modManager/imageviewer_moc.ui
  50. settingsView/csettingsview_moc.ui
  51. mainwindow_moc.ui
  52. )
  53. assign_source_group(${launcher_SRCS} ${launcher_HEADERS} VCMI_launcher.rc)
  54. # Tell CMake to run moc when necessary:
  55. set(CMAKE_AUTOMOC ON)
  56. # As moc files are generated in the binary dir, tell CMake
  57. # to always look for includes there:
  58. set(CMAKE_INCLUDE_CURRENT_DIR ON)
  59. #### We need add -DQT_WIDGETS_LIB when using QtWidgets in Qt 5.
  60. ###add_definitions(${Qt5Widgets_DEFINITIONS})
  61. ###add_definitions(${Qt5Network_DEFINITIONS})
  62. if("${CMAKE_VERSION}" VERSION_LESS 2.8.12)
  63. # Executables fail to build with Qt 5 in the default configuration
  64. # without -fPIE. We add that here.
  65. set(CMAKE_CXX_FLAGS "${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS} ${CMAKE_CXX_FLAGS}")
  66. endif()
  67. qt5_wrap_ui(launcher_UI_HEADERS ${launcher_FORMS})
  68. if(WIN32)
  69. set(launcher_ICON VCMI_launcher.rc)
  70. endif()
  71. add_executable(vcmilauncher WIN32 ${launcher_SRCS} ${launcher_HEADERS} ${launcher_UI_HEADERS} ${launcher_ICON})
  72. if(WIN32)
  73. set_target_properties(vcmilauncher
  74. PROPERTIES
  75. OUTPUT_NAME "VCMI_launcher"
  76. PROJECT_LABEL "VCMI_launcher"
  77. )
  78. # FIXME: Can't to get CMP0020 working with Vcpkg and CMake 3.8.2
  79. # So far I tried:
  80. # - cmake_minimum_required set to 2.8.11 globally and in this file
  81. # - cmake_policy in all possible places
  82. # - used NO_POLICY_SCOPE to make sure no other parts reset policies
  83. # Still nothing worked, warning kept appearing and WinMain didn't link automatically
  84. target_link_libraries(vcmilauncher Qt5::WinMain)
  85. endif()
  86. target_link_libraries(vcmilauncher vcmi Qt5::Widgets Qt5::Network ${SDL_LIBRARY})
  87. vcmi_set_output_dir(vcmilauncher "")
  88. # temporary(?) disabled - generation of PCH takes too much time since cotire is trying to collect all Qt headers
  89. #set_target_properties(vcmilauncher PROPERTIES ${PCH_PROPERTIES})
  90. #cotire(vcmilauncher)
  91. if(NOT APPLE) # Already inside bundle
  92. install(TARGETS vcmilauncher DESTINATION ${BIN_DIR})
  93. # copy whole directory
  94. install(DIRECTORY icons DESTINATION ${DATA_DIR}/launcher)
  95. endif()