-
Notifications
You must be signed in to change notification settings - Fork 40
/
CMakeLists.txt
140 lines (121 loc) · 4.08 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
# -*- mode: CMAKE; -*-
cmake_minimum_required(VERSION 3.9)
project(velocypack CXX C)
set(CMAKE_CXX_STANDARD 20 CACHE STRING "target C++ standard")
message(STATUS "Require C++${CMAKE_CXX_STANDARD}")
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(UseIPO "AUTO" CACHE STRING "Use interprocedural optimization: ON, OFF or AUTO")
set_property(CACHE UseIPO PROPERTY STRINGS AUTO ON OFF)
# Determine value if IPO_ENABLED from USE_IPO and CMAKE_BUILD_TYPE
set(IPO_ENABLED False)
if (UseIPO STREQUAL "AUTO")
if (CMAKE_BUILD_TYPE STREQUAL "Release"
OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo"
OR CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
set(IPO_ENABLED True)
else()
set(IPO_ENABLED False)
endif ()
elseif (UseIPO)
set(IPO_ENABLED True)
else()
set(IPO_ENABLED False)
endif()
if (IPO_ENABLED)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION True)
endif()
option(Maintainer "Build maintainer tools" OFF)
option(BuildSseOpt "Build with SSE optimization instructions" ON)
set(HashType "xxhash" CACHE STRING "Hash type (fasthash, xxhash)" )
# Set Build Type
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif()
message(STATUS "VelocyPack build mode: ${CMAKE_BUILD_TYPE}")
message(STATUS "VelocyPack interprocedural optimizations: ${IPO_ENABLED}")
message(STATUS "VelocyPack install base directory: ${CMAKE_INSTALL_PREFIX}")
set(VELOCYPACK_VERSION "0.1.33" CACHE STRING "VelocyPack version")
set(VELOCYPACK_DISPLAY_NAME "Velocypack")
set(VELOCYPACK_URL_INFO_ABOUT "https://github.com/arangodb/velocypack")
set(VELOCYPACK_CONTACT "[email protected]")
set(VELOCYPACK_FRIENDLY_STRING "VelocyPack - A fast & compact serialization format")
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
#Compiler Setting
include(AR_CompilerSettings)
if(NOT BuildSseOpt OR NOT CAN_USE_SSE)
add_definitions("-DVELOCYPACK_ASM_OPTIMIZATIONS=0")
else()
if(ADD_SSE_FLAG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.2")
elseif(IS_ARM)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__ARM_NEON")
endif()
add_definitions("-DVELOCYPACK_ASM_OPTIMIZATIONS=1")
endif()
add_library(velocypack STATIC
src/velocypack-common.cpp
src/AttributeTranslator.cpp
src/Builder.cpp
src/Collection.cpp
src/Compare.cpp
src/Dumper.cpp
src/Exception.cpp
src/HashedStringRef.cpp
src/HexDump.cpp
src/Iterator.cpp
src/Options.cpp
src/Parser.cpp
src/Serializable.cpp
src/SharedSlice.cpp
src/Slice.cpp
src/Utf8Helper.cpp
src/Validator.cpp
src/Value.cpp
src/ValueType.cpp
src/Version.cpp
src/asm-functions.cpp
src/asm-utf8check.cpp
src/fpconv.cpp
src/string-functions.cpp
src/String.cpp)
#Use xxhash, fasthash?
if(HashType STREQUAL "xxhash")
target_sources(velocypack PRIVATE src/xxhash.c)
target_compile_definitions(velocypack PRIVATE "-DXXH_NAMESPACE=VELOCYPACK_")
add_definitions("-DVELOCYPACK_XXHASH=1")
elseif(HashType STREQUAL "fasthash")
target_sources(velocypack PRIVATE src/fasthash.cpp)
add_definitions("-DVELOCYPACK_FASTHASH=1")
else()
message(FATAL_ERROR "VelocyPack invalid HashType value. supported values: xxhash, fasthash")
endif()
message(STATUS "VelocyPack Building with hash type: ${HashType}")
target_include_directories(
velocypack
PRIVATE ${PROJECT_SOURCE_DIR}/src
PUBLIC ${PROJECT_SOURCE_DIR}/include
)
if(IS_ARM)
target_include_directories(velocypack PRIVATE ${PROJECT_SOURCE_DIR}/external/sse2neon)
endif()
if(Maintainer)
add_executable(buildVersion scripts/build-version.cpp)
add_custom_target(buildVersionNumber
COMMAND ${PROJECT_BINARY_DIR}/scripts/buildVersion
${PROJECT_SOURCE_DIR}/include/velocypack/velocypack-version-number.h
DEPENDS ${PROJECT_BINARY_DIR}/scripts/buildVersion
VERBATIM
)
endif()
add_subdirectory(tools)
add_subdirectory(examples)
add_subdirectory(tests)
install(TARGETS velocypack DESTINATION lib)
install(
DIRECTORY "include/velocypack"
DESTINATION include
)
include(CPack)