CMakeLists.txt 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
  14. else()
  15. message(WARNING "IPO is not supported ${message}")
  16. endif()
  17. endif()
  18. if(TUTORIAL_BUILD_UTILITIES)
  19. add_subdirectory(Tutorial)
  20. install(
  21. TARGETS Tutorial
  22. EXPORT TutorialTargets
  23. )
  24. endif()
  25. if(BUILD_TESTING)
  26. enable_testing()
  27. add_subdirectory(Tests)
  28. endif()
  29. add_subdirectory(MathFunctions)
  30. include(GNUInstallDirs)
  31. install(
  32. TARGETS MathFunctions OpAdd OpMul OpSub MathLogger SqrtTable
  33. EXPORT TutorialTargets
  34. FILE_SET HEADERS
  35. )
  36. install(
  37. EXPORT TutorialTargets
  38. DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Tutorial
  39. NAMESPACE Tutorial::
  40. )
  41. include(CMakePackageConfigHelpers)
  42. write_basic_package_version_file(
  43. ${CMAKE_CURRENT_BINARY_DIR}/TutorialConfigVersion.cmake
  44. COMPATIBILITY ExactVersion
  45. )
  46. install(
  47. FILES
  48. cmake/TutorialConfig.cmake
  49. ${CMAKE_CURRENT_BINARY_DIR}/TutorialConfigVersion.cmake
  50. DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Tutorial
  51. )