forked from intel/ScalableVectorSearch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
159 lines (129 loc) · 3.96 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
cmake_minimum_required(VERSION 3.21)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}/cmake")
project(svs
LANGUAGES CXX
# The version is tested in the files:
# - /tests/svs/lib/version.cpp
# - /bindings/python/tests/test_common.py
# Manually keep in-sync with:
# - /bindings/python/setup.py
VERSION 0.0.3
)
set(SVS_LIB svs_devel)
# Version variables.
set(SVS_VERSION ${PROJECT_VERSION})
set(SVS_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(SVS_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(SVS_VERSION_PATCH ${PROJECT_VERSION_PATCH})
add_library(${SVS_LIB} INTERFACE)
set_target_properties(${SVS_LIB} PROPERTIES EXPORT_NAME svs)
add_library(svs::svs ALIAS ${SVS_LIB})
# Runtime include directories are established in the installation logic.
target_include_directories(
${SVS_LIB}
INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
)
# We use C++ 20 features in our exposed headers.
# Anyone using us as a depdency and including our headers will need to be C++20 compatible.
target_compile_features(${SVS_LIB} INTERFACE cxx_std_20)
# Populate with the version number macro.
target_compile_options(
${SVS_LIB}
INTERFACE
"-DSVS_VERSION_MAJOR=${SVS_VERSION_MAJOR}"
"-DSVS_VERSION_MINOR=${SVS_VERSION_MINOR}"
"-DSVS_VERSION_PATCH=${SVS_VERSION_PATCH}"
)
#####
##### Options and extra build steps
#####
include("cmake/options.cmake")
include("cmake/clang-tidy.cmake")
include("cmake/eve.cmake")
include("cmake/pthread.cmake")
include("cmake/numa.cmake")
include("cmake/robin-map.cmake")
include("cmake/fmt.cmake")
include("cmake/toml.cmake")
# LeanVec requires MKL support
if(SVS_EXPERIMENTAL_LEANVEC)
include("cmake/mkl.cmake")
target_compile_options(${SVS_LIB} INTERFACE "-DSVS_HAVE_MKL=1")
else()
target_compile_options(${SVS_LIB} INTERFACE "-DSVS_HAVE_MKL=0")
endif()
#####
##### Build Objects
#####
if(SVS_BUILD_BINARIES)
add_subdirectory(utils)
endif()
if(SVS_BUILD_TESTS)
add_subdirectory(tests)
endif()
if(SVS_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
if(SVS_BUILD_DOCS)
add_subdirectory(docs)
endif()
# The benchmark directory contains a sub-component that is used by both the benchmarking
# framework and the unit-tests.
#
# If only the unit tests are enabled, then the benchmark will be built as a minimal
# component to avoid excessive compilation time.
if(SVS_BUILD_BENCHMARK OR SVS_BUILD_TESTS OR SVS_BUILD_BENCHMARK_TEST_GENERATORS)
add_subdirectory(benchmark)
endif()
#####
##### Install Logic
#####
include(GNUInstallDirs)
# Location of auxiliary generated cmake files to help consumers of this package.
set(LIB_CONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/svs")
# Install headers and target information.
install(
TARGETS svs_devel svs_compile_options svs_native_options
EXPORT svs-targets
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
install(
DIRECTORY "${PROJECT_SOURCE_DIR}/include/svs"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
FILES_MATCHING PATTERN "*.h"
)
install(
EXPORT svs-targets
NAMESPACE "svs::"
DESTINATION "${LIB_CONFIG_INSTALL_DIR}"
)
#####
##### Config File
#####
set(VERSION_CONFIG "${CMAKE_CURRENT_BINARY_DIR}/svsConfigVersion.cmake")
include(CMakePackageConfigHelpers)
configure_package_config_file(
"${CMAKE_CURRENT_LIST_DIR}/cmake/Config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/svsConfig.cmake"
INSTALL_DESTINATION "${LIB_CONFIG_INSTALL_DIR}"
)
# Don't make compatibility guarentees until we reach a compatibility milestone.
write_basic_package_version_file(
${VERSION_CONFIG}
VERSION ${SVS_VERSION}
COMPATIBILITY ExactVersion
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/svsConfig.cmake"
"${VERSION_CONFIG}"
DESTINATION "${LIB_CONFIG_INSTALL_DIR}"
)
# Copy any "Find*" files that may be needed.
set(CMAKE_DIR "${CMAKE_CURRENT_LIST_DIR}/cmake")
set(SVS_CMAKE_FIND_FILES
${CMAKE_DIR}/FindNuma.cmake
)
install(FILES
${SVS_CMAKE_FIND_FILES}
DESTINATION "${LIB_CONFIG_INSTALL_DIR}"
)