-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathCMakeLists.txt
84 lines (70 loc) · 2.07 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
82
83
84
# cmake-format: off
# /CMakeLists.txt -*-makefile-*-
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# cmake-format: on
cmake_minimum_required(VERSION 3.23)
project(
beman.inplace_vector
VERSION 1.0.0
DESCRIPTION
"A dynamically-resizable vector with fixed capacity and embedded storage"
LANGUAGES CXX
)
# [CMAKE.SKIP_EXAMPLES]
option(
BEMAN_EXEMPLAR_BUILD_EXAMPLES
"Enable building examples. Default: ON. Values: { ON, OFF }."
${PROJECT_IS_TOP_LEVEL}
)
# [CMAKE.SKIP_TESTS]
option(
BEMAN_INPLACE_VECTOR_BUILD_TESTS
"Enable building tests and test infrastructure. Default: ON. Values: { ON, OFF }."
${PROJECT_IS_TOP_LEVEL}
)
include(FetchContent)
include(GNUInstallDirs)
add_library(beman.inplace_vector INTERFACE)
# [CMAKE.LIBRARY_ALIAS]
add_library(beman::inplace_vector ALIAS beman.inplace_vector)
target_include_directories(
beman.inplace_vector
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
# Install the InplaceVector library to the appropriate destination
install(
TARGETS beman.inplace_vector
EXPORT ${TARGETS_EXPORT_NAME}
DESTINATION
${CMAKE_INSTALL_LIBDIR}
)
# Install the header files to the appropriate destination
install(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${CMAKE_PROJECT_NAME}
FILES_MATCHING
PATTERN
"${CMAKE_CURRENT_SOURCE_DIR}/include/beman/inplace_vector/inplace_vector.hpp"
)
if(BEMAN_INPLACE_VECTOR_BUILD_TESTS)
include(CTest)
enable_testing()
# Fetch GoogleTest
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG
f8d7d77c06936315286eb55f8de22cd23c188571 # release-1.14.0
EXCLUDE_FROM_ALL
)
block()
set(INSTALL_GTEST OFF) # Disable GoogleTest installation
FetchContent_MakeAvailable(googletest)
endblock()
add_subdirectory(tests/beman/inplace_vector)
endif()
if(BEMAN_EXEMPLAR_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()