-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
122 lines (108 loc) · 4.17 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# MIT License
#
# Copyright (c) 2022-2024 Paul Bowen-Huggett
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
cmake_minimum_required (VERSION 3.22)
project (icubaby
VERSION "1.2.4"
DESCRIPTION "Little Library to Immediately Convert Unicode"
LANGUAGES C CXX
)
option (ICUBABY_COVERAGE "Generate LLVM Source-based Coverage" No)
option (ICUBABY_CXX17 "Use C++17 (rather than the default C++20)" No)
option (ICUBABY_EXAMPLES "Include example code in the generated build" No)
option (ICUBABY_FUZZTEST "Enable FuzzTest (if yes, overrides ICUBABY_UNIT_TESTS)" No)
option (ICUBABY_LIBCXX "Use libc++ rather than libstdc++ (clang only)")
option (ICUBABY_SANITIZE "Enable undefined behavior- and address-sanitizers where supported" No)
option (ICUBABY_STANDALONE "A standalone build includes test executables" No)
option (ICUBABY_UNIT_TESTS "Include unit tests (and the Google Test framework) in the generated build?" Yes)
option (ICUBABY_WERROR "Compiler warnings are errors" No)
set (icubaby_project_root "${CMAKE_CURRENT_SOURCE_DIR}")
list (APPEND CMAKE_MODULE_PATH "${icubaby_project_root}/cmake")
include (setup_target)
include (setup_gtest)
if (ICUBABY_FUZZTEST)
set (FUZZTEST_FUZZING_MODE On)
include (FetchContent)
set (FUZZTEST_REPO_BRANCH "1635d42" CACHE STRING "FuzzTest repository branch.")
message ("Building fuzztest at tag " ${FUZZTEST_REPO_BRANCH})
FetchContent_Declare (
fuzztest
GIT_REPOSITORY https://github.com/google/fuzztest.git
GIT_TAG ${FUZZTEST_REPO_BRANCH}
)
FetchContent_MakeAvailable (fuzztest)
include (GoogleTest)
fuzztest_setup_fuzzing_flags ()
else ()
if (ICUBABY_UNIT_TESTS)
setup_gtest ()
endif (ICUBABY_UNIT_TESTS)
endif (ICUBABY_FUZZTEST)
enable_testing ()
# A custom target from which the install will hang
add_custom_target (
install-icubaby
COMMAND "${CMAKE_COMMAND}" -D CMAKE_INSTALL_COMPONENT=icubaby -P
"${CMAKE_BINARY_DIR}/cmake_install.cmake"
USES_TERMINAL
)
# icubaby target
set (icubaby_include_dir "${icubaby_project_root}/include")
set (icubaby_headers "${icubaby_include_dir}/icubaby/icubaby.hpp")
add_library (icubaby INTERFACE "${icubaby_headers}")
target_include_directories (icubaby SYSTEM INTERFACE
"$<BUILD_INTERFACE:${icubaby_include_dir}>"
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>"
)
set_target_properties (icubaby PROPERTIES PUBLIC_HEADER "${icubaby_headers}")
include (GNUInstallDirs)
install (
TARGETS icubaby
EXPORT icubaby
PUBLIC_HEADER
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/icubaby"
COMPONENT icubaby
LIBRARY COMPONENT icubaby
ARCHIVE COMPONENT icubaby
INCLUDES
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)
add_dependencies (install-icubaby icubaby)
# examples
if (ICUBABY_EXAMPLES)
add_subdirectory (examples)
endif (ICUBABY_EXAMPLES)
# tests
if (ICUBABY_STANDALONE)
add_subdirectory (tests)
endif (ICUBABY_STANDALONE)
if (ICUBABY_UNIT_TESTS AND TARGET gtest)
add_subdirectory (unittests)
endif ()
install (
EXPORT icubaby
DESTINATION "${CMAKE_INSTALL_LIBDIR}/icubaby"
NAMESPACE icubaby::
)
include (InstallRequiredSystemLibraries)
set (CPACK_PACKAGE_VENDOR "Paul Bowen-Huggett")
set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
include (CPack)