@@ -150,18 +150,17 @@ option(SECP256K1_BUILD_EXHAUSTIVE_TESTS "Build exhaustive tests." ON)
150
150
option (SECP256K1_BUILD_CTIME_TESTS "Build constant-time tests." ${SECP256K1_VALGRIND} )
151
151
option (SECP256K1_BUILD_EXAMPLES "Build examples." OFF )
152
152
153
+ include (ProcessConfigurations)
154
+ set_default_config(RelWithDebInfo)
155
+
153
156
# Redefine configuration flags.
154
157
# We leave assertions on, because they are only used in the examples, and we want them always on there.
155
158
if (MSVC )
156
- string (REGEX REPLACE "/DNDEBUG[ \t\r\n ]*" "" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} " )
157
- string (REGEX REPLACE "/DNDEBUG[ \t\r\n ]*" "" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} " )
158
- string (REGEX REPLACE "/DNDEBUG[ \t\r\n ]*" "" CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} " )
159
+ remove_flag_from_all_configs(/DNDEBUG)
159
160
else ()
160
- string (REGEX REPLACE "-DNDEBUG[ \t\r\n ]*" "" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} " )
161
- string (REGEX REPLACE "-DNDEBUG[ \t\r\n ]*" "" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} " )
162
- string (REGEX REPLACE "-DNDEBUG[ \t\r\n ]*" "" CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} " )
161
+ remove_flag_from_all_configs(-DNDEBUG)
163
162
# Prefer -O2 optimization level. (-O3 is CMake's default for Release for many compilers.)
164
- string ( REGEX REPLACE " -O3[ \t\r\n ]*" " -O2" CMAKE_C_FLAGS_RELEASE " ${CMAKE_C_FLAGS_RELEASE} " )
163
+ replace_flag_in_config(Release -O3 -O2)
165
164
endif ()
166
165
167
166
# Define custom "Coverage" build type.
@@ -184,23 +183,10 @@ mark_as_advanced(
184
183
)
185
184
186
185
get_property (is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
187
- set (default_build_type "RelWithDebInfo" )
188
186
if (is_multi_config)
189
- set (CMAKE_CONFIGURATION_TYPES "${default_build_type} " "Release" "Debug" "MinSizeRel" "Coverage" CACHE STRING
190
- "Supported configuration types."
191
- FORCE
192
- )
187
+ list (APPEND CMAKE_CONFIGURATION_TYPES Coverage)
193
188
else ()
194
- set_property (CACHE CMAKE_BUILD_TYPE PROPERTY
195
- STRINGS "${default_build_type} " "Release" "Debug" "MinSizeRel" "Coverage"
196
- )
197
- if (NOT CMAKE_BUILD_TYPE )
198
- message (STATUS "Setting build type to \" ${default_build_type} \" as none was specified" )
199
- set (CMAKE_BUILD_TYPE "${default_build_type} " CACHE STRING
200
- "Choose the type of build."
201
- FORCE
202
- )
203
- endif ()
189
+ set_property (CACHE CMAKE_BUILD_TYPE APPEND PROPERTY STRINGS Coverage)
204
190
endif ()
205
191
206
192
include (TryAppendCFlags)
@@ -296,24 +282,7 @@ message("CFLAGS ................................ ${CMAKE_C_FLAGS}")
296
282
get_directory_property (compile_options COMPILE_OPTIONS)
297
283
string (REPLACE ";" " " compile_options "${compile_options} " )
298
284
message ("Compile options ....................... " ${compile_options} )
299
- if (NOT is_multi_config)
300
- message ("Build type:" )
301
- message (" - CMAKE_BUILD_TYPE ................... ${CMAKE_BUILD_TYPE} " )
302
- string (TOUPPER "${CMAKE_BUILD_TYPE} " build_type )
303
- message (" - CFLAGS ............................. ${CMAKE_C_FLAGS_${build_type} }" )
304
- message (" - LDFLAGS for executables ............ ${CMAKE_EXE_LINKER_FLAGS_${build_type} }" )
305
- message (" - LDFLAGS for shared libraries ....... ${CMAKE_SHARED_LINKER_FLAGS_${build_type} }" )
306
- else ()
307
- message ("Supported configurations .............. ${CMAKE_CONFIGURATION_TYPES} " )
308
- message ("RelWithDebInfo configuration:" )
309
- message (" - CFLAGS ............................. ${CMAKE_C_FLAGS_RELWITHDEBINFO} " )
310
- message (" - LDFLAGS for executables ............ ${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} " )
311
- message (" - LDFLAGS for shared libraries ....... ${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} " )
312
- message ("Debug configuration:" )
313
- message (" - CFLAGS ............................. ${CMAKE_C_FLAGS_DEBUG} " )
314
- message (" - LDFLAGS for executables ............ ${CMAKE_EXE_LINKER_FLAGS_DEBUG} " )
315
- message (" - LDFLAGS for shared libraries ....... ${CMAKE_SHARED_LINKER_FLAGS_DEBUG} " )
316
- endif ()
285
+ print_config_flags()
317
286
message ("\n " )
318
287
if (SECP256K1_EXPERIMENTAL)
319
288
message (
0 commit comments