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