File tree 2 files changed +20
-0
lines changed 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -216,9 +216,14 @@ if(SECP256K1_BUILD_BENCHMARK OR SECP256K1_BUILD_TESTS OR SECP256K1_BUILD_EXHAUST
216
216
enable_testing ()
217
217
endif ()
218
218
219
+ set (SECP256K1_C_FLAGS "" CACHE STRING "Compiler flags that can override flags set by the build system." )
220
+ include (AllTargetsCompileOptions)
221
+
219
222
add_subdirectory (src)
223
+ all_targets_compile_options(src "${SECP256K1_C_FLAGS} " )
220
224
if (SECP256K1_BUILD_EXAMPLES)
221
225
add_subdirectory (examples)
226
+ all_targets_compile_options(examples "${SECP256K1_C_FLAGS} " )
222
227
endif ()
223
228
224
229
message ("\n " )
@@ -286,6 +291,9 @@ else()
286
291
message (" - LDFLAGS for executables ............ ${CMAKE_EXE_LINKER_FLAGS_DEBUG} " )
287
292
message (" - LDFLAGS for shared libraries ....... ${CMAKE_SHARED_LINKER_FLAGS_DEBUG} " )
288
293
endif ()
294
+ if (SECP256K1_C_FLAGS)
295
+ message ("SECP256K1_C_FLAGS ..................... ${SECP256K1_C_FLAGS} " )
296
+ endif ()
289
297
message ("\n " )
290
298
if (SECP256K1_EXPERIMENTAL)
291
299
message (
Original file line number Diff line number Diff line change
1
+ # Add compile options to all targets added in the subdirectory.
2
+ function (all_targets_compile_options dir options )
3
+ get_directory_property (targets DIRECTORY ${dir} BUILDSYSTEM_TARGETS)
4
+ separate_arguments (options )
5
+ set (compiled_target_types STATIC_LIBRARY SHARED_LIBRARY OBJECT_LIBRARY EXECUTABLE)
6
+ foreach (target ${targets} )
7
+ get_target_property (type ${target} TYPE )
8
+ if (type IN_LIST compiled_target_types)
9
+ target_compile_options (${target} PRIVATE ${options} )
10
+ endif ()
11
+ endforeach ()
12
+ endfunction ()
You can’t perform that action at this time.
0 commit comments