forked from arangodb/velocypack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
121 lines (104 loc) · 3.61 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
# -*- mode: CMAKE; -*-
cmake_minimum_required(VERSION 3.9)
project(velocypack CXX C)
set(CMAKE_CXX_STANDARD 17 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(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(BuildVelocyPackExamples "Build examples" ON)
option(Maintainer "Build maintainer tools" OFF)
set(HashType "xxhash" CACHE STRING "Hash type (fasthash, xxhash, wyhash)" )
# 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 "hackers@arangodb.org")
set(VELOCYPACK_FRIENDLY_STRING "VelocyPack - A fast & compact serialization format")
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
#Compiler Setting
include(AR_CompilerSettings)
set(VELOCY_SOURCE
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
)
#Use xxhash, fasthash?
if(HashType STREQUAL "xxhash")
list(APPEND VELOCY_SOURCE src/xxhash.cpp)
add_definitions("-DVELOCYPACK_XXHASH=1")
elseif(HashType STREQUAL "fasthash")
list(APPEND VELOCY_SOURCE 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}")
add_library(velocypack STATIC ${VELOCY_SOURCE})
target_include_directories(velocypack PRIVATE src)
target_include_directories(velocypack PUBLIC include)
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)