Skip to content

Commit 0578462

Browse files
committed
Merge #184: cmake: Add user-defined APPEND_{CPP,C,CXX,LD}FLAGS (take 2)
a9dc2c1 cmake: Dispaly `APPEND_{CPP,C,CXX,LD}FLAGS` in summary (Hennadii Stepanov) bfadb6e cmake: Add `APPEND_{CPP,C,CXX,LD}FLAGS` cache variables (Hennadii Stepanov) Pull request description: An alternative implementation of #157. ACKs for top commit: vasild: ACK a9dc2c1 Tree-SHA512: 77fff64817c59153e4022390bed3a5db1eeb247ea916c99c582fcf18fe9e1f638aa2dd38121ebb5734339bf15d935a8b817083918020b944f2a0d72c76375e86
2 parents fb593cd + a9dc2c1 commit 0578462

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

CMakeLists.txt

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,14 @@ cmake_dependent_option(FUZZ "Build for fuzzing. Enabling this will disable all o
169169

170170
option(INSTALL_MAN "Install man pages." ON)
171171

172+
set(APPEND_CPPFLAGS "" CACHE STRING "Preprocessor flags that are appended to the flags added by the build system.")
173+
set(APPEND_CFLAGS "" CACHE STRING "C compiler flags that are appended to the flags added by the build system.")
174+
set(APPEND_CXXFLAGS "" CACHE STRING "(Objective) C++ compiler flags that are appended to the flags added by the build system.")
175+
set(APPEND_LDFLAGS "" CACHE STRING "Linker flags that are appended to the flags added by the build system.")
176+
string(APPEND CMAKE_CXX_COMPILE_OBJECT " ${APPEND_CPPFLAGS} ${APPEND_CXXFLAGS}")
177+
string(APPEND CMAKE_CXX_CREATE_SHARED_LIBRARY " ${APPEND_LDFLAGS}")
178+
string(APPEND CMAKE_CXX_LINK_EXECUTABLE " ${APPEND_LDFLAGS}")
179+
172180
set(configure_warnings)
173181

174182
include(CheckPIESupported)
@@ -630,15 +638,15 @@ endif()
630638
message("Cross compiling ....................... ${cross_status}")
631639
message("Preprocessor defined macros ........... ${definitions}")
632640
message("C compiler ............................ ${CMAKE_C_COMPILER_ID} ${CMAKE_C_COMPILER_VERSION}, ${CMAKE_C_COMPILER}")
633-
message("CFLAGS ................................ ${CMAKE_C_FLAGS}")
641+
message("CFLAGS ................................ ${CMAKE_C_FLAGS} ${APPEND_CPPFLAGS} ${APPEND_CFLAGS}")
634642
message("C++ compiler .......................... ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}, ${CMAKE_CXX_COMPILER}")
635-
message("CXXFLAGS .............................. ${CMAKE_CXX_FLAGS}")
643+
message("CXXFLAGS .............................. ${CMAKE_CXX_FLAGS} ${APPEND_CPPFLAGS} ${APPEND_CXXFLAGS}")
636644
get_target_interface(common_compile_options core_interface COMPILE_OPTIONS)
637645
message("Common compile options ................ ${common_compile_options}")
638646
get_target_interface(common_link_options core_interface LINK_OPTIONS)
639647
message("Common link options ................... ${common_link_options}")
640-
message("Linker flags for executables .......... ${CMAKE_EXE_LINKER_FLAGS}")
641-
message("Linker flags for shared libraries ..... ${CMAKE_SHARED_LINKER_FLAGS}")
648+
message("Linker flags for executables .......... ${CMAKE_EXE_LINKER_FLAGS} ${APPEND_LDFLAGS}")
649+
message("Linker flags for shared libraries ..... ${CMAKE_SHARED_LINKER_FLAGS} ${APPEND_LDFLAGS}")
642650
print_config_flags()
643651
message("Attempt to harden executables ......... ${HARDENING}")
644652
message("Treat compiler warnings as errors ..... ${WERROR}")

cmake/secp256k1.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
enable_language(C)
1010
set(CMAKE_C_STANDARD 90)
1111
set(CMAKE_C_EXTENSIONS OFF)
12+
string(APPEND CMAKE_C_COMPILE_OBJECT " ${APPEND_CPPFLAGS} ${APPEND_CFLAGS}")
1213

1314
include(CheckCSourceCompiles)
1415
check_c_source_compiles("

src/qt/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
2323
set(CMAKE_OBJCXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
2424
set(CMAKE_OBJCXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
2525
set(CMAKE_OBJCXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL}")
26+
string(APPEND CMAKE_OBJCXX_COMPILE_OBJECT " ${APPEND_CPPFLAGS} ${APPEND_CXXFLAGS}")
2627
endif()
2728

2829
function(import_plugins target)

0 commit comments

Comments
 (0)