Skip to content

Commit

Permalink
configure_make: use CMAKE_C_COMPILER_TARGET to detect cross-compilation
Browse files Browse the repository at this point in the history
Currently, the only way to cross-compile using vcpkg_configure_make is
to use a gcc cross toolchain with the target as the prefix.

This is not how you cross compile with clang--with clang you set
CMAKE_<LANG>_COMPILER_TARGET. This detects this from the toolchain file
and passes it along
  • Loading branch information
russelltg committed Oct 19, 2024
1 parent 63b6722 commit 64a9e9a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions scripts/cmake/vcpkg_configure_make.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,9 @@ function(vcpkg_configure_make)
# This is used via --host as a prefix for all other bin tools as well.
# Setting the compiler directly via CC=arm-linux-gnueabihf-gcc does not work acording to:
# https://www.gnu.org/software/autoconf/manual/autoconf-2.65/html_node/Specifying-Target-Triplets.html
if(VCPKG_DETECTED_CMAKE_C_COMPILER MATCHES "([^\/]*)-gcc$" AND CMAKE_MATCH_1)
if (VCPKG_DETECTED_CMAKE_C_COMPILER_TARGET)
set(arg_BUILD_TRIPLET "--host=${VCPKG_DETECTED_CMAKE_C_COMPILER_TARGET}") # (Host activates crosscompilation; The name given here is just the prefix of the host tools for the target)
elseif(VCPKG_DETECTED_CMAKE_C_COMPILER MATCHES "([^\/]*)-gcc$" AND CMAKE_MATCH_1)
set(arg_BUILD_TRIPLET "--host=${CMAKE_MATCH_1}") # (Host activates crosscompilation; The name given here is just the prefix of the host tools for the target)
endif()
debug_message("Using make triplet: ${arg_BUILD_TRIPLET}")
Expand Down Expand Up @@ -441,7 +443,7 @@ function(vcpkg_configure_make)
# Remove full filepaths due to spaces and prepend filepaths to PATH (cross-compiling tools are unlikely on path by default)
set(progs VCPKG_DETECTED_CMAKE_C_COMPILER VCPKG_DETECTED_CMAKE_CXX_COMPILER VCPKG_DETECTED_CMAKE_AR
VCPKG_DETECTED_CMAKE_LINKER VCPKG_DETECTED_CMAKE_RANLIB VCPKG_DETECTED_CMAKE_OBJDUMP
VCPKG_DETECTED_CMAKE_STRIP VCPKG_DETECTED_CMAKE_NM VCPKG_DETECTED_CMAKE_DLLTOOL VCPKG_DETECTED_CMAKE_RC_COMPILER)
VCPKG_DETECTED_CMAKE_STRIP VCPKG_DETECTED_CMAKE_NM VCPKG_DETECTED_CMAKE_DLLTOOL VCPKG_DETECTED_CMAKE_RC_COMPILER VCPKG_DETECTED_CMAKE_C_COMPILER_TARGET)
foreach(prog IN LISTS progs)
set(filepath "${${prog}}")
if(filepath MATCHES " ")
Expand Down

0 comments on commit 64a9e9a

Please sign in to comment.