CMakeLists.txt 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. cmake_minimum_required(VERSION 3.23)
  2. project(Tutorial
  3. VERSION 1.0.0
  4. )
  5. option(TUTORIAL_BUILD_UTILITIES "Build the Tutorial executable" ON)
  6. option(TUTORIAL_USE_STD_SQRT "Use std::sqrt" OFF)
  7. option(TUTORIAL_ENABLE_IPO "Check for and use IPO support" ON)
  8. option(BUILD_TESTING "Enable testing and build tests" ON)
  9. if(TUTORIAL_ENABLE_IPO)
  10. include(CheckIPOSupported)
  11. check_ipo_supported(RESULT result OUTPUT output)
  12. if(result)
  13. message("IPO is supported, enabling IPO")
  14. set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
  15. else()
  16. message(WARNING "IPO is not supported: ${output}")
  17. endif()
  18. endif()
  19. if(TUTORIAL_BUILD_UTILITIES)
  20. add_subdirectory(Tutorial)
  21. endif()
  22. if(BUILD_TESTING)
  23. enable_testing()
  24. add_subdirectory(Tests)
  25. endif()
  26. add_subdirectory(MathFunctions)
  27. include(GNUInstallDirs)
  28. install(
  29. TARGETS MathFunctions OpAdd OpMul OpSub MathLogger SqrtTable
  30. EXPORT TutorialTargets
  31. FILE_SET HEADERS
  32. )
  33. install(
  34. EXPORT TutorialTargets
  35. DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Tutorial
  36. NAMESPACE Tutorial::
  37. )
  38. include(CMakePackageConfigHelpers)
  39. write_basic_package_version_file(
  40. ${CMAKE_CURRENT_BINARY_DIR}/TutorialConfigVersion.cmake
  41. COMPATIBILITY ExactVersion
  42. )
  43. install(
  44. FILES
  45. cmake/TutorialConfig.cmake
  46. ${CMAKE_CURRENT_BINARY_DIR}/TutorialConfigVersion.cmake
  47. DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Tutorial
  48. )