-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
97 lines (78 loc) · 2.55 KB
/
CMakeLists.txt
File metadata and controls
97 lines (78 loc) · 2.55 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
cmake_minimum_required(VERSION 3.23...3.30)
# ---- Get project VERSION major.minor.patch ----
# ---- extracts version from 'git describe' ----
# The git repo is tagged with e.g v1.2 version major.minor numbers only
# with the patch number extracted from 'git describe' which appends the
# number of commits since the tag (and a hash) -NUMCOMMITS-gHEXHASH
find_package(Git)
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --tags --long
OUTPUT_VARIABLE GIT_DESCRIBE_TAGS
OUTPUT_STRIP_TRAILING_WHITESPACE
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
)
string(REGEX REPLACE "v([0-9]*)\.([0-9]*)-([0-9]*)-g[a-f0-9]*$"
"\\1.\\2.\\3" VERSION_NUMBERS_FROM_GIT ${GIT_DESCRIBE_TAGS})
project(
c_array_support
VERSION ${VERSION_NUMBERS_FROM_GIT}
DESCRIPTION "Concepts, traits and utils for handing C arrays. C++20"
HOMEPAGE_URL "https://github.com/lemuriad/c_array_support"
LANGUAGES CXX
)
option(C_ARRAY_SUPPORT_TESTS "Build tests" ${PROJECT_IS_TOP_LEVEL})
# ---- Declare library ----
add_library(c_array_support INTERFACE)
add_library(c_array::support ALIAS c_array_support)
target_compile_features(c_array_support INTERFACE cxx_std_20)
set_property(
TARGET c_array_support PROPERTY
EXPORT_NAME c_array_support
)
target_sources(
c_array_support
INTERFACE
FILE_SET api
TYPE HEADERS
BASE_DIRS c_array_support
FILES
c_array_support/c_array_support.hpp
c_array_support/util_traits.hpp
c_array_support/c_array_assign.hpp
c_array_support/c_array_compare.hpp
c_array_support/namespace.hpp
c_array_support/ALLOW_ZERO_SIZE_ARRAY.hpp
)
# ---- Install rules ----
if (NOT CMAKE_SKIP_INSTALL_RULES)
if (PROJECT_IS_TOP_LEVEL)
set(
CMAKE_INSTALL_INCLUDEDIR "include/c_array_support-${PROJECT_VERSION}"
CACHE STRING ""
)
set_property(CACHE CMAKE_INSTALL_INCLUDEDIR PROPERTY TYPE PATH)
endif()
# Project is configured with no languages, so tell GNUInstallDirs the lib dir
set(CMAKE_INSTALL_LIBDIR lib CACHE PATH "")
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
# find_package(<package>) call for consumers to find this project
set(package c_array_support)
install(
TARGETS c_array_support
EXPORT c_array_supportTargets
FILE_SET api
)
write_basic_package_version_file(
"${package}ConfigVersion.cmake"
COMPATIBILITY SameMajorVersion
ARCH_INDEPENDENT
)
endif()
# ---- Developer mode ----
if (C_ARRAY_SUPPORT_TESTS)
include(CTest)
if (BUILD_TESTING)
add_subdirectory(tests)
endif()
endif()