@@ -161,18 +161,17 @@ option(SECP256K1_BUILD_EXHAUSTIVE_TESTS "Build exhaustive tests." ON)
161
161
option (SECP256K1_BUILD_CTIME_TESTS "Build constant-time tests." ${SECP256K1_VALGRIND} )
162
162
option (SECP256K1_BUILD_EXAMPLES "Build examples." OFF )
163
163
164
+ include (ProcessConfigurations )
165
+ set_default_config (RelWithDebInfo )
166
+
164
167
# Redefine configuration flags.
165
168
# We leave assertions on, because they are only used in the examples, and we want them always on there.
166
169
if (MSVC )
167
- string (REGEX REPLACE "/DNDEBUG[ \t\r\n ]*" "" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} " )
168
- string (REGEX REPLACE "/DNDEBUG[ \t\r\n ]*" "" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} " )
169
- string (REGEX REPLACE "/DNDEBUG[ \t\r\n ]*" "" CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} " )
170
+ remove_flag_from_all_configs (/DNDEBUG )
170
171
else ()
171
- string (REGEX REPLACE "-DNDEBUG[ \t\r\n ]*" "" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} " )
172
- string (REGEX REPLACE "-DNDEBUG[ \t\r\n ]*" "" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} " )
173
- string (REGEX REPLACE "-DNDEBUG[ \t\r\n ]*" "" CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} " )
172
+ remove_flag_from_all_configs (-DNDEBUG )
174
173
# Prefer -O2 optimization level. (-O3 is CMake's default for Release for many compilers.)
175
- string ( REGEX REPLACE " -O3[ \t\r\n ]*" " -O2" CMAKE_C_FLAGS_RELEASE " ${CMAKE_C_FLAGS_RELEASE} " )
174
+ replace_flag_in_config ( Release -O3 -O2 )
176
175
endif ()
177
176
178
177
# Define custom "Coverage" build type.
@@ -195,23 +194,10 @@ mark_as_advanced(
195
194
)
196
195
197
196
get_property (is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG )
198
- set (default_build_type "RelWithDebInfo" )
199
197
if (is_multi_config )
200
- set (CMAKE_CONFIGURATION_TYPES "${default_build_type} " "Release" "Debug" "MinSizeRel" "Coverage" CACHE STRING
201
- "Supported configuration types."
202
- FORCE
203
- )
198
+ list (APPEND CMAKE_CONFIGURATION_TYPES Coverage )
204
199
else ()
205
- set_property (CACHE CMAKE_BUILD_TYPE PROPERTY
206
- STRINGS "${default_build_type} " "Release" "Debug" "MinSizeRel" "Coverage"
207
- )
208
- if (NOT CMAKE_BUILD_TYPE )
209
- message (STATUS "Setting build type to \" ${default_build_type} \" as none was specified" )
210
- set (CMAKE_BUILD_TYPE "${default_build_type} " CACHE STRING
211
- "Choose the type of build."
212
- FORCE
213
- )
214
- endif ()
200
+ set_property (CACHE CMAKE_BUILD_TYPE APPEND PROPERTY STRINGS Coverage )
215
201
endif ()
216
202
217
203
include (TryAppendCFlags )
@@ -312,24 +298,7 @@ message("CFLAGS ................................ ${CMAKE_C_FLAGS}")
312
298
get_directory_property (compile_options COMPILE_OPTIONS )
313
299
string (REPLACE ";" " " compile_options "${compile_options} " )
314
300
message ("Compile options ....................... " ${compile_options} )
315
- if (NOT is_multi_config )
316
- message ("Build type:" )
317
- message (" - CMAKE_BUILD_TYPE ................... ${CMAKE_BUILD_TYPE} " )
318
- string (TOUPPER "${CMAKE_BUILD_TYPE} " build_type )
319
- message (" - CFLAGS ............................. ${CMAKE_C_FLAGS_${build_type} }" )
320
- message (" - LDFLAGS for executables ............ ${CMAKE_EXE_LINKER_FLAGS_${build_type} }" )
321
- message (" - LDFLAGS for shared libraries ....... ${CMAKE_SHARED_LINKER_FLAGS_${build_type} }" )
322
- else ()
323
- message ("Supported configurations .............. ${CMAKE_CONFIGURATION_TYPES} " )
324
- message ("RelWithDebInfo configuration:" )
325
- message (" - CFLAGS ............................. ${CMAKE_C_FLAGS_RELWITHDEBINFO} " )
326
- message (" - LDFLAGS for executables ............ ${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} " )
327
- message (" - LDFLAGS for shared libraries ....... ${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} " )
328
- message ("Debug configuration:" )
329
- message (" - CFLAGS ............................. ${CMAKE_C_FLAGS_DEBUG} " )
330
- message (" - LDFLAGS for executables ............ ${CMAKE_EXE_LINKER_FLAGS_DEBUG} " )
331
- message (" - LDFLAGS for shared libraries ....... ${CMAKE_SHARED_LINKER_FLAGS_DEBUG} " )
332
- endif ()
301
+ print_config_flags ()
333
302
message ("\n " )
334
303
if (SECP256K1_EXPERIMENTAL )
335
304
message (
0 commit comments