-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
77 lines (63 loc) · 2 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
cmake_minimum_required(VERSION 3.12)
# Check if CPP-AP is a top level project
if (NOT DEFINED PROJECT_NAME)
set(CPP_AP_IS_TOP_LEVEL_PROJECT ON)
else()
set(CPP_AP_IS_TOP_LEVEL_PROJECT OFF)
endif()
project(cpp-ap
VERSION 1.0
DESCRIPTION "Command-line argument parser for C++20"
HOMEPAGE_URL "https://github.com/SpectraL519/cpp-ap"
LANGUAGES CXX
)
option(BUILD_TESTS "Build project tests" OFF)
# Define the library target
add_library(cpp-ap INTERFACE)
target_include_directories(cpp-ap INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
set_target_properties(cpp-ap PROPERTIES
CXX_STANDARD 20
CXX_STANDARD_REQUIRED YES
)
# Installation configuration
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
# Install the headers
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
# Install the library target
install(TARGETS cpp-ap EXPORT cpp-ap-targets)
# Create a Config file for find_package
configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/cpp-ap-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/cpp-ap-config.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/cpp-ap
)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/cpp-ap-config-version.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY ExactVersion
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/cpp-ap-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/cpp-ap-config-version.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/cpp-ap
)
install(EXPORT cpp-ap-targets
FILE cpp-ap-targets.cmake
NAMESPACE cpp-ap::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/cpp-ap
)
# Include the tests directory if CPP-AP is a top level project
if (CPP_AP_IS_TOP_LEVEL_PROJECT AND BUILD_TESTS)
add_subdirectory(tests)
endif()
# Exporting from the build tree
export(EXPORT cpp-ap-targets
FILE ${CMAKE_CURRENT_BINARY_DIR}/cpp-ap-targets.cmake
NAMESPACE cpp-ap::
)
export(PACKAGE cpp-ap)