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 26, 2024
1 parent 8078427 commit e351106
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 @@ -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})
Expand Down
2 changes: 1 addition & 1 deletion cmake/module/CrossPkgConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
2 changes: 1 addition & 1 deletion cmake/module/Maintenance.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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})
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 e351106

Please sign in to comment.