-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
89 lines (75 loc) · 2.3 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
cmake_minimum_required(VERSION 3.14...3.22)
# ---- Project ----
# Note: update this to your new project's name and version
project(
simdjson_use_release
VERSION ${simdjson_VERSION}
LANGUAGES CXX)
option(BUILD_SHARED_LIBS "yes/no" NO)
if(${BUILD_SHARED_LIBS})
# https://stackoverflow.com/questions/33062728/cmake-link-shared-library-on-windows
if(WIN32)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
endif()
endif()
set(FETCHCONTENT_QUIET
OFF
CACHE BOOL "Make downloading of packages quiet")
# ---- Include guards ----
if(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
message(
FATAL_ERROR
"In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there."
)
endif()
include(getCPM.cmake)
set(packageProject_VERSION 1.12.0)
cpmaddpackage(
NAME
PackageProject.cmake
VERSION
${packageProject_VERSION}
URL
"https://github.com/TheLartians/PackageProject.cmake/archive/refs/tags/v${packageProject_VERSION}.zip"
)
file(
DOWNLOAD
https://github.com/simdjson/simdjson/releases/download/v${simdjson_VERSION}/simdjson.cpp
${CMAKE_CURRENT_LIST_DIR}/simdjson/simdjson.cpp)
file(
DOWNLOAD
https://github.com/simdjson/simdjson/releases/download/v${simdjson_VERSION}/simdjson.h
${CMAKE_CURRENT_LIST_DIR}/simdjson/include/simdjson.h)
add_library(simdjson ${CMAKE_CURRENT_LIST_DIR}/simdjson/simdjson.cpp)
target_include_directories(
simdjson
PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/simdjson/include>
$<INSTALL_INTERFACE:include/simdjson>)
# the location where the project's version header will be placed should match
# the project's regular header paths
string(TOLOWER simdjson/version.h
simdjson_VERSION_HEADER_LOCATION)
string(TOLOWER simdjson/export.h simdjson_EXPORT_HEADER_LOCATION)
set_property(TARGET simdjson PROPERTY VERSION ${simdjson_VERSION})
set_property(TARGET simdjson PROPERTY SOVERSION ${simdjson_VERSION})
packageproject(
NAME
simdjson
VERSION
${simdjson_VERSION}
NAMESPACE
simdjson
BINARY_DIR
${PROJECT_BINARY_DIR}
INCLUDE_DIR
${PROJECT_SOURCE_DIR}/simdjson/include
INCLUDE_DESTINATION
include
VERSION_HEADER
"${simdjson_VERSION_HEADER_LOCATION}"
EXPORT_HEADER
"${simdjson_EXPORT_HEADER_LOCATION}"
COMPATIBILITY
"AnyNewerVersion"
DISABLE_VERSION_SUFFIX
ON)