CMakeLists.txt 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # Minimum required CMake and project declaration
  2. cmake_minimum_required(VERSION 3.5)
  3. # Enable both C and CXX languages so C and C++ toolchains are configured.
  4. project(V-Gears VERSION 0.1.19 LANGUAGES C CXX)
  5. # Provide a central common include for project-wide policies and defaults.
  6. list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake")
  7. include(ProjectCommon)
  8. # Configure CMake options
  9. option(USE_COTIRE "Enable cotire precompiled header support" ON)
  10. option(BUILD_INSTALLER "Build the V-Gears-Installer" TRUE)
  11. option(BUILD_TESTS "Build the unit tests" FALSE)
  12. option(MULTITHREADING "Enable multithreading" TRUE)
  13. # Hint for Qt configuration dirs. Setting this early helps subprojects locate
  14. # Qt via config-mode packages when installs are in distro-specific locations.
  15. # Example: -DQT_DIR_HINT=/usr/lib/x86_64-linux-gnu/cmake
  16. set(QT_DIR_HINT "" CACHE PATH "Optional hint for Qt CMake config directory (parent of Qt5/Qt6)")
  17. if(QT_DIR_HINT)
  18. list(APPEND CMAKE_PREFIX_PATH "${QT_DIR_HINT}")
  19. if(EXISTS "${QT_DIR_HINT}/Qt5")
  20. set(Qt5_DIR "${QT_DIR_HINT}/Qt5" CACHE PATH "Qt5 dir from hint" FORCE)
  21. elseif(EXISTS "${QT_DIR_HINT}/Qt5Core")
  22. set(Qt5_DIR "${QT_DIR_HINT}/Qt5Core" CACHE PATH "Qt5 dir from hint" FORCE)
  23. endif()
  24. if(EXISTS "${QT_DIR_HINT}/Qt6")
  25. set(Qt6_DIR "${QT_DIR_HINT}/Qt6" CACHE PATH "Qt6 dir from hint" FORCE)
  26. endif()
  27. endif()
  28. # Optionally enable cotire (precompiled header/speedup).
  29. if(USE_COTIRE)
  30. include(cotire OPTIONAL RESULT_VARIABLE COTIRE_INCLUDE_RESULT)
  31. if(NOT COTIRE_INCLUDE_RESULT)
  32. message(WARNING "cotire requested but cotire.cmake not found in CMake modules; skipping")
  33. endif()
  34. endif()
  35. set(CMAKE_PACKAGE_ICON v-gears.png)
  36. # Generate version header into the build tree so source tree is not modified.
  37. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/Version.h.in ${CMAKE_BINARY_DIR}/generated/Version.h @ONLY)
  38. include_directories(${CMAKE_BINARY_DIR}/generated)
  39. # Default build type when none is supplied by the caller.
  40. if(NOT CMAKE_BUILD_TYPE)
  41. set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build" FORCE)
  42. endif()
  43. # First, build external libraries (luabind and luajit).
  44. add_subdirectory(lib)
  45. # Build v-gears (and, if requested, the installer).
  46. add_subdirectory(src)
  47. # If requested, build tests
  48. if(BUILD_TESTS)
  49. add_subdirectory(test)
  50. endif()
  51. # TODO: Generate Installer (.msi, .deb, .appImage...)