Skip to content

Commit dfc074c

Browse files
committed
build: create Depends build type for depends and use it by default
Rather than modifying the existing build types and adding flags for each, create a new type specifically for depends. This allows the forwarding of optional flags into the CMake build for the "Depends" build type, but the user can now optionally use an existing (Debug/RelWitDebInfo/etc.) type to ignore the optimization flags set by depends and use the ones from that type instead. As an example, a user may do: make -C depends cmake --toolchain depends/arm64-apple-darwin/toolchain.cmake -DCMAKE_BUILD_TYPE=Debug This would compile depends with the default optimization flags for depends (-O2) but build Core with the default optimization flags from CMake. Depends note: For hosts, $host_*FLAGS variables now represent the mandatory flags for compiling and will be forwarded to all Core builds in the toolchain file, regardless of the build type. For most platforms they should be empty, but are useful at least for darwin. When setting (for example) CFLAGS from the command line when building depends, these flags will be stored in $host_release_CFLAGS (or _debug_), and will only be forwarded to the Depends build type.
1 parent f7906de commit dfc074c

File tree

3 files changed

+33
-36
lines changed

3 files changed

+33
-36
lines changed

CMakeLists.txt

+3-4
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,10 @@ check_linker_supports_pie(configure_warnings)
201201
# It is a usage requirement for all targets except for secp256k1, which
202202
# gets its flags by other means.
203203
add_library(core_interface INTERFACE)
204-
add_library(core_interface_relwithdebinfo INTERFACE)
204+
add_library(core_interface_depends INTERFACE)
205205
add_library(core_interface_debug INTERFACE)
206206
target_link_libraries(core_interface INTERFACE
207-
$<$<CONFIG:RelWithDebInfo>:core_interface_relwithdebinfo>
207+
$<$<CONFIG:Depends>:core_interface_depends>
208208
$<$<CONFIG:Debug>:core_interface_debug>
209209
)
210210

@@ -572,8 +572,7 @@ else()
572572
endif()
573573

574574
target_compile_definitions(core_interface INTERFACE ${DEPENDS_COMPILE_DEFINITIONS})
575-
target_compile_definitions(core_interface_relwithdebinfo INTERFACE ${DEPENDS_COMPILE_DEFINITIONS_RELWITHDEBINFO})
576-
target_compile_definitions(core_interface_debug INTERFACE ${DEPENDS_COMPILE_DEFINITIONS_DEBUG})
575+
target_compile_definitions(core_interface_depends INTERFACE ${DEPENDS_CONFIG_COMPILE_DEFINITIONS})
577576

578577
# If the {CXX,LD}FLAGS environment variables are defined during building depends
579578
# and configuring this build system, their content might be duplicated.

depends/Makefile

+4-8
Original file line numberDiff line numberDiff line change
@@ -218,17 +218,13 @@ $(host_prefix)/toolchain.cmake : toolchain.cmake.in $(host_prefix)/.stamp_$(fina
218218
-e 's|@OBJCOPY@|$(host_OBJCOPY)|' \
219219
-e 's|@OBJDUMP@|$(host_OBJDUMP)|' \
220220
-e 's|@CFLAGS@|$(strip $(host_CFLAGS))|' \
221-
-e 's|@CFLAGS_RELEASE@|$(strip $(host_release_CFLAGS))|' \
222-
-e 's|@CFLAGS_DEBUG@|$(strip $(host_debug_CFLAGS))|' \
221+
-e 's|@CFLAGS_DEPENDS_CONFIG@|$(strip $(host_$(release_type)_CFLAGS))|' \
223222
-e 's|@CXXFLAGS@|$(strip $(host_CXXFLAGS))|' \
224-
-e 's|@CXXFLAGS_RELEASE@|$(strip $(host_release_CXXFLAGS))|' \
225-
-e 's|@CXXFLAGS_DEBUG@|$(strip $(host_debug_CXXFLAGS))|' \
223+
-e 's|@CXXFLAGS_DEPENDS_CONFIG@|$(strip $(host_$(release_type)_CXXFLAGS))|' \
226224
-e 's|@CPPFLAGS@|$(strip $(host_CPPFLAGS))|' \
227-
-e 's|@CPPFLAGS_RELEASE@|$(strip $(host_release_CPPFLAGS))|' \
228-
-e 's|@CPPFLAGS_DEBUG@|$(strip $(host_debug_CPPFLAGS))|' \
225+
-e 's|@CPPFLAGS_DEPENDS_CONFIG@|$(strip $(host_$(release_type)_CPPFLAGS))|' \
229226
-e 's|@LDFLAGS@|$(strip $(host_LDFLAGS))|' \
230-
-e 's|@LDFLAGS_RELEASE@|$(strip $(host_release_LDFLAGS))|' \
231-
-e 's|@LDFLAGS_DEBUG@|$(strip $(host_debug_LDFLAGS))|' \
227+
-e 's|@LDFLAGS_DEPENDS_CONFIG@|$(strip $(host_$(release_type)_LDFLAGS))|' \
232228
-e 's|@qt_packages@|$(qt_packages_)|' \
233229
-e 's|@qrencode_packages@|$(qrencode_packages_)|' \
234230
-e 's|@zmq_packages@|$(zmq_packages_)|' \

depends/toolchain.cmake.in

+26-24
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,27 @@ if(@depends_crosscompiling@)
1515
set(CMAKE_SYSTEM_PROCESSOR @host_arch@)
1616
endif()
1717

18+
19+
# Create a build type specifically for depends builds and default to it. When
20+
# building from depends toolchain file, this will ensure that the flags from
21+
# depends (or those provided by the user during depends build) will not be
22+
# overridden by CMake's build-type flags.
23+
# The user can still change the build-type to a non-Depends-type
24+
# (Release/Debug/RelWithDebInfo/etc), which will inform the build to ignore the
25+
# depends flags.
26+
if(NOT SET_UP_CONFIGURATIONS_DONE)
27+
set(SET_UP_CONFIGURATIONS_DONE TRUE)
28+
list(PREPEND CMAKE_CONFIGURATION_TYPES "Depends")
29+
if(NOT CMAKE_BUILD_TYPE)
30+
set(CMAKE_BUILD_TYPE Depends)
31+
endif()
32+
endif()
33+
1834
if(NOT DEFINED CMAKE_C_FLAGS_INIT)
1935
set(CMAKE_C_FLAGS_INIT "@CFLAGS@")
2036
endif()
21-
if(NOT DEFINED CMAKE_C_FLAGS_RELWITHDEBINFO_INIT)
22-
set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "@CFLAGS_RELEASE@")
23-
endif()
24-
if(NOT DEFINED CMAKE_C_FLAGS_DEBUG_INIT)
25-
set(CMAKE_C_FLAGS_DEBUG_INIT "@CFLAGS_DEBUG@")
37+
if(NOT DEFINED CMAKE_C_FLAGS_DEPENDS_INIT)
38+
set(CMAKE_C_FLAGS_DEPENDS_INIT "@CFLAGS_DEPENDS_CONFIG@")
2639
endif()
2740

