| a0630906 |
Poul Sander |
2022-01-15 13:59 |
1 |
cmake_minimum_required(VERSION 3.1...3.18) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
2 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
3 |
# Fallback for using newer policies on CMake <3.12. |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
4 |
if(${CMAKE_VERSION} VERSION_LESS 3.12) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
5 |
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
6 |
endif() |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
7 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
8 |
# Determine if fmt is built as a subproject (using add_subdirectory) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
9 |
# or if it is the master project. |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
10 |
if (NOT DEFINED FMT_MASTER_PROJECT) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
11 |
set(FMT_MASTER_PROJECT OFF) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
12 |
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
13 |
set(FMT_MASTER_PROJECT ON) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
14 |
message(STATUS "CMake version: ${CMAKE_VERSION}") |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
15 |
endif () |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
16 |
endif () |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
17 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
18 |
# Joins arguments and places the results in ${result_var}. |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
19 |
function(join result_var) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
20 |
set(result "") |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
21 |
foreach (arg ${ARGN}) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
22 |
set(result "${result}${arg}") |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
23 |
endforeach () |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
24 |
set(${result_var} "${result}" PARENT_SCOPE) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
25 |
endfunction() |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
26 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
27 |
function(enable_module target) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
28 |
if (MSVC) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
29 |
set(BMI ${CMAKE_CURRENT_BINARY_DIR}/${target}.ifc) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
30 |
target_compile_options(${target} |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
31 |
PRIVATE /interface /ifcOutput ${BMI} |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
32 |
INTERFACE /reference fmt=${BMI}) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
33 |
endif () |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
34 |
set_target_properties(${target} PROPERTIES ADDITIONAL_CLEAN_FILES ${BMI}) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
35 |
set_source_files_properties(${BMI} PROPERTIES GENERATED ON) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
36 |
endfunction() |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
37 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
38 |
include(CMakeParseArguments) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
39 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
40 |
# Sets a cache variable with a docstring joined from multiple arguments: |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
41 |
# set(<variable> <value>... CACHE <type> <docstring>...) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
42 |
# This allows splitting a long docstring for readability. |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
43 |
function(set_verbose) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
44 |
# cmake_parse_arguments is broken in CMake 3.4 (cannot parse CACHE) so use |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
45 |
# list instead. |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
46 |
list(GET ARGN 0 var) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
47 |
list(REMOVE_AT ARGN 0) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
48 |
list(GET ARGN 0 val) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
49 |
list(REMOVE_AT ARGN 0) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
50 |
list(REMOVE_AT ARGN 0) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
51 |
list(GET ARGN 0 type) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
52 |
list(REMOVE_AT ARGN 0) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
53 |
join(doc ${ARGN}) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
54 |
set(${var} ${val} CACHE ${type} ${doc}) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
55 |
endfunction() |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
56 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
57 |
# Set the default CMAKE_BUILD_TYPE to Release. |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
58 |
# This should be done before the project command since the latter can set |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
59 |
# CMAKE_BUILD_TYPE itself (it does so for nmake). |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
60 |
if (FMT_MASTER_PROJECT AND NOT CMAKE_BUILD_TYPE) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
61 |
set_verbose(CMAKE_BUILD_TYPE Release CACHE STRING |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
62 |
"Choose the type of build, options are: None(CMAKE_CXX_FLAGS or " |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
63 |
"CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.") |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
64 |
endif () |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
65 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
66 |
project(FMT CXX) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
67 |
include(GNUInstallDirs) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
68 |
set_verbose(FMT_INC_DIR ${CMAKE_INSTALL_INCLUDEDIR} CACHE STRING |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
69 |
"Installation directory for include files, a relative path that " |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
70 |
"will be joined with ${CMAKE_INSTALL_PREFIX} or an absolute path.") |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
71 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
72 |
option(FMT_PEDANTIC "Enable extra warnings and expensive tests." OFF) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
73 |
option(FMT_WERROR "Halt the compilation with an error on compiler warnings." |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
74 |
OFF) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
75 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
76 |
# Options that control generation of various targets. |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
77 |
option(FMT_DOC "Generate the doc target." ${FMT_MASTER_PROJECT}) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
78 |
option(FMT_INSTALL "Generate the install target." ${FMT_MASTER_PROJECT}) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
79 |
option(FMT_TEST "Generate the test target." ${FMT_MASTER_PROJECT}) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
80 |
option(FMT_FUZZ "Generate the fuzz target." OFF) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
81 |
option(FMT_CUDA_TEST "Generate the cuda-test target." OFF) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
82 |
option(FMT_OS "Include core requiring OS (Windows/Posix) " ON) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
83 |
option(FMT_MODULE "Build a module instead of a traditional library." OFF) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
84 |
option(FMT_SYSTEM_HEADERS "Expose headers with marking them as system." OFF) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
85 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
86 |
set(FMT_CAN_MODULE OFF) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
87 |
if (CMAKE_CXX_STANDARD GREATER 17 AND |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
88 |
# msvc 16.10-pre4 |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
89 |
MSVC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 19.29.30035) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
90 |
set(FMT_CAN_MODULE OFF) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
91 |
endif () |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
92 |
if (NOT FMT_CAN_MODULE) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
93 |
set(FMT_MODULE OFF) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
94 |
message(STATUS "Module support is disabled.") |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
95 |
endif () |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
96 |
if (FMT_TEST AND FMT_MODULE) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
97 |
# The tests require {fmt} to be compiled as traditional library |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
98 |
message(STATUS "Testing is incompatible with build mode 'module'.") |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
99 |
endif () |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
100 |
set(FMT_SYSTEM_HEADERS_ATTRIBUTE "") |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
101 |
if (FMT_SYSTEM_HEADERS) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
102 |
set(FMT_SYSTEM_HEADERS_ATTRIBUTE SYSTEM) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
103 |
endif () |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
104 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
105 |
# Get version from core.h |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
106 |
file(READ include/fmt/core.h core_h) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
107 |
if (NOT core_h MATCHES "FMT_VERSION ([0-9]+)([0-9][0-9])([0-9][0-9])") |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
108 |
message(FATAL_ERROR "Cannot get FMT_VERSION from core.h.") |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
109 |
endif () |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
110 |
# Use math to skip leading zeros if any. |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
111 |
math(EXPR CPACK_PACKAGE_VERSION_MAJOR ${CMAKE_MATCH_1}) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
112 |
math(EXPR CPACK_PACKAGE_VERSION_MINOR ${CMAKE_MATCH_2}) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
113 |
math(EXPR CPACK_PACKAGE_VERSION_PATCH ${CMAKE_MATCH_3}) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
114 |
join(FMT_VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}. |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
115 |
${CPACK_PACKAGE_VERSION_PATCH}) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
116 |
message(STATUS "Version: ${FMT_VERSION}") |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
117 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
118 |
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}") |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
119 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
120 |
if (NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
121 |
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
122 |
endif () |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
123 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
124 |
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
125 |
"${CMAKE_CURRENT_SOURCE_DIR}/support/cmake") |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
126 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
127 |
include(cxx14) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
128 |
include(CheckCXXCompilerFlag) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
129 |
include(JoinPaths) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
130 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
131 |
list(FIND CMAKE_CXX_COMPILE_FEATURES "cxx_variadic_templates" index) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
132 |
if (${index} GREATER -1) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
133 |
# Use cxx_variadic_templates instead of more appropriate cxx_std_11 for |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
134 |
# compatibility with older CMake versions. |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
135 |
set(FMT_REQUIRED_FEATURES cxx_variadic_templates) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
136 |
endif () |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
137 |
message(STATUS "Required features: ${FMT_REQUIRED_FEATURES}") |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
138 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
139 |
if (FMT_MASTER_PROJECT AND NOT DEFINED CMAKE_CXX_VISIBILITY_PRESET) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
140 |
set_verbose(CMAKE_CXX_VISIBILITY_PRESET hidden CACHE STRING |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
141 |
"Preset for the export of private symbols") |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
142 |
set_property(CACHE CMAKE_CXX_VISIBILITY_PRESET PROPERTY STRINGS |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
143 |
hidden default) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
144 |
endif () |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
145 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
146 |
if (FMT_MASTER_PROJECT AND NOT DEFINED CMAKE_VISIBILITY_INLINES_HIDDEN) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
147 |
set_verbose(CMAKE_VISIBILITY_INLINES_HIDDEN ON CACHE BOOL |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
148 |
"Whether to add a compile flag to hide symbols of inline functions") |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
149 |
endif () |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
150 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
151 |
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU") |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
152 |
set(PEDANTIC_COMPILE_FLAGS -pedantic-errors -Wall -Wextra -pedantic |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
153 |
-Wold-style-cast -Wundef |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
154 |
-Wredundant-decls -Wwrite-strings -Wpointer-arith |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
155 |
-Wcast-qual -Wformat=2 -Wmissing-include-dirs |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
156 |
-Wcast-align |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
157 |
-Wctor-dtor-privacy -Wdisabled-optimization |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
158 |
-Winvalid-pch -Woverloaded-virtual |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
159 |
-Wconversion -Wundef |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
160 |
-Wno-ctor-dtor-privacy -Wno-format-nonliteral) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
161 |
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.6) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
162 |
set(PEDANTIC_COMPILE_FLAGS ${PEDANTIC_COMPILE_FLAGS} |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
163 |
-Wno-dangling-else -Wno-unused-local-typedefs) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
164 |
endif () |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
165 |
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
166 |
set(PEDANTIC_COMPILE_FLAGS ${PEDANTIC_COMPILE_FLAGS} -Wdouble-promotion |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
167 |
-Wtrampolines -Wzero-as-null-pointer-constant -Wuseless-cast |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
168 |
-Wvector-operation-performance -Wsized-deallocation -Wshadow) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
169 |
endif () |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
170 |
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
171 |
set(PEDANTIC_COMPILE_FLAGS ${PEDANTIC_COMPILE_FLAGS} -Wshift-overflow=2 |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
172 |
-Wnull-dereference -Wduplicated-cond) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
173 |
endif () |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
174 |
set(WERROR_FLAG -Werror) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
175 |
endif () |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
176 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
177 |
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
178 |
set(PEDANTIC_COMPILE_FLAGS -Wall -Wextra -pedantic -Wconversion -Wundef |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
179 |
-Wdeprecated -Wweak-vtables -Wshadow |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
180 |
-Wno-gnu-zero-variadic-macro-arguments) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
181 |
check_cxx_compiler_flag(-Wzero-as-null-pointer-constant HAS_NULLPTR_WARNING) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
182 |
if (HAS_NULLPTR_WARNING) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
183 |
set(PEDANTIC_COMPILE_FLAGS ${PEDANTIC_COMPILE_FLAGS} |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
184 |
-Wzero-as-null-pointer-constant) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
185 |
endif () |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
186 |
set(WERROR_FLAG -Werror) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
187 |
endif () |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
188 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
189 |
if (MSVC) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
190 |
set(PEDANTIC_COMPILE_FLAGS /W3) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
191 |
set(WERROR_FLAG /WX) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
192 |
endif () |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
193 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
194 |
if (FMT_MASTER_PROJECT AND CMAKE_GENERATOR MATCHES "Visual Studio") |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
195 |
# If Microsoft SDK is installed create script run-msbuild.bat that |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
196 |
# calls SetEnv.cmd to set up build environment and runs msbuild. |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
197 |
# It is useful when building Visual Studio projects with the SDK |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
198 |
# toolchain rather than Visual Studio. |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
199 |
include(FindSetEnv) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
200 |
if (WINSDK_SETENV) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
201 |
set(MSBUILD_SETUP "call \"${WINSDK_SETENV}\"") |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
202 |
endif () |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
203 |
# Set FrameworkPathOverride to get rid of MSB3644 warnings. |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
204 |
join(netfxpath |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
205 |
"C:\\Program Files\\Reference Assemblies\\Microsoft\\Framework\\" |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
206 |
".NETFramework\\v4.0") |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
207 |
file(WRITE run-msbuild.bat " |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
208 |
${MSBUILD_SETUP} |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
209 |
${CMAKE_MAKE_PROGRAM} -p:FrameworkPathOverride=\"${netfxpath}\" %*") |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
210 |
endif () |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
211 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
212 |
set(strtod_l_headers stdlib.h) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
213 |
if (APPLE) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
214 |
set(strtod_l_headers ${strtod_l_headers} xlocale.h) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
215 |
endif () |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
216 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
217 |
include(CheckSymbolExists) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
218 |
if (WIN32) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
219 |
check_symbol_exists(_strtod_l "${strtod_l_headers}" HAVE_STRTOD_L) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
220 |
else () |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
221 |
check_symbol_exists(strtod_l "${strtod_l_headers}" HAVE_STRTOD_L) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
222 |
endif () |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
223 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
224 |
function(add_headers VAR) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
225 |
set(headers ${${VAR}}) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
226 |
foreach (header ${ARGN}) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
227 |
set(headers ${headers} include/fmt/${header}) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
228 |
endforeach() |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
229 |
set(${VAR} ${headers} PARENT_SCOPE) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
230 |
endfunction() |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
231 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
232 |
# Define the fmt library, its includes and the needed defines. |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
233 |
add_headers(FMT_HEADERS args.h chrono.h color.h compile.h core.h format.h |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
234 |
format-inl.h locale.h os.h ostream.h printf.h ranges.h |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
235 |
xchar.h) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
236 |
if (FMT_MODULE) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
237 |
set(FMT_SOURCES src/fmt.cc) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
238 |
elseif (FMT_OS) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
239 |
set(FMT_SOURCES src/format.cc src/os.cc) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
240 |
else() |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
241 |
set(FMT_SOURCES src/format.cc) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
242 |
endif () |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
243 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
244 |
add_library(fmt ${FMT_SOURCES} ${FMT_HEADERS} README.rst ChangeLog.rst) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
245 |
add_library(fmt::fmt ALIAS fmt) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
246 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
247 |
if (HAVE_STRTOD_L) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
248 |
target_compile_definitions(fmt PUBLIC FMT_LOCALE) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
249 |
endif () |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
250 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
251 |
if (MINGW) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
252 |
check_cxx_compiler_flag("-Wa,-mbig-obj" FMT_HAS_MBIG_OBJ) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
253 |
if (${FMT_HAS_MBIG_OBJ}) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
254 |
target_compile_options(fmt PUBLIC "-Wa,-mbig-obj") |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
255 |
endif() |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
256 |
endif () |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
257 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
258 |
if (FMT_WERROR) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
259 |
target_compile_options(fmt PRIVATE ${WERROR_FLAG}) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
260 |
endif () |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
261 |
if (FMT_PEDANTIC) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
262 |
target_compile_options(fmt PRIVATE ${PEDANTIC_COMPILE_FLAGS}) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
263 |
endif () |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
264 |
if (FMT_MODULE) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
265 |
enable_module(fmt) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
266 |
endif () |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
267 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
268 |
target_compile_features(fmt INTERFACE ${FMT_REQUIRED_FEATURES}) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
269 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
270 |
target_include_directories(fmt ${FMT_SYSTEM_HEADERS_ATTRIBUTE} PUBLIC |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
271 |
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
272 |
$<INSTALL_INTERFACE:${FMT_INC_DIR}>) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
273 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
274 |
set(FMT_DEBUG_POSTFIX d CACHE STRING "Debug library postfix.") |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
275 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
276 |
set_target_properties(fmt PROPERTIES |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
277 |
VERSION ${FMT_VERSION} SOVERSION ${CPACK_PACKAGE_VERSION_MAJOR} |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
278 |
DEBUG_POSTFIX "${FMT_DEBUG_POSTFIX}") |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
279 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
280 |
# Set FMT_LIB_NAME for pkg-config fmt.pc. We cannot use the OUTPUT_NAME target |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
281 |
# property because it's not set by default. |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
282 |
set(FMT_LIB_NAME fmt) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
283 |
if (CMAKE_BUILD_TYPE STREQUAL "Debug") |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
284 |
set(FMT_LIB_NAME ${FMT_LIB_NAME}${FMT_DEBUG_POSTFIX}) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
285 |
endif () |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
286 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
287 |
if (BUILD_SHARED_LIBS) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
288 |
if (UNIX AND NOT APPLE AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "SunOS" AND |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
289 |
NOT EMSCRIPTEN) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
290 |
# Fix rpmlint warning: |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
291 |
# unused-direct-shlib-dependency /usr/lib/libformat.so.1.1.0 /lib/libm.so.6. |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
292 |
target_link_libraries(fmt -Wl,--as-needed) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
293 |
endif () |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
294 |
target_compile_definitions(fmt PRIVATE FMT_EXPORT INTERFACE FMT_SHARED) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
295 |
endif () |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
296 |
if (FMT_SAFE_DURATION_CAST) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
297 |
target_compile_definitions(fmt PUBLIC FMT_SAFE_DURATION_CAST) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
298 |
endif() |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
299 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
300 |
add_library(fmt-header-only INTERFACE) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
301 |
add_library(fmt::fmt-header-only ALIAS fmt-header-only) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
302 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
303 |
target_compile_definitions(fmt-header-only INTERFACE FMT_HEADER_ONLY=1) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
304 |
target_compile_features(fmt-header-only INTERFACE ${FMT_REQUIRED_FEATURES}) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
305 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
306 |
target_include_directories(fmt-header-only ${FMT_SYSTEM_HEADERS_ATTRIBUTE} INTERFACE |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
307 |
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
308 |
$<INSTALL_INTERFACE:${FMT_INC_DIR}>) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
309 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
310 |
# Install targets. |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
311 |
if (FMT_INSTALL) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
312 |
include(CMakePackageConfigHelpers) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
313 |
set_verbose(FMT_CMAKE_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/fmt CACHE STRING |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
314 |
"Installation directory for cmake files, a relative path that " |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
315 |
"will be joined with ${CMAKE_INSTALL_PREFIX} or an absolute " |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
316 |
"path.") |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
317 |
set(version_config ${PROJECT_BINARY_DIR}/fmt-config-version.cmake) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
318 |
set(project_config ${PROJECT_BINARY_DIR}/fmt-config.cmake) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
319 |
set(pkgconfig ${PROJECT_BINARY_DIR}/fmt.pc) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
320 |
set(targets_export_name fmt-targets) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
321 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
322 |
set_verbose(FMT_LIB_DIR ${CMAKE_INSTALL_LIBDIR} CACHE STRING |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
323 |
"Installation directory for libraries, a relative path that " |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
324 |
"will be joined to ${CMAKE_INSTALL_PREFIX} or an absolute path.") |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
325 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
326 |
set_verbose(FMT_PKGCONFIG_DIR ${CMAKE_INSTALL_LIBDIR}/pkgconfig CACHE PATH |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
327 |
"Installation directory for pkgconfig (.pc) files, a relative " |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
328 |
"path that will be joined with ${CMAKE_INSTALL_PREFIX} or an " |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
329 |
"absolute path.") |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
330 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
331 |
# Generate the version, config and target files into the build directory. |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
332 |
write_basic_package_version_file( |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
333 |
${version_config} |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
334 |
VERSION ${FMT_VERSION} |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
335 |
COMPATIBILITY AnyNewerVersion) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
336 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
337 |
join_paths(libdir_for_pc_file "\${exec_prefix}" "${FMT_LIB_DIR}") |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
338 |
join_paths(includedir_for_pc_file "\${prefix}" "${FMT_INC_DIR}") |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
339 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
340 |
configure_file( |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
341 |
"${PROJECT_SOURCE_DIR}/support/cmake/fmt.pc.in" |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
342 |
"${pkgconfig}" |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
343 |
@ONLY) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
344 |
configure_package_config_file( |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
345 |
${PROJECT_SOURCE_DIR}/support/cmake/fmt-config.cmake.in |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
346 |
${project_config} |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
347 |
INSTALL_DESTINATION ${FMT_CMAKE_DIR}) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
348 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
349 |
set(INSTALL_TARGETS fmt fmt-header-only) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
350 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
351 |
# Install the library and headers. |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
352 |
install(TARGETS ${INSTALL_TARGETS} EXPORT ${targets_export_name} |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
353 |
LIBRARY DESTINATION ${FMT_LIB_DIR} |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
354 |
ARCHIVE DESTINATION ${FMT_LIB_DIR} |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
355 |
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
356 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
357 |
# Use a namespace because CMake provides better diagnostics for namespaced |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
358 |
# imported targets. |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
359 |
export(TARGETS ${INSTALL_TARGETS} NAMESPACE fmt:: |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
360 |
FILE ${PROJECT_BINARY_DIR}/${targets_export_name}.cmake) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
361 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
362 |
# Install version, config and target files. |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
363 |
install( |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
364 |
FILES ${project_config} ${version_config} |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
365 |
DESTINATION ${FMT_CMAKE_DIR}) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
366 |
install(EXPORT ${targets_export_name} DESTINATION ${FMT_CMAKE_DIR} |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
367 |
NAMESPACE fmt::) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
368 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
369 |
install(FILES $<TARGET_PDB_FILE:${INSTALL_TARGETS}> |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
370 |
DESTINATION ${FMT_LIB_DIR} OPTIONAL) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
371 |
install(FILES ${FMT_HEADERS} DESTINATION "${FMT_INC_DIR}/fmt") |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
372 |
install(FILES "${pkgconfig}" DESTINATION "${FMT_PKGCONFIG_DIR}") |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
373 |
endif () |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
374 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
375 |
if (FMT_DOC) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
376 |
add_subdirectory(doc) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
377 |
endif () |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
378 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
379 |
if (FMT_TEST) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
380 |
enable_testing() |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
381 |
add_subdirectory(test) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
382 |
endif () |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
383 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
384 |
# Control fuzzing independent of the unit tests. |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
385 |
if (FMT_FUZZ) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
386 |
add_subdirectory(test/fuzzing) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
387 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
388 |
# The FMT_FUZZ macro is used to prevent resource exhaustion in fuzzing |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
389 |
# mode and make fuzzing practically possible. It is similar to |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
390 |
# FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION but uses a different name to |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
391 |
# avoid interfering with fuzzing of projects that use {fmt}. |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
392 |
# See also https://llvm.org/docs/LibFuzzer.html#fuzzer-friendly-build-mode. |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
393 |
target_compile_definitions(fmt PUBLIC FMT_FUZZ) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
394 |
endif () |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
395 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
396 |
set(gitignore ${PROJECT_SOURCE_DIR}/.gitignore) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
397 |
if (FMT_MASTER_PROJECT AND EXISTS ${gitignore}) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
398 |
# Get the list of ignored files from .gitignore. |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
399 |
file (STRINGS ${gitignore} lines) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
400 |
list(REMOVE_ITEM lines /doc/html) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
401 |
foreach (line ${lines}) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
402 |
string(REPLACE "." "[.]" line "${line}") |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
403 |
string(REPLACE "*" ".*" line "${line}") |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
404 |
set(ignored_files ${ignored_files} "${line}$" "${line}/") |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
405 |
endforeach () |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
406 |
set(ignored_files ${ignored_files} |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
407 |
/.git /breathe /format-benchmark sphinx/ .buildinfo .doctrees) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
408 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
409 |
set(CPACK_SOURCE_GENERATOR ZIP) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
410 |
set(CPACK_SOURCE_IGNORE_FILES ${ignored_files}) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
411 |
set(CPACK_SOURCE_PACKAGE_FILE_NAME fmt-${FMT_VERSION}) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
412 |
set(CPACK_PACKAGE_NAME fmt) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
413 |
set(CPACK_RESOURCE_FILE_README ${PROJECT_SOURCE_DIR}/README.rst) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
414 |
include(CPack) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
415 |
endif () |
|
|
1970-01-01 00:00 |
416 |
|