diff --git a/CMakeLists.txt b/CMakeLists.txt index f07a159e34fae..354911775117a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 "$<$:${DEPENDS_C_COMPILER_FLAGS}>") target_compile_options(core_base_interface INTERFACE "$<$:${DEPENDS_CXX_COMPILER_FLAGS}>") diff --git a/cmake/module/CrossPkgConfig.cmake b/cmake/module/CrossPkgConfig.cmake index cbd6f3c27b288..fba6ac80a697e 100644 --- a/cmake/module/CrossPkgConfig.cmake +++ b/cmake/module/CrossPkgConfig.cmake @@ -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}) diff --git a/cmake/module/Maintenance.cmake b/cmake/module/Maintenance.cmake index 9bef503f3a727..c9e090adcd0e5 100644 --- a/cmake/module/Maintenance.cmake +++ b/cmake/module/Maintenance.cmake @@ -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}) diff --git a/depends/Makefile b/depends/Makefile index ab91b5b72a317..062cb0f5635b3 100644 --- a/depends/Makefile +++ b/depends/Makefile @@ -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)|' \ diff --git a/depends/toolchain.cmake.in b/depends/toolchain.cmake.in index a8ef8f6264a9e..ca893b0afc33d 100644 --- a/depends/toolchain.cmake.in +++ b/depends/toolchain.cmake.in @@ -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}) diff --git a/src/qt/CMakeLists.txt b/src/qt/CMakeLists.txt index 45b8b50da2334..787e32fb570e4 100644 --- a/src/qt/CMakeLists.txt +++ b/src/qt/CMakeLists.txt @@ -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