diff --git a/CMakeLists.txt b/CMakeLists.txt index 3914bc7f6134e..3a8321ba5891e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -509,22 +509,20 @@ else() ) endif() -if(CMAKE_CROSSCOMPILING) - 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}) - - # If {C,CXX}FLAGS variables are defined during building depends and - # configuring this build system, their content might be duplicated. - if(DEFINED ENV{CFLAGS}) - deduplicate_flags(CMAKE_C_FLAGS) - endif() - if(DEFINED ENV{CXXFLAGS}) - deduplicate_flags(CMAKE_CXX_FLAGS) - endif() - if(DEFINED ENV{LDFLAGS}) - deduplicate_flags(CMAKE_EXE_LINKER_FLAGS) - endif() +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}) + +# If {C,CXX,LD}FLAGS variables are defined during building depends and +# configuring this build system, their content might be duplicated. +if(DEFINED ENV{CFLAGS}) + deduplicate_flags(CMAKE_C_FLAGS) +endif() +if(DEFINED ENV{CXXFLAGS}) + deduplicate_flags(CMAKE_CXX_FLAGS) +endif() +if(DEFINED ENV{LDFLAGS}) + deduplicate_flags(CMAKE_EXE_LINKER_FLAGS) endif() add_subdirectory(src) diff --git a/cmake/module/Maintenance.cmake b/cmake/module/Maintenance.cmake index 57307d6cd1979..d2bede5ce33d4 100644 --- a/cmake/module/Maintenance.cmake +++ b/cmake/module/Maintenance.cmake @@ -30,11 +30,7 @@ function(add_maintenance_targets) else() set(exe_format ELF) endif() - if(CMAKE_CROSSCOMPILING) - list(JOIN DEPENDS_C_COMPILER_WITH_LAUNCHER " " c_compiler_command) - else() - set(c_compiler_command ${CMAKE_C_COMPILER}) - endif() + set(c_compiler_command "${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1}") add_custom_target(test-security-check COMMAND ${CMAKE_COMMAND} -E env CC=${c_compiler_command} CFLAGS=${CMAKE_C_FLAGS} LDFLAGS=${CMAKE_EXE_LINKER_FLAGS} ${PYTHON_COMMAND} ${CMAKE_SOURCE_DIR}/contrib/devtools/test-security-check.py TestSecurityChecks.test_${exe_format} COMMAND ${CMAKE_COMMAND} -E env CC=${c_compiler_command} CFLAGS=${CMAKE_C_FLAGS} LDFLAGS=${CMAKE_EXE_LINKER_FLAGS} ${PYTHON_COMMAND} ${CMAKE_SOURCE_DIR}/contrib/devtools/test-symbol-check.py TestSymbolChecks.test_${exe_format} @@ -111,7 +107,20 @@ function(add_macos_deploy_target) ) string(REPLACE " " "-" osx_volname ${PACKAGE_NAME}) - if(CMAKE_CROSSCOMPILING) + if(CMAKE_HOST_APPLE) + add_custom_command( + OUTPUT ${CMAKE_BINARY_DIR}/${osx_volname}.zip + COMMAND ${PYTHON_COMMAND} ${CMAKE_SOURCE_DIR}/contrib/macdeploy/macdeployqtplus ${macos_app} ${osx_volname} -translations-dir=${QT_TRANSLATIONS_DIR} -zip + DEPENDS ${CMAKE_BINARY_DIR}/${macos_app}/Contents/MacOS/Bitcoin-Qt + VERBATIM + ) + add_custom_target(deploydir + DEPENDS ${CMAKE_BINARY_DIR}/${osx_volname}.zip + ) + add_custom_target(deploy + DEPENDS ${CMAKE_BINARY_DIR}/${osx_volname}.zip + ) + else() add_custom_command( OUTPUT ${CMAKE_BINARY_DIR}/dist/${macos_app}/Contents/MacOS/Bitcoin-Qt COMMAND INSTALL_NAME_TOOL=${CMAKE_INSTALL_NAME_TOOL} OTOOL=${OTOOL} STRIP=${CMAKE_STRIP} ${PYTHON_COMMAND} ${CMAKE_SOURCE_DIR}/contrib/macdeploy/macdeployqtplus ${macos_app} ${osx_volname} -translations-dir=${QT_TRANSLATIONS_DIR} @@ -133,19 +142,6 @@ function(add_macos_deploy_target) DEPENDS ${CMAKE_BINARY_DIR}/dist/${osx_volname}.zip ) add_dependencies(deploy deploydir) - else() - add_custom_command( - OUTPUT ${CMAKE_BINARY_DIR}/${osx_volname}.zip - COMMAND ${PYTHON_COMMAND} ${CMAKE_SOURCE_DIR}/contrib/macdeploy/macdeployqtplus ${macos_app} ${osx_volname} -translations-dir=${QT_TRANSLATIONS_DIR} -zip - DEPENDS ${CMAKE_BINARY_DIR}/${macos_app}/Contents/MacOS/Bitcoin-Qt - VERBATIM - ) - add_custom_target(deploydir - DEPENDS ${CMAKE_BINARY_DIR}/${osx_volname}.zip - ) - add_custom_target(deploy - DEPENDS ${CMAKE_BINARY_DIR}/${osx_volname}.zip - ) endif() endif() endfunction() diff --git a/depends/Makefile b/depends/Makefile index 50825d8d5d9f3..0ffc3bfaad642 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)/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 1cfa3fd91a6ab..50c46880386d1 100644 --- a/depends/toolchain.cmake.in +++ b/depends/toolchain.cmake.in @@ -4,8 +4,10 @@ # 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@) +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})