Skip to content

Commit

Permalink
Move changes to versioned port
Browse files Browse the repository at this point in the history
  • Loading branch information
Krzmbrzl committed Feb 8, 2025
1 parent e58a50d commit 94eba20
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 39 deletions.
41 changes: 38 additions & 3 deletions ports/vcpkg-make/vcpkg_make.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ endfunction()

function(z_vcpkg_make_get_configure_triplets out)
cmake_parse_arguments(PARSE_ARGV 1 arg
""
"COMPILER_NAME"
"AVOID_BUILD_TRIPLET"
"COMPILER_NAME;CONFIG_DIR"
""
)
z_vcpkg_unparsed_args(FATAL_ERROR)
Expand All @@ -140,7 +140,7 @@ function(z_vcpkg_make_get_configure_triplets out)
set(build_triplet_opt "--build=${BUILD_ARCH}-pc-mingw32")
endif()

set(host_triplet "")
set(host_triplet_opt "")
if(VCPKG_CROSSCOMPILING)
if(VCPKG_TARGET_IS_WINDOWS)
if(NOT TARGET_ARCH MATCHES "${BUILD_ARCH}" OR NOT CMAKE_HOST_WIN32)
Expand All @@ -158,6 +158,41 @@ function(z_vcpkg_make_get_configure_triplets out)
endif()
endif()

if (host_triplet_opt AND NOT build_triplet_opt AND NOT arg_AVOID_BUILD_TRIPLET)
# According to the autoconf manual, when specifying --host, one should always also specify
# --build. It is mentioned that this was due to historic reasons and that it will be fixed
# in some future version but for now, we should do exactly as recommended.
if (arg_CONFIG_DIR)
cmake_path(ABSOLUTE_PATH "config.guess" BASE_DIRECTORY "${arg_CONFIG_DIR}" OUTPUT_VARIABLE config_guess_file)
endif()

if (EXISTS "${config_guess_file}")
if (CMAKE_HOST_WIN32)
vcpkg_execute_required_process(
COMMAND ${base_cmd} -c "${config_guess_file}"
LOGNAME "config.guess-${TARGET_TRIPLET}"
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE BUILD_TRIPLET
)
else()
vcpkg_execute_required_process(
COMMAND "${config_guess_file}"
LOGNAME "config.guess-${TARGET_TRIPLET}"
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE BUILD_TRIPLET
)
endif()

set(build_triplet_opt "--build=${BUILD_TRIPLET}")
elseif (VCPKG_HOST_IS_WINDOWS)
set(build_triplet_opt "--build=${BUILD_ARCH}-pc-mingw32")
elseif (VCPKG_HOST_IS_LINUX)
set(build_triplet_opt "--build=${BUILD_ARCH}-pc-linux")
elseif (VCPKG_HOST_IS_IOS OR VCPKG_HOST_IS_OSX)
set(build_triplet_opt "--build=${BUILD_ARCH}-apple-darwin")
endif()
endif()

set(output "${build_triplet_opt};${host_triplet_opt}")
string(STRIP "${output}" output)
set("${out}" "${output}" PARENT_SCOPE)
Expand Down
7 changes: 4 additions & 3 deletions ports/vcpkg-make/vcpkg_make_configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ function(vcpkg_make_configure)
if(DEFINED VCPKG_MAKE_BUILD_TRIPLET)
set(BUILD_TRIPLET "${VCPKG_MAKE_BUILD_TRIPLET}")
endif()
if(NOT DEFINED BUILD_TRIPLET)
z_vcpkg_make_get_configure_triplets(BUILD_TRIPLET COMPILER_NAME "${ccname}")
endif()

if(NOT arg_DISABLE_MSVC_WRAPPERS AND "${frontend}" STREQUAL "MSVC" )
# Lets assume that wrappers are only required for MSVC like frontends.
Expand Down Expand Up @@ -92,6 +89,10 @@ function(vcpkg_make_configure)
set(relative_build_path ".")
endif()

if(NOT DEFINED BUILD_TRIPLET)
z_vcpkg_make_get_configure_triplets(BUILD_TRIPLET COMPILER_NAME "${ccname}" CONFIG_DIR "${target_dir}")
endif()

z_vcpkg_make_prepare_programs(configure_env ${prepare_flags_opts} CONFIG "${configup}" BUILD_TRIPLET "${BUILD_TRIPLET}")

set(opts "")
Expand Down
33 changes: 0 additions & 33 deletions scripts/cmake/vcpkg_configure_make.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -754,39 +754,6 @@ function(vcpkg_configure_make)
message(STATUS "Finished generating configure for ${TARGET_TRIPLET}")
endif()

if ((arg_BUILD_TRIPLET MATCHES "--host") AND NOT (arg_BUILD_TRIPLET MATCHES "--build"))
# --host option specified but --build has been left out. According to the autoconf manual,
# whenever --host is set, --build must be too (for historical reasons).
# See https://www.gnu.org/software/autoconf/manual/autoconf-2.65/html_node/Specifying-Target-Triplets.html
# -> Use config.guess to determine build triplet
if (EXISTS "config.guess")
if (CMAKE_HOST_WIN32)
vcpkg_execute_required_process(
COMMAND ${base_cmd} -c "./config.guess"
WORKING_DIRECTORY "${src_dir}"
LOGNAME "config.guess-${TARGET_TRIPLET}"
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE BUILD_TRIPLET
)
else()
vcpkg_execute_required_process(
COMMAND "./config.guess"
WORKING_DIRECTORY "${src_dir}"
LOGNAME "config.guess-${TARGET_TRIPLET}"
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE BUILD_TRIPLET
)
endif()

string(APPEND arg_BUILD_TRIPLET " --build=${BUILD_TRIPLET}")
else()
# For the time being we'll assume that for projects that don't have a config.guess
# file, target triplets aren't that important and hence we can get away with not
# defining --build in addition to --host
debug_message("vcpkg will run configure with the --host option but without --build, which may cause issues")
endif()
endif()

if (arg_PRERUN_SHELL)
message(STATUS "Prerun shell with ${TARGET_TRIPLET}")
if (CMAKE_HOST_WIN32)
Expand Down

0 comments on commit 94eba20

Please sign in to comment.