-
Notifications
You must be signed in to change notification settings - Fork 225
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
109 lines (86 loc) · 3.31 KB
/
CMakeLists.txt
File metadata and controls
109 lines (86 loc) · 3.31 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
cmake_minimum_required(VERSION 3.21)
include(cmake/prelude.cmake)
project(
glaze
VERSION 7.2.2
LANGUAGES CXX
)
include(cmake/project-is-top-level.cmake)
include(cmake/variables.cmake)
if (PROJECT_IS_TOP_LEVEL)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
endif()
add_library(glaze_glaze INTERFACE)
add_library(glaze::glaze ALIAS glaze_glaze)
if (MSVC)
string(REGEX MATCH "\/cl(.exe)?$" matched_cl ${CMAKE_CXX_COMPILER})
if (matched_cl)
# for a C++ standards compliant preprocessor, not needed for clang-cl
target_compile_options(glaze_glaze INTERFACE "/Zc:preprocessor" /permissive- /Zc:lambda)
if(PROJECT_IS_TOP_LEVEL)
target_compile_options(glaze_glaze INTERFACE
$<$<CONFIG:Release>:/GL>
$<$<CONFIG:MinSizeRel>:/GL>)
target_link_options(glaze_glaze INTERFACE
$<$<CONFIG:Release>:/LTCG /INCREMENTAL:NO>
$<$<CONFIG:MinSizeRel>:/LTCG /INCREMENTAL:NO>)
endif()
endif()
else()
# Only apply -Wno-missing-braces for C and C++ compilation to avoid breaking ISPC and other language builds
target_compile_options(${PROJECT_NAME}_${PROJECT_NAME} INTERFACE
$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Wno-missing-braces>)
endif()
set_property(TARGET ${PROJECT_NAME}_${PROJECT_NAME} PROPERTY EXPORT_NAME glaze)
target_compile_features(${PROJECT_NAME}_${PROJECT_NAME} INTERFACE cxx_std_23)
target_include_directories(
${PROJECT_NAME}_${PROJECT_NAME} ${warning_guard}
INTERFACE "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
)
if(NOT CMAKE_SKIP_INSTALL_RULES)
include(cmake/install-rules.cmake)
endif()
if (glaze_DEVELOPER_MODE)
include(cmake/dev-mode.cmake)
endif()
option(glaze_DISABLE_SIMD_WHEN_SUPPORTED
"disable SIMD optimizations even when targets support it (e.g. AVX2)" OFF)
if(glaze_DISABLE_SIMD_WHEN_SUPPORTED)
target_compile_definitions(glaze_glaze INTERFACE GLZ_DISABLE_SIMD)
endif()
option(glaze_DISABLE_ALWAYS_INLINE
"disable forced inlining to reduce binary size and compilation time" OFF)
if(glaze_DISABLE_ALWAYS_INLINE)
target_compile_definitions(glaze_glaze INTERFACE GLZ_DISABLE_ALWAYS_INLINE)
endif()
option(glaze_BUILD_EXAMPLES "Build GLAZE examples" OFF)
if(glaze_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
option(glaze_EETF_FORMAT "Enable Erlang external term format parsing" OFF)
if(glaze_EETF_FORMAT)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
find_package(Erlang REQUIRED)
target_link_libraries(
glaze_glaze ${warning_guard}
INTERFACE
Erlang::EI
Erlang::Erlang
)
target_compile_definitions(glaze_glaze INTERFACE GLZ_ENABLE_EETF)
endif(glaze_EETF_FORMAT)
option(glaze_ENABLE_SSL "Enable SSL/TLS support for HTTPS servers" OFF)
if(glaze_ENABLE_SSL)
find_package(OpenSSL REQUIRED)
target_link_libraries(
glaze_glaze ${warning_guard}
INTERFACE
OpenSSL::SSL
OpenSSL::Crypto
)
target_compile_definitions(glaze_glaze INTERFACE GLZ_ENABLE_SSL)
endif(glaze_ENABLE_SSL)
option(glaze_ENABLE_REFLECTION26 "Enable C++26 P2996 reflection (requires Bloomberg clang-p2996 or compatible compiler)" OFF)
if(glaze_ENABLE_REFLECTION26)
target_compile_definitions(glaze_glaze INTERFACE GLZ_REFLECTION26=1)
endif(glaze_ENABLE_REFLECTION26)