CMakeLists.txt 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. install(
  22. TARGETS Tutorial
  23. EXPORT TutorialTargets
  24. )
  25. endif()
  26. if(BUILD_TESTING)
  27. enable_testing()
  28. add_subdirectory(Tests)
  29. endif()
  30. add_subdirectory(MathFunctions)
  31. include(GNUInstallDirs)
  32. install(
  33. TARGETS MathFunctions OpAdd OpMul OpSub MathLogger SqrtTable
  34. EXPORT TutorialTargets
  35. FILE_SET HEADERS
  36. )
  37. install(
  38. EXPORT TutorialTargets
  39. DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Tutorial
  40. NAMESPACE Tutorial::
  41. )
  42. include(CMakePackageConfigHelpers)
  43. write_basic_package_version_file(
  44. ${CMAKE_CURRENT_BINARY_DIR}/TutorialConfigVersion.cmake
  45. COMPATIBILITY ExactVersion
  46. )
  47. install(
  48. FILES
  49. cmake/TutorialConfig.cmake
  50. ${CMAKE_CURRENT_BINARY_DIR}/TutorialConfigVersion.cmake
  51. DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Tutorial
  52. )