cmake: Reimplement SECP256K1_APPEND_CFLAGS using Bitcoin Core approach
This commit is contained in:
@@ -284,14 +284,16 @@ if(SECP256K1_BUILD_BENCHMARK OR SECP256K1_BUILD_TESTS OR SECP256K1_BUILD_EXHAUST
|
||||
enable_testing()
|
||||
endif()
|
||||
|
||||
set(SECP256K1_APPEND_CFLAGS "" CACHE STRING "Compiler flags that are added to the command line after all other flags added by the build system.")
|
||||
include(AllTargetsCompileOptions)
|
||||
set(SECP256K1_APPEND_CFLAGS "" CACHE STRING "Compiler flags that are appended to the command line after all other flags added by the build system. This variable is intended for debugging and special builds.")
|
||||
if(SECP256K1_APPEND_CFLAGS)
|
||||
# Appending to this low-level rule variable is the only way to
|
||||
# guarantee that the flags appear at the end of the command line.
|
||||
string(APPEND CMAKE_C_COMPILE_OBJECT " ${SECP256K1_APPEND_CFLAGS}")
|
||||
endif()
|
||||
|
||||
add_subdirectory(src)
|
||||
all_targets_compile_options(src "${SECP256K1_APPEND_CFLAGS}")
|
||||
if(SECP256K1_BUILD_EXAMPLES)
|
||||
add_subdirectory(examples)
|
||||
all_targets_compile_options(examples "${SECP256K1_APPEND_CFLAGS}")
|
||||
endif()
|
||||
|
||||
message("\n")
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
# Add compile options to all targets added in the subdirectory.
|
||||
function(all_targets_compile_options dir options)
|
||||
get_directory_property(targets DIRECTORY ${dir} BUILDSYSTEM_TARGETS)
|
||||
separate_arguments(options)
|
||||
set(compiled_target_types STATIC_LIBRARY SHARED_LIBRARY OBJECT_LIBRARY EXECUTABLE)
|
||||
foreach(target ${targets})
|
||||
get_target_property(type ${target} TYPE)
|
||||
if(type IN_LIST compiled_target_types)
|
||||
target_compile_options(${target} PRIVATE ${options})
|
||||
endif()
|
||||
endforeach()
|
||||
endfunction()
|
||||
Reference in New Issue
Block a user