@@ -23,28 +23,6 @@ message (STATUS "CMAKE_CXX_COMPILER_ID = ${CMAKE_CXX_COMPILER_ID}")
2323message (VERBOSE "CMAKE_CXX_COMPILE_FEATURES = ${CMAKE_CXX_COMPILE_FEATURES} " )
2424
2525
26- ###########################################################################
27- # The proj_add_compile_definitions, proj_add_compile_options, and
28- # proj_add_link_options are like the global add_compile_definitions (etc), but
29- # they merely add to ${PROJECT_NAME}_blah lists, which are expected to be
30- # added to library and executable targets in our project. The point is that
31- # we really shouldn't be polluting the global definitions, in case our
32- # cmake files are included in an "outer" project.
33- #
34- macro (proj_add_compile_definitions)
35- list (APPEND ${PROJECT_NAME} _compile_definitions ${ARGN} )
36- endmacro ()
37-
38- macro (proj_add_compile_options)
39- list (APPEND ${PROJECT_NAME} _compile_options ${ARGN} )
40- endmacro ()
41-
42- macro (proj_add_link_options)
43- list (APPEND ${PROJECT_NAME} _link_options ${ARGN} )
44- endmacro ()
45-
46-
47-
4826###########################################################################
4927# C++ language standard
5028#
@@ -114,12 +92,12 @@ else ()
11492endif ()
11593option (EXTRA_WARNINGS "Enable lots of extra pedantic warnings" OFF )
11694if (NOT MSVC )
117- proj_add_compile_options ("-Wall" )
95+ add_compile_options ("-Wall" )
11896 if (EXTRA_WARNINGS)
119- proj_add_compile_options ("-Wextra" )
97+ add_compile_options ("-Wextra" )
12098 endif ()
12199 if (STOP_ON_WARNING)
122- proj_add_compile_options ("-Werror" )
100+ add_compile_options ("-Werror" )
123101 endif ()
124102endif ()
125103
@@ -157,88 +135,88 @@ endif ()
157135#
158136if (CMAKE_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_APPLECLANG)
159137 # Clang-specific options
160- proj_add_compile_options ("-Wno-unused-function" )
161- proj_add_compile_options ("-Wno-overloaded-virtual" )
162- proj_add_compile_options ("-Wno-unneeded-internal-declaration" )
163- proj_add_compile_options ("-Wno-unused-private-field" )
164- proj_add_compile_options ("-Wno-tautological-compare" )
138+ add_compile_options ("-Wno-unused-function" )
139+ add_compile_options ("-Wno-overloaded-virtual" )
140+ add_compile_options ("-Wno-unneeded-internal-declaration" )
141+ add_compile_options ("-Wno-unused-private-field" )
142+ add_compile_options ("-Wno-tautological-compare" )
165143 # disable warning about unused command line arguments
166- proj_add_compile_options ("-Qunused-arguments" )
144+ add_compile_options ("-Qunused-arguments" )
167145 # Don't warn if we ask it not to warn about warnings it doesn't know
168- proj_add_compile_options ("-Wunknown-warning-option" )
146+ add_compile_options ("-Wunknown-warning-option" )
169147 if (CLANG_VERSION_STRING VERSION_GREATER_EQUAL 3.6 OR
170148 APPLECLANG_VERSION_STRING VERSION_GREATER 6.1)
171- proj_add_compile_options ("-Wno-unused-local-typedefs" )
149+ add_compile_options ("-Wno-unused-local-typedefs" )
172150 endif ()
173151 if (CLANG_VERSION_STRING VERSION_GREATER_EQUAL 3.9)
174152 # Don't warn about using unknown preprocessor symbols in `#if`
175- proj_add_compile_options ("-Wno-expansion-to-defined" )
153+ add_compile_options ("-Wno-expansion-to-defined" )
176154 endif ()
177155 if (CMAKE_GENERATOR MATCHES "Xcode" )
178- proj_add_compile_options ("-Wno-shorten-64-to-32" )
156+ add_compile_options ("-Wno-shorten-64-to-32" )
179157 endif ()
180158endif ()
181159
182160if (CMAKE_COMPILER_IS_GNUCC AND NOT (CMAKE_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_APPLECLANG))
183161 # gcc specific options
184- proj_add_compile_options ("-Wno-unused-local-typedefs" )
185- proj_add_compile_options ("-Wno-unused-result" )
162+ add_compile_options ("-Wno-unused-local-typedefs" )
163+ add_compile_options ("-Wno-unused-result" )
186164 if (NOT ${GCC_VERSION} VERSION_LESS 7.0)
187- proj_add_compile_options ("-Wno-aligned-new" )
188- proj_add_compile_options ("-Wno-noexcept-type" )
165+ add_compile_options ("-Wno-aligned-new" )
166+ add_compile_options ("-Wno-noexcept-type" )
189167 endif ()
190168endif ()
191169
192170if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
193171 # Options common to gcc and clang
194172
195173 # Ensure this macro is set for stdint.h
196- proj_add_compile_definitions ( "-D__STDC_LIMIT_MACROS" )
197- proj_add_compile_definitions ( "-D__STDC_CONSTANT_MACROS" )
174+ add_compile_definitions (__STDC_LIMIT_MACROS )
175+ add_compile_definitions (__STDC_CONSTANT_MACROS )
198176endif ()
199177
200178if (INTELCLANG_VERSION_STRING VERSION_GREATER_EQUAL 2022.1.0)
201179 # New versions of icx warn about changing certain floating point options
202- proj_add_compile_options ("-Wno-overriding-t-option" )
180+ add_compile_options ("-Wno-overriding-t-option" )
203181endif ()
204182
205183if (MSVC )
206184 # Microsoft specific options
207- proj_add_compile_options (/W1)
208- proj_add_compile_options (/MP)
209- proj_add_compile_definitions (-D_CRT_SECURE_NO_DEPRECATE )
210- proj_add_compile_definitions (-D_CRT_SECURE_NO_WARNINGS )
211- proj_add_compile_definitions (-D_CRT_NONSTDC_NO_WARNINGS )
212- proj_add_compile_definitions (-D_SCL_SECURE_NO_WARNINGS )
213- proj_add_compile_definitions (-DJAS_WIN_MSVC_BUILD )
185+ add_compile_options (/W1)
186+ add_compile_options (/MP)
187+ add_compile_definitions (_CRT_SECURE_NO_DEPRECATE )
188+ add_compile_definitions (_CRT_SECURE_NO_WARNINGS )
189+ add_compile_definitions (_CRT_NONSTDC_NO_WARNINGS )
190+ add_compile_definitions (_SCL_SECURE_NO_WARNINGS )
191+ add_compile_definitions (JAS_WIN_MSVC_BUILD )
214192endif (MSVC )
215193
216194if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD"
217195 AND ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i386" )
218196 # For FreeBSD, minimum arch of i586 is needed for atomic cpu instructions
219- proj_add_compile_options (-march=i586)
197+ add_compile_options (-march=i586)
220198endif ()
221199
222200# Fast-math mode may go faster, but it breaks IEEE and also makes inconsistent
223201# results on different compilers/platforms, so we don't use it by default.
224202option (ENABLE_FAST_MATH "Use fast math (may break IEEE fp rules)" OFF )
225203if (ENABLE_FAST_MATH)
226204 if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
227- proj_add_compile_options ("-ffast-math" )
205+ add_compile_options ("-ffast-math" )
228206 elseif (MSVC )
229- proj_add_compile_options ("/fp:fast" )
207+ add_compile_options ("/fp:fast" )
230208 endif ()
231209else ()
232210 if (CMAKE_COMPILER_IS_INTELCLANG)
233211 # Intel icx is fast-math by default, so if we don't want that, we need
234212 # to explicitly disable it.
235- proj_add_compile_options ("-fno-fast-math" )
213+ add_compile_options ("-fno-fast-math" )
236214 endif ()
237215endif ()
238216
239217if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
240218 # this allows native instructions to be used for sqrtf instead of a function call
241- proj_add_compile_options ("-fno-math-errno" )
219+ add_compile_options ("-fno-math-errno" )
242220endif ()
243221
244222
@@ -307,7 +285,7 @@ endif ()
307285set (GLIBCXX_USE_CXX11_ABI "" CACHE STRING "For gcc, use the new C++11 library ABI (0|1)" )
308286if (CMAKE_COMPILER_IS_GNUCC AND ${GCC_VERSION} VERSION_GREATER_EQUAL 5.0)
309287 if (NOT ${GLIBCXX_USE_CXX11_ABI} STREQUAL "" )
310- proj_add_compile_definitions ( "-D_GLIBCXX_USE_CXX11_ABI =${GLIBCXX_USE_CXX11_ABI} " )
288+ add_compile_definitions (_GLIBCXX_USE_CXX11_ABI =${GLIBCXX_USE_CXX11_ABI} )
311289 endif ()
312290endif ()
313291
@@ -358,7 +336,7 @@ if (NOT USE_SIMD STREQUAL "")
358336 # off by default except when we explicitly use madd. At some
359337 # future time, we should look at this again carefully and
360338 # see if we want to use it more widely by ffp-contract=fast.
361- proj_add_compile_options ("-ffp-contract=off" )
339+ add_compile_options ("-ffp-contract=off" )
362340 endif ()
363341 endforeach ()
364342
@@ -376,7 +354,7 @@ if (NOT USE_SIMD STREQUAL "")
376354 endif ()
377355 unset (_highest_msvc_arch)
378356 endif ()
379- proj_add_compile_options (${SIMD_COMPILE_FLAGS} )
357+ add_compile_options (${SIMD_COMPILE_FLAGS} )
380358endif ()
381359
382360
@@ -436,10 +414,10 @@ endif ()
436414if (USE_STD_FILESYSTEM)
437415 # Note: std::filesystem seems unreliable for gcc until 9
438416 message (STATUS "Compiler supports std::filesystem" )
439- proj_add_compile_definitions (-DUSE_STD_FILESYSTEM )
417+ add_compile_definitions (USE_STD_FILESYSTEM )
440418else ()
441419 message (STATUS "Using Boost::filesystem" )
442- proj_add_compile_definitions (-DUSE_BOOST_FILESYSTEM )
420+ add_compile_definitions (USE_BOOST_FILESYSTEM )
443421endif ()
444422cmake_pop_check_state ()
445423
@@ -450,9 +428,9 @@ cmake_pop_check_state ()
450428option (CODECOV "Build code coverage tests" OFF )
451429if (CODECOV AND (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG))
452430 message (STATUS "Compiling for code coverage analysis" )
453- proj_add_compile_options (-ftest-coverage -fprofile-arcs)
454- proj_add_link_options (-ftest-coverage -fprofile-arcs)
455- proj_add_compile_definitions ( "-D ${PROJ_NAME} _CODE_COVERAGE=1" )
431+ add_compile_options (-ftest-coverage -fprofile-arcs)
432+ add_link_options (-ftest-coverage -fprofile-arcs)
433+ add_compile_definitions ( ${PROJ_NAME} _CODE_COVERAGE=1)
456434endif ()
457435
458436
@@ -465,15 +443,15 @@ if (SANITIZE AND (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG))
465443 string (REPLACE "," ";" SANITIZE_FEATURE_LIST ${SANITIZE} )
466444 foreach (feature ${SANITIZE_FEATURE_LIST} )
467445 message (STATUS " sanitize feature: ${feature} " )
468- proj_add_compile_options (-fsanitize=${feature} )
469- proj_add_link_options (-fsanitize=${feature} )
446+ add_compile_options (-fsanitize=${feature} )
447+ add_link_options (-fsanitize=${feature} )
470448 endforeach ()
471- proj_add_compile_options (-g -fno-omit-frame-pointer)
449+ add_compile_options (-g -fno-omit-frame-pointer)
472450 if (CMAKE_COMPILER_IS_GNUCC)
473451 # turn on glibcxx extra annotations to find vector writes past end
474- proj_add_compile_definitions ( "-D_GLIBCXX_SANITIZE_VECTOR=1" )
452+ add_compile_definitions (_GLIBCXX_SANITIZE_VECTOR=1 )
475453 endif ()
476- proj_add_compile_definitions ( "-D ${PROJECT_NAME} _SANITIZE=1" )
454+ add_compile_definitions ( ${PROJECT_NAME} _SANITIZE=1)
477455endif ()
478456
479457
@@ -496,7 +474,7 @@ endif ()
496474set (FORTIFY_SOURCE "0" CACHE STRING "Turn on Fortification level (0, 1, 2, 3)" )
497475if (FORTIFY_SOURCE AND (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG))
498476 message (STATUS "Compiling with _FORTIFY_SOURCE=${FORTIFY_SOURCE} " )
499- proj_add_compile_options (-D_FORTIFY_SOURCE=${FORTIFY_SOURCE} )
477+ add_compile_options (-D_FORTIFY_SOURCE=${FORTIFY_SOURCE} )
500478endif ()
501479
502480
@@ -595,7 +573,7 @@ endif ()
595573set (EXTRA_CPP_ARGS "" CACHE STRING "Extra C++ command line definitions" )
596574if (EXTRA_CPP_ARGS)
597575 message (STATUS "Extra C++ args: ${EXTRA_CPP_ARGS} " )
598- proj_add_compile_options (${EXTRA_CPP_ARGS} )
576+ add_compile_options (${EXTRA_CPP_ARGS} )
599577endif ()
600578set (EXTRA_DSO_LINK_ARGS "" CACHE STRING "Extra command line definitions when building DSOs" )
601579
@@ -623,7 +601,7 @@ message(VERBOSE "Setting SOVERSION to: ${SOVERSION}")
623601#
624602option (BUILD_SHARED_LIBS "Build shared libraries (set to OFF to build static libs)" ON )
625603if (NOT BUILD_SHARED_LIBS )
626- proj_add_compile_definitions (-D ${PROJ_NAME} _STATIC_DEFINE=1)
604+ add_compile_definitions ( ${PROJ_NAME} _STATIC_DEFINE=1)
627605endif ()
628606
629607
@@ -648,7 +626,7 @@ endif ()
648626# We expect our own CI runs to define env variable ${PROJECT_NAME}_CI
649627#
650628if (DEFINED ENV{${PROJECT_NAME} _CI})
651- proj_add_compile_definitions (-D ${PROJ_NAME} _CI=1 -DBUILD_CI =1)
629+ add_compile_definitions ( ${PROJ_NAME} _CI=1 BUILD_CI =1)
652630 if (APPLE )
653631 # Keep Mono framework from being incorrectly searched for include
654632 # files on GitHub Actions CI.
0 commit comments