-
Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
164 lines (140 loc) · 6.36 KB
/
Copy pathCMakeLists.txt
File metadata and controls
164 lines (140 loc) · 6.36 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
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
cmake_minimum_required(VERSION 3.10)
project(SIMDCompressionAndIntersection
VERSION 0.2.0
LANGUAGES C CXX)
# ---------------------------------------------------------------------------
# Standards
# ---------------------------------------------------------------------------
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
endif()
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# Is this the top-level project, or are we being added via add_subdirectory()?
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
set(SIMDCOMP_IS_TOP_LEVEL ON)
else()
set(SIMDCOMP_IS_TOP_LEVEL OFF)
endif()
option(SIMDCOMP_BUILD_TESTS
"Build the test, benchmark and example executables" ${SIMDCOMP_IS_TOP_LEVEL})
option(SIMDCOMP_INSTALL
"Generate install rules for SIMDCompressionAndIntersection" ${SIMDCOMP_IS_TOP_LEVEL})
# Defines CMAKE_INSTALL_{LIB,INCLUDE,BIN}DIR; needed before they are referenced
# in the library's INSTALL_INTERFACE include directories below.
include(GNUInstallDirs)
# Release builds define NDEBUG (disabling assertions), which is the CMake
# default for the Release / RelWithDebInfo / MinSizeRel configurations.
# ---------------------------------------------------------------------------
# SIMD flags
#
# On x86/x64 the code is built for AVX (AVX itself is not required at runtime,
# but the default build assumes it, matching the Makefile). On AArch64 the SSE
# intrinsics are mapped to ARM NEON via include/neon_sse.h, and NEON is baseline
# so no architecture flag is needed.
# ---------------------------------------------------------------------------
set(SIMD_FLAGS "")
if(NOT MSVC)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "(^|;)(x86_64|amd64|AMD64|i.86|x86)$")
set(SIMD_FLAGS -mavx)
endif()
endif()
if(NOT MSVC)
add_compile_options(
${SIMD_FLAGS}
-Wall -Wextra -Wsign-compare -Wwrite-strings -Wpointer-arith
-Winit-self -Wno-sign-conversion)
# -Weffc++ and -pedantic only on the C++ sources (matches the Makefile).
add_compile_options(
$<$<COMPILE_LANGUAGE:CXX>:-Weffc++>
$<$<COMPILE_LANGUAGE:CXX>:-pedantic>
$<$<COMPILE_LANGUAGE:C>:-pedantic>)
else()
add_compile_options(/arch:AVX)
endif()
# ---------------------------------------------------------------------------
# Library
# ---------------------------------------------------------------------------
set(SIMDCOMP_SOURCES
src/codecfactory.cpp
src/bitpacking.cpp
src/integratedbitpacking.cpp
src/simdbitpacking.cpp
src/usimdbitpacking.cpp
src/simdintegratedbitpacking.cpp
src/intersection.cpp
src/varintdecode.c
src/streamvbyte.c
src/simdpackedsearch.c
src/simdpackedselect.c
src/frameofreference.cpp
src/for.c)
add_library(SIMDCompressionAndIntersection STATIC ${SIMDCOMP_SOURCES})
# Same-name namespaced alias so consumers can use the identical target name
# whether they add_subdirectory() this project or find_package() an install.
add_library(SIMDCompressionAndIntersection::SIMDCompressionAndIntersection
ALIAS SIMDCompressionAndIntersection)
target_include_directories(SIMDCompressionAndIntersection PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/SIMDCompressionAndIntersection>)
# ---------------------------------------------------------------------------
# Test / benchmark / example executables (optional)
# ---------------------------------------------------------------------------
if(SIMDCOMP_BUILD_TESTS)
foreach(prog unit testcodecs testintegration benchintersection benchsearch)
add_executable(${prog} src/${prog}.cpp)
target_link_libraries(${prog} PRIVATE SIMDCompressionAndIntersection)
endforeach()
add_executable(example example.cpp)
target_link_libraries(example PRIVATE SIMDCompressionAndIntersection)
# Advanced benchmarking tools
foreach(prog simplesynth compress uncompress budgetedtest ramtocache entropy compflatstat)
add_executable(${prog} advancedbenchmarking/src/${prog}.cpp)
target_link_libraries(${prog} PRIVATE SIMDCompressionAndIntersection)
target_include_directories(${prog} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/advancedbenchmarking/include)
endforeach()
enable_testing()
add_test(NAME unit COMMAND unit)
add_test(NAME testintegration COMMAND testintegration)
endif()
# ---------------------------------------------------------------------------
# Installation
# ---------------------------------------------------------------------------
if(SIMDCOMP_INSTALL)
include(CMakePackageConfigHelpers)
set(SIMDCOMP_INSTALL_CMAKEDIR
"${CMAKE_INSTALL_LIBDIR}/cmake/SIMDCompressionAndIntersection"
CACHE STRING "Path (relative to prefix) to install the CMake package config")
# Library + export set.
install(TARGETS SIMDCompressionAndIntersection
EXPORT SIMDCompressionAndIntersectionTargets
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
# Public headers (flat layout, matching the in-tree include/ directory).
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/SIMDCompressionAndIntersection"
FILES_MATCHING PATTERN "*.h")
# Exported targets file -> SIMDCompressionAndIntersection::SIMDCompressionAndIntersection
install(EXPORT SIMDCompressionAndIntersectionTargets
FILE SIMDCompressionAndIntersectionTargets.cmake
NAMESPACE SIMDCompressionAndIntersection::
DESTINATION "${SIMDCOMP_INSTALL_CMAKEDIR}")
# Package config + version files, so find_package() works.
configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/SIMDCompressionAndIntersectionConfig.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/SIMDCompressionAndIntersectionConfig.cmake"
INSTALL_DESTINATION "${SIMDCOMP_INSTALL_CMAKEDIR}")
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/SIMDCompressionAndIntersectionConfigVersion.cmake"
VERSION "${PROJECT_VERSION}"
COMPATIBILITY SameMajorVersion)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/SIMDCompressionAndIntersectionConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/SIMDCompressionAndIntersectionConfigVersion.cmake"
DESTINATION "${SIMDCOMP_INSTALL_CMAKEDIR}")
endif()