CMakeLists.txt 1.3 KB

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