-
-
Notifications
You must be signed in to change notification settings - Fork 86
/
CMakeLists.txt
181 lines (153 loc) · 4.71 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
cmake_minimum_required(VERSION 3.16)
project(ada
DESCRIPTION "Fast spec-compliant URL parser"
LANGUAGES C CXX
VERSION 2.9.2
)
set(ADA_LIB_VERSION "2.9.2" CACHE STRING "ada library version")
set(ADA_LIB_SOVERSION "2" CACHE STRING "ada library soversion")
include(GNUInstallDirs)
include(CTest)
include(cmake/ada-flags.cmake)
set(ADA_SOURCE_DIR src)
add_subdirectory(src)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake)
option(ADA_BENCHMARKS "Build benchmarks" OFF)
option(ADA_TESTING "Build tests" OFF)
# There are cases where when embedding ada as a dependency for other CMake
# projects as submodules or subdirectories (via FetchContent) can lead to
# errors due to CPM, so this is here to support disabling all the testing
# and tooling for ada if one only wishes to use the ada library.
if(ADA_TESTING OR ADA_BENCHMARKS OR ADA_TOOLS)
include(cmake/CPM.cmake)
# CPM requires git as an implicit dependency
find_package(Git QUIET)
# We use googletest in the tests
if(Git_FOUND AND ADA_TESTING)
CPMAddPackage(
NAME GTest
GITHUB_REPOSITORY google/googletest
VERSION 1.15.2
OPTIONS "BUILD_GMOCK OFF" "INSTALL_GTEST OFF"
)
endif()
# We use simdjson in both the benchmarks and tests
if(Git_FOUND AND (ADA_TESTING OR ADA_BENCHMARKS))
CPMAddPackage("gh:simdjson/simdjson@3.10.1")
endif()
# We use Google Benchmark, but it does not build under several 32-bit systems.
if(Git_FOUND AND ADA_BENCHMARKS AND (CMAKE_SIZEOF_VOID_P EQUAL 8))
CPMAddPackage(
NAME benchmark
GITHUB_REPOSITORY google/benchmark
VERSION 1.9.0
OPTIONS "BENCHMARK_ENABLE_TESTING OFF"
"BENCHMARK_ENABLE_INSTALL OFF"
"BENCHMARK_ENABLE_WERROR OFF"
)
endif()
if (ADA_TESTING AND NOT EMSCRIPTEN)
if(Git_FOUND)
set(CTEST_TEST_TIMEOUT 5)
message(STATUS "The tests are enabled.")
add_subdirectory(tests)
else()
message(STATUS "The tests are disabled because git was not found.")
endif()
else()
if(is_top_project)
message(STATUS "The tests are disabled.")
endif()
endif(ADA_TESTING AND NOT EMSCRIPTEN)
If(ADA_BENCHMARKS AND NOT EMSCRIPTEN)
if(Git_FOUND)
message(STATUS "Ada benchmarks enabled.")
add_subdirectory(benchmarks)
else()
message(STATUS "The benchmarks are disabled because git was not found.")
endif()
else(ADA_BENCHMARKS AND NOT EMSCRIPTEN)
if(is_top_project)
message(STATUS "Ada benchmarks disabled. Set ADA_BENCHMARKS=ON to enable them.")
endif()
endif(ADA_BENCHMARKS AND NOT EMSCRIPTEN)
if (ADA_TESTING AND EMSCRIPTEN)
add_subdirectory(tests/wasm)
endif(ADA_TESTING AND EMSCRIPTEN)
endif()
add_library(ada::ada ALIAS ada)
set_target_properties(
ada PROPERTIES
VERSION "${ADA_LIB_VERSION}"
SOVERSION "${ADA_LIB_SOVERSION}"
WINDOWS_EXPORT_ALL_SYMBOLS YES
)
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
if(NOT ADA_COVERAGE AND NOT EMSCRIPTEN)
add_subdirectory(singleheader)
endif()
if(ADA_TOOLS)
if(Git_FOUND)
add_subdirectory(tools)
else()
message(STATUS "The tools are disabled because git was not found.")
endif()
endif()
install(
FILES include/ada.h include/ada_c.h
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
COMPONENT ada_development
)
install(
DIRECTORY include/ada
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
COMPONENT ada_development
)
install(
TARGETS ada
EXPORT ada_targets
RUNTIME COMPONENT ada_runtime
LIBRARY COMPONENT ada_runtime
NAMELINK_COMPONENT ada_development
ARCHIVE COMPONENT ada_development
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)
configure_file(cmake/ada-config.cmake.in ada-config.cmake @ONLY)
write_basic_package_version_file(
ada-config-version.cmake
COMPATIBILITY SameMinorVersion
)
set(
ADA_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/ada"
CACHE STRING "CMake package config location relative to the install prefix"
)
mark_as_advanced(ADA_INSTALL_CMAKEDIR)
install(
FILES
"${PROJECT_BINARY_DIR}/ada-config.cmake"
"${PROJECT_BINARY_DIR}/ada-config-version.cmake"
DESTINATION "${ADA_INSTALL_CMAKEDIR}"
COMPONENT ada_development
)
install(
EXPORT ada_targets
NAMESPACE ada::
DESTINATION "${ADA_INSTALL_CMAKEDIR}"
COMPONENT ada_development
)
install(
EXPORT ada_targets
NAMESPACE ada::
DESTINATION "${ADA_INSTALL_CMAKEDIR}"
COMPONENT example_development
)
if(is_top_project)
set(CPACK_PACKAGE_VENDOR "Ada Authors")
set(CPACK_PACKAGE_CONTACT "yagiz@nizipli.com")
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE-MIT")
set(CPACK_RPM_PACKAGE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE-MIT")
set(CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/README.md")
set(CPACK_SOURCE_GENERATOR "TGZ;ZIP")
include(CPack)
endif()