2841
if(NOT DEFINED CMAKE_C_COMPILER)
@@ -33,13 +46,9 @@ if(NOT DEFINED CMAKE_CXX_FLAGS_INIT)
3346
set(CMAKE_CXX_FLAGS_INIT "@CXXFLAGS@")
3447
set(CMAKE_OBJCXX_FLAGS_INIT "@CXXFLAGS@")
3548
endif()
36-
if(NOT DEFINED CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT)
37-
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "@CXXFLAGS_RELEASE@")
38-
set(CMAKE_OBJCXX_FLAGS_RELWITHDEBINFO_INIT "@CXXFLAGS_RELEASE@")
39-
endif()
40-
if(NOT DEFINED CMAKE_CXX_FLAGS_DEBUG_INIT)
41-
set(CMAKE_CXX_FLAGS_DEBUG_INIT "@CXXFLAGS_DEBUG@")
42-
set(CMAKE_OBJCXX_FLAGS_DEBUG_INIT "@CXXFLAGS_DEBUG@")
49+
if(NOT DEFINED CMAKE_CXX_FLAGS_DEPENDS_INIT)
50+
set(CMAKE_CXX_FLAGS_DEPENDS_INIT "@CXXFLAGS_DEPENDS_CONFIG@")
51+
set(CMAKE_OBJCXX_FLAGS_DEPENDS_INIT "@CXXFLAGS_DEPENDS_CONFIG@")
4352
endif()
4453

4554
if(NOT DEFINED CMAKE_CXX_COMPILER)
@@ -49,26 +58,19 @@ endif()
4958

5059
# The DEPENDS_COMPILE_DEFINITIONS* variables are to be treated as lists.
5160
set(DEPENDS_COMPILE_DEFINITIONS @CPPFLAGS@)
52-
set(DEPENDS_COMPILE_DEFINITIONS_RELWITHDEBINFO @CPPFLAGS_RELEASE@)
53-
set(DEPENDS_COMPILE_DEFINITIONS_DEBUG @CPPFLAGS_DEBUG@)
61+
set(DEPENDS_CONFIG_COMPILE_DEFINITIONS @CPPFLAGS_DEPENDS_CONFIG@)
5462

5563
if(NOT DEFINED CMAKE_EXE_LINKER_FLAGS_INIT)
5664
set(CMAKE_EXE_LINKER_FLAGS_INIT "@LDFLAGS@")
5765
endif()
5866
if(NOT DEFINED CMAKE_SHARED_LINKER_FLAGS_INIT)
5967
set(CMAKE_SHARED_LINKER_FLAGS_INIT "@LDFLAGS@")
6068
endif()
61-
if(NOT DEFINED CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT)
62-
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT "@LDFLAGS_RELEASE@")
63-
endif()
64-
if(NOT DEFINED CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO_INIT)
65-
set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO_INIT "@LDFLAGS_RELEASE@")
66-
endif()
67-
if(NOT DEFINED CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT)
68-
set(CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT "@LDFLAGS_DEBUG@")
69+
if(NOT DEFINED CMAKE_SHARED_LINKER_FLAGS_DEPENDS_INIT)
70+
set(CMAKE_SHARED_LINKER_FLAGS_DEPENDS_INIT "@LDFLAGS_DEPENDS_CONFIG@")
6971
endif()
70-
if(NOT DEFINED CMAKE_SHARED_LINKER_FLAGS_DEBUG_INIT)
71-
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG_INIT "@LDFLAGS_DEBUG@")
72+
if(NOT DEFINED CMAKE_EXE_LINKER_FLAGS_DEPENDS_INIT)
73+
set(CMAKE_EXE_LINKER_FLAGS_DEPENDS_INIT "@LDFLAGS_DEPENDS_CONFIG@")
7274
endif()
7375

7476
set(CMAKE_AR "@AR@")

0 commit comments

Comments
 (0)