diff --git a/CMakeLists.txt b/CMakeLists.txt index 75f7e70e59e44..26f3cab8e2b7a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -483,7 +483,7 @@ else() ) endif() -if(CMAKE_CROSSCOMPILING) +if(BITCOIN_BUILD_WITH_DEPENDS) target_compile_definitions(core_base_interface INTERFACE ${DEPENDS_COMPILE_DEFINITIONS}) target_compile_definitions(core_depends_release_interface INTERFACE ${DEPENDS_COMPILE_DEFINITIONS_RELWITHDEBINFO}) target_compile_definitions(core_depends_debug_interface INTERFACE ${DEPENDS_COMPILE_DEFINITIONS_DEBUG}) diff --git a/cmake/module/CrossPkgConfig.cmake b/cmake/module/CrossPkgConfig.cmake index 33929fd1048ea..d1ab3ff24e44c 100644 --- a/cmake/module/CrossPkgConfig.cmake +++ b/cmake/module/CrossPkgConfig.cmake @@ -5,7 +5,7 @@ find_package(PkgConfig REQUIRED) 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 b552e408658dd..b270c83c229a7 100644 --- a/cmake/module/Maintenance.cmake +++ b/cmake/module/Maintenance.cmake @@ -30,7 +30,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 f75a1822c045a..b3308596eca12 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 9ff2bbeb51e12..2ab926c94538f 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