This repository has been archived by the owner on Oct 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
81 lines (68 loc) · 2.06 KB
/
CMakeLists.txt
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
# CMake settings
cmake_minimum_required( VERSION 3.15 )
# Project settings
project( ptc-print-build
VERSION 1.0
DESCRIPTION "Build system for ptc-print."
LANGUAGES CXX
)
# Error if building out of a build directory
file( TO_CMAKE_PATH "${PROJECT_BINARY_DIR}/CMakeLists.txt" LOC_PATH )
if( EXISTS "${LOC_PATH}" )
message( FATAL_ERROR "You cannot build in a source directory (or any directory with "
"CMakeLists.txt file). Please make a build subdirectory. Feel free to "
"remove CMakeCache.txt and CMakeFiles." )
endif()
# Create interface library
add_library( ptcprint INTERFACE )
add_library( ptcprint::ptcprint ALIAS ptcprint )
# Compile tests
option( PTCPRINT_TESTS "Enable / disable tests." ON )
if( PTCPRINT_TESTS )
add_subdirectory( tests )
else()
message( STATUS "Skipping tests." )
endif()
# Setting installation paths
target_include_directories( ptcprint INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>
)
install(
DIRECTORY include/ptc
DESTINATION include
)
# Creating the package files
install(
TARGETS ptcprint
EXPORT ptcprintTargets
DESTINATION lib
)
install(
EXPORT ptcprintTargets
FILE ptcprintTargets.cmake
NAMESPACE ptcprint::
DESTINATION lib/cmake/ptcprint
)
# Configure package files
include( CMakePackageConfigHelpers )
configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/ptcprintConfig.cmake"
INSTALL_DESTINATION "lib/cmake/ptcprint"
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/ptcprintConfigVersion.cmake"
VERSION "${Tutorial_VERSION_MAJOR}.${Tutorial_VERSION_MINOR}"
COMPATIBILITY AnyNewerVersion
)
install( FILES
${CMAKE_CURRENT_BINARY_DIR}/ptcprintConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/ptcprintConfigVersion.cmake
DESTINATION lib/cmake/ptcprint
)
export( EXPORT ptcprintTargets
FILE "${CMAKE_CURRENT_BINARY_DIR}/ptcprintTargets.cmake"
)