Skip to content

Commit

Permalink
[FIXUP] cmake: Do not trigger cross-compiling unnecessarily
Browse files Browse the repository at this point in the history
  • Loading branch information
hebasto committed Mar 21, 2024
1 parent 2b2edb3 commit 5c50fe9
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
try_append_linker_flag("-Wl,-headerpad_max_install_names" TARGET core_base_interface)
endif()

if(CMAKE_CROSSCOMPILING)
if(BITCOIN_BUILD_WITH_DEPENDS)
target_compile_definitions(core_base_interface INTERFACE ${DEPENDS_COMPILE_DEFINITIONS})
target_compile_options(core_base_interface INTERFACE "$<$<COMPILE_LANGUAGE:C>:${DEPENDS_C_COMPILER_FLAGS}>")
target_compile_options(core_base_interface INTERFACE "$<$<COMPILE_LANGUAGE:CXX>:${DEPENDS_CXX_COMPILER_FLAGS}>")
Expand Down
2 changes: 1 addition & 1 deletion cmake/module/CrossPkgConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function(remove_isystem_from_include_directories_internal target)
endfunction()

macro(cross_pkg_check_modules prefix)
if(CMAKE_CROSSCOMPILING)
if(BITCOIN_BUILD_WITH_DEPENDS)
set(pkg_config_path_saved "$ENV{PKG_CONFIG_PATH}")
set(pkg_config_libdir_saved "$ENV{PKG_CONFIG_LIBDIR}")
set(ENV{PKG_CONFIG_PATH} ${PKG_CONFIG_PATH})
Expand Down
2 changes: 1 addition & 1 deletion cmake/module/Maintenance.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function(add_maintenance_targets)
else()
set(exe_format ELF)
endif()
if(CMAKE_CROSSCOMPILING)
if(BITCOIN_BUILD_WITH_DEPENDS)
list(JOIN DEPENDS_C_COMPILER_WITH_LAUNCHER " " c_compiler_command)
else()
set(c_compiler_command ${CMAKE_C_COMPILER})
Expand Down
9 changes: 8 additions & 1 deletion depends/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,16 @@ $(host_prefix)/share/config.site : config.site.in $(host_prefix)/.stamp_$(final_
$< > $@
touch $@

ifeq ($(host),$(build))
crosscompiling=FALSE
else
crosscompiling=TRUE
endif

$(host_prefix)/share/toolchain.cmake : toolchain.cmake.in $(host_prefix)/.stamp_$(final_build_id)
@mkdir -p $(@D)
sed -e 's|@host_system@|$($(host_os)_cmake_system)|' \
sed -e 's|@depends_crosscompiling@|$(crosscompiling)|' \
-e 's|@host_system@|$($(host_os)_cmake_system)|' \
-e 's|@host_arch@|$(host_arch)|' \
-e 's|@CC@|$(host_CC)|' \
-e 's|@CXX@|$(host_CXX)|' \
Expand Down
9 changes: 7 additions & 2 deletions depends/toolchain.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@

# This file is expected to be highly volatile and may still change substantially.

set(CMAKE_SYSTEM_NAME @host_system@)
set(CMAKE_SYSTEM_PROCESSOR @host_arch@)
set(BITCOIN_BUILD_WITH_DEPENDS TRUE)

set(DEPENDS_CROSSCOMPILING @depends_crosscompiling@)
if(DEPENDS_CROSSCOMPILING)
set(CMAKE_SYSTEM_NAME @host_system@)
set(CMAKE_SYSTEM_PROCESSOR @host_arch@)
endif()

function(split_compiler_launcher env_compiler launcher compiler)
set(${launcher})
Expand Down
2 changes: 1 addition & 1 deletion src/qt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ if(BUILD_GUI_TESTS)
list(APPEND qt_components Test)
endif()

if(CMAKE_CROSSCOMPILING)
if(BITCOIN_BUILD_WITH_DEPENDS)
# The find_package(Qt ...) function internally uses find_library()
# calls for all dependencies to ensure their availability.
# In turn, the find_library() inspects the well-known locations
Expand Down

0 comments on commit 5c50fe9

Please sign in to comment.