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 316ac13
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions scripts/cmake/vcpkg_configure_make.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,11 @@ 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)
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)
# (--host activates crosscompilation; The name given here is just the prefix of the host tools for the target)
if (VCPKG_DETECTED_CMAKE_C_COMPILER_TARGET)
set(arg_BUILD_TRIPLET "--host=${VCPKG_DETECTED_CMAKE_C_COMPILER_TARGET}")
elseif(VCPKG_DETECTED_CMAKE_C_COMPILER MATCHES "([^\/]*)-gcc$" AND CMAKE_MATCH_1)
set(arg_BUILD_TRIPLET "--host=${CMAKE_MATCH_1}")
endif()
debug_message("Using make triplet: ${arg_BUILD_TRIPLET}")
endif()
Expand Down

0 comments on commit 316ac13

Please sign in to comment.