-
Notifications
You must be signed in to change notification settings - Fork 204
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
83 lines (69 loc) · 2.53 KB
/
CMakeLists.txt
File metadata and controls
83 lines (69 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
cmake_minimum_required(VERSION 3.12)
project(CppNumericalSolvers VERSION 2.0.0 LANGUAGES CXX)
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
add_library(CppNumericalSolvers INTERFACE)
option(CppNumericalSolvers_INSTALL "Generate the install target." ON)
option(BUILD_EXAMPLES "Build the examples" OFF)
option(BUILD_TESTS "Build the tests" OFF)
target_include_directories(CppNumericalSolvers
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_compile_features(CppNumericalSolvers INTERFACE cxx_std_17)
if(CppNumericalSolvers_INSTALL)
# Install the interface target and export it.
install(TARGETS CppNumericalSolvers
EXPORT CppNumericalSolversTargets
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
# Install header files (everything under the include/ folder)
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
# Export the target so that consumers can use find_package.
install(EXPORT CppNumericalSolversTargets
FILE CppNumericalSolversTargets.cmake
NAMESPACE CppNumericalSolvers::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/CppNumericalSolvers
)
# Generate the package configuration file from a template.
configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/CppNumericalSolversConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/CppNumericalSolvers
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
# Generate the version file.
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/CppNumericalSolversConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)
# Install the generated config files.
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/CppNumericalSolversConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/CppNumericalSolversConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/CppNumericalSolvers
)
# Export the target for use from the build tree.
export(TARGETS CppNumericalSolvers NAMESPACE CppNumericalSolvers:: FILE CppNumericalSolversTargets.cmake)
export(PACKAGE CppNumericalSolvers)
# pkg-config support.
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/cppoptlib.pc.in
${CMAKE_CURRENT_BINARY_DIR}/cppoptlib.pc
@ONLY
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/cppoptlib.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
)
endif()
if(BUILD_EXAMPLES)
add_subdirectory(src/examples)
endif()
if(BUILD_TESTS)
enable_testing()
add_subdirectory(src/test)
endif()