2021-10-21 05:12:58 +08:00
macro ( z_vcpkg_determine_autotools_host_cpu out_var )
2021-05-01 02:26:05 +08:00
# TODO: the host system processor architecture can differ from the host triplet target architecture
2020-11-11 01:52:02 +08:00
if ( DEFINED ENV{PROCESSOR_ARCHITEW6432} )
2021-10-21 05:12:58 +08:00
set ( host_arch $ENV{ PROCESSOR_ARCHITEW6432 } )
2021-05-01 02:26:05 +08:00
elseif ( DEFINED ENV{PROCESSOR_ARCHITECTURE} )
2021-10-21 05:12:58 +08:00
set ( host_arch $ENV{ PROCESSOR_ARCHITECTURE } )
2021-05-01 02:26:05 +08:00
else ( )
2021-10-21 05:12:58 +08:00
set ( host_arch "${VCPKG_DETECTED_CMAKE_HOST_SYSTEM_PROCESSOR}" )
2020-11-11 01:52:02 +08:00
endif ( )
2021-10-21 05:12:58 +08:00
if ( host_arch MATCHES "(amd|AMD)64" )
2020-11-11 01:52:02 +08:00
set ( ${ out_var } x86_64 )
2021-10-21 05:12:58 +08:00
elseif ( host_arch MATCHES "(x|X)86" )
2020-11-11 01:52:02 +08:00
set ( ${ out_var } i686 )
2021-10-21 05:12:58 +08:00
elseif ( host_arch MATCHES "^(ARM|arm)64$" )
2020-11-11 01:52:02 +08:00
set ( ${ out_var } aarch64 )
2021-10-21 05:12:58 +08:00
elseif ( host_arch MATCHES "^(ARM|arm)$" )
2020-11-11 01:52:02 +08:00
set ( ${ out_var } arm )
else ( )
2021-10-21 05:12:58 +08:00
message ( FATAL_ERROR "Unsupported host architecture ${host_arch} in z_vcpkg_determine_autotools_host_cpu!" )
2020-11-11 01:52:02 +08:00
endif ( )
2021-10-21 05:12:58 +08:00
unset ( host_arch )
2020-11-11 01:52:02 +08:00
endmacro ( )
2021-10-21 05:12:58 +08:00
macro ( z_vcpkg_determine_autotools_target_cpu out_var )
2020-11-11 01:52:02 +08:00
if ( VCPKG_TARGET_ARCHITECTURE MATCHES "(x|X)64" )
set ( ${ out_var } x86_64 )
elseif ( VCPKG_TARGET_ARCHITECTURE MATCHES "(x|X)86" )
set ( ${ out_var } i686 )
elseif ( VCPKG_TARGET_ARCHITECTURE MATCHES "^(ARM|arm)64$" )
set ( ${ out_var } aarch64 )
elseif ( VCPKG_TARGET_ARCHITECTURE MATCHES "^(ARM|arm)$" )
set ( ${ out_var } arm )
else ( )
2021-10-21 05:12:58 +08:00
message ( FATAL_ERROR "Unsupported VCPKG_TARGET_ARCHITECTURE architecture ${VCPKG_TARGET_ARCHITECTURE} in z_vcpkg_determine_autotools_target_cpu!" )
2020-11-11 01:52:02 +08:00
endif ( )
endmacro ( )
2023-04-20 05:35:20 +08:00
macro ( z_vcpkg_set_arch_mac out_var value )
# Better match the arch behavior of config.guess
# See: https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
if ( "${value}" MATCHES "^(ARM|arm)64$" )
set ( ${ out_var } "aarch64" )
else ( )
set ( ${ out_var } "${value}" )
endif ( )
endmacro ( )
2021-10-21 05:12:58 +08:00
macro ( z_vcpkg_determine_autotools_host_arch_mac out_var )
2023-04-20 05:35:20 +08:00
z_vcpkg_set_arch_mac ( ${ out_var } "${VCPKG_DETECTED_CMAKE_HOST_SYSTEM_PROCESSOR}" )
2021-01-29 11:38:32 +08:00
endmacro ( )
2021-10-21 05:12:58 +08:00
macro ( z_vcpkg_determine_autotools_target_arch_mac out_var )
list ( LENGTH VCPKG_OSX_ARCHITECTURES osx_archs_num )
if ( osx_archs_num EQUAL 0 )
2023-04-20 05:35:20 +08:00
z_vcpkg_set_arch_mac ( ${ out_var } "${VCPKG_DETECTED_CMAKE_HOST_SYSTEM_PROCESSOR}" )
2021-10-21 05:12:58 +08:00
elseif ( osx_archs_num GREATER_EQUAL 2 )
2021-01-29 11:38:32 +08:00
set ( ${ out_var } "universal" )
else ( )
2023-04-20 05:35:20 +08:00
z_vcpkg_set_arch_mac ( ${ out_var } "${VCPKG_OSX_ARCHITECTURES}" )
2021-01-29 11:38:32 +08:00
endif ( )
2021-10-21 05:12:58 +08:00
unset ( osx_archs_num )
2021-01-29 11:38:32 +08:00
endmacro ( )
2021-10-21 05:12:58 +08:00
macro ( z_vcpkg_extract_cpp_flags_and_set_cflags_and_cxxflags flag_suffix )
2022-10-14 00:40:52 +08:00
string ( REGEX MATCHALL "( |^)(-D|-isysroot|--sysroot=|-isystem|-m?[Aa][Rr][Cc][Hh]|--target=|-target) ?[^ ]+" CPPFLAGS_ ${ flag_suffix } "${VCPKG_DETECTED_CMAKE_C_FLAGS_${flag_suffix}}" )
string ( REGEX MATCHALL "( |^)(-D|-isysroot|--sysroot=|-isystem|-m?[Aa][Rr][Cc][Hh]|--target=|-target) ?[^ ]+" CXXPPFLAGS_ ${ flag_suffix } "${VCPKG_DETECTED_CMAKE_CXX_FLAGS_${flag_suffix}}" )
2021-10-21 05:12:58 +08:00
list ( JOIN CXXPPFLAGS_ ${ flag_suffix } "|" CXXREGEX )
if ( CXXREGEX )
list ( FILTER CPPFLAGS_ ${ flag_suffix } INCLUDE REGEX "(${CXXREGEX})" )
2020-11-11 01:52:02 +08:00
else ( )
2021-10-21 05:12:58 +08:00
set ( CPPFLAGS_ ${ flag_suffix } )
2020-11-11 01:52:02 +08:00
endif ( )
2021-10-21 05:12:58 +08:00
list ( JOIN CPPFLAGS_ ${ flag_suffix } "|" CPPREGEX )
list ( JOIN CPPFLAGS_ ${ flag_suffix } " " CPPFLAGS_ ${ flag_suffix } )
set ( CPPFLAGS_ ${ flag_suffix } "${CPPFLAGS_${flag_suffix}}" )
if ( CPPREGEX )
string ( REGEX REPLACE "(${CPPREGEX})" "" CFLAGS_ ${ flag_suffix } "${VCPKG_DETECTED_CMAKE_C_FLAGS_${flag_suffix}}" )
string ( REGEX REPLACE "(${CPPREGEX})" "" CXXFLAGS_ ${ flag_suffix } "${VCPKG_DETECTED_CMAKE_CXX_FLAGS_${flag_suffix}}" )
2020-11-11 01:52:02 +08:00
else ( )
2021-10-21 05:12:58 +08:00
set ( CFLAGS_ ${ flag_suffix } "${VCPKG_DETECTED_CMAKE_C_FLAGS_${flag_suffix}}" )
set ( CXXFLAGS_ ${ flag_suffix } "${VCPKG_DETECTED_CMAKE_CXX_FLAGS_${flag_suffix}}" )
2020-11-11 01:52:02 +08:00
endif ( )
2021-10-21 05:12:58 +08:00
string ( REGEX REPLACE " +" " " CPPFLAGS_ ${ flag_suffix } "${CPPFLAGS_${flag_suffix}}" )
string ( REGEX REPLACE " +" " " CFLAGS_ ${ flag_suffix } "${CFLAGS_${flag_suffix}}" )
string ( REGEX REPLACE " +" " " CXXFLAGS_ ${ flag_suffix } "${CXXFLAGS_${flag_suffix}}" )
string ( STRIP "${CPPFLAGS_${flag_suffix}}" CPPFLAGS_ ${ flag_suffix } )
string ( STRIP "${CFLAGS_${flag_suffix}}" CFLAGS_ ${ flag_suffix } )
string ( STRIP "${CXXFLAGS_${flag_suffix}}" CXXFLAGS_ ${ flag_suffix } )
2023-01-07 17:04:32 +08:00
# libtool tries to filter CFLAGS passed to the link stage via a whitelist.
# that approach is flawed since it fails to pass flags unknown to libtool
# but required for linking to the link stage (e.g. -fsanitize=<x>).
# libtool has an -R option so we need to guard against -RTC by using -Xcompiler
# while configuring there might be a lot of unknown compiler option warnings due to that
# just ignore them.
if ( VCPKG_DETECTED_CMAKE_C_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC" OR VCPKG_DETECTED_CMAKE_C_COMPILER_ID STREQUAL "MSVC" )
separate_arguments ( CFLAGS_LIST NATIVE_COMMAND "${CFLAGS_${flag_suffix}}" )
list ( JOIN CFLAGS_LIST " -Xcompiler " CFLAGS_ ${ var_suffix } )
string ( PREPEND CFLAGS_ ${ var_suffix } "-Xcompiler " )
endif ( )
if ( VCPKG_DETECTED_CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC" OR VCPKG_DETECTED_CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" )
separate_arguments ( CXXFLAGS_LIST NATIVE_COMMAND "${CXXFLAGS_${flag_suffix}}" )
list ( JOIN CXXFLAGS_LIST " -Xcompiler " CXXFLAGS_ ${ var_suffix } )
string ( PREPEND CXXFLAGS_ ${ var_suffix } "-Xcompiler " )
endif ( )
2021-10-21 05:12:58 +08:00
debug_message ( "CPPFLAGS_${flag_suffix}: ${CPPFLAGS_${flag_suffix}}" )
debug_message ( "CFLAGS_${flag_suffix}: ${CFLAGS_${flag_suffix}}" )
debug_message ( "CXXFLAGS_${flag_suffix}: ${CXXFLAGS_${flag_suffix}}" )
2020-11-11 01:52:02 +08:00
endmacro ( )
2021-10-21 05:12:58 +08:00
macro ( z_vcpkg_append_to_configure_environment inoutstring var defaultval )
# Allows to overwrite settings in custom triplets via the environment on windows
if ( CMAKE_HOST_WIN32 AND DEFINED ENV{ ${ var } } )
string ( APPEND ${ inoutstring } " ${var}='$ENV{${var}}'" )
2020-11-11 01:52:02 +08:00
else ( )
2021-10-21 05:12:58 +08:00
string ( APPEND ${ inoutstring } " ${var}='${defaultval}'" )
2020-11-11 01:52:02 +08:00
endif ( )
2021-10-21 05:12:58 +08:00
endmacro ( )
macro ( z_convert_to_list input output )
string ( REGEX MATCHALL "(( +|^ *)[^ ]+)" ${ output } "${${input}}" )
2020-11-11 01:52:02 +08:00
endmacro ( )
function ( vcpkg_configure_make )
2020-12-02 05:37:26 +08:00
# parse parameters such that semicolons in options arguments to COMMAND don't get erased
2021-10-21 05:12:58 +08:00
cmake_parse_arguments ( PARSE_ARGV 0 arg
2022-08-20 06:13:23 +08:00
" A U T O C O N F I G ; S K I P _ C O N F I G U R E ; C O P Y _ S O U R C E ; D I S A B L E _ V E R B O S E _ F L A G S ; N O _ A D D I T I O N A L _ P A T H S ; A D D _ B I N _ T O _ P A T H ; N O _ D E B U G ; U S E _ W R A P P E R S ; N O _ W R A P P E R S ; D E T E R M I N E _ B U I L D _ T R I P L E T "
2020-11-11 01:52:02 +08:00
" S O U R C E _ P A T H ; P R O J E C T _ S U B P A T H ; P R E R U N _ S H E L L ; B U I L D _ T R I P L E T "
2020-11-18 01:18:59 +08:00
" O P T I O N S ; O P T I O N S _ D E B U G ; O P T I O N S _ R E L E A S E ; C O N F I G U R E _ E N V I R O N M E N T _ V A R I A B L E S ; C O N F I G _ D E P E N D E N T _ E N V I R O N M E N T ; A D D I T I O N A L _ M S Y S _ P A C K A G E S "
2020-11-11 01:52:02 +08:00
)
2021-10-21 05:12:58 +08:00
2022-03-03 05:43:19 +08:00
if ( DEFINED arg_UNPARSED_ARGUMENTS )
message ( WARNING "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}" )
endif ( )
2022-08-20 06:13:23 +08:00
if ( arg_USE_WRAPPERS AND arg_NO_WRAPPERS )
message ( FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} was passed conflicting options USE_WRAPPERS and NO_WRAPPERS. Please remove one of them!" )
endif ( )
2021-07-30 00:47:35 +08:00
z_vcpkg_get_cmake_vars ( cmake_vars_file )
debug_message ( "Including cmake vars from: ${cmake_vars_file}" )
include ( "${cmake_vars_file}" )
2022-04-28 09:12:48 +08:00
2023-03-15 05:11:06 +08:00
# Remove outer quotes from cmake variables which will be forwarded via makefile/shell variables
# substituted into makefile commands (e.g. Android NDK has "--sysroot=...")
foreach ( var IN ITEMS VCPKG_DETECTED_CMAKE_C_FLAGS_DEBUG
V C P K G _ D E T E C T E D _ C M A K E _ C _ F L A G S _ R E L E A S E
V C P K G _ D E T E C T E D _ C M A K E _ C X X _ F L A G S _ D E B U G
V C P K G _ D E T E C T E D _ C M A K E _ C X X _ F L A G S _ R E L E A S E
V C P K G _ D E T E C T E D _ C M A K E _ S H A R E D _ L I N K E R _ F L A G S _ D E B U G
V C P K G _ D E T E C T E D _ C M A K E _ S H A R E D _ L I N K E R _ F L A G S _ R E L E A S E
V C P K G _ D E T E C T E D _ C M A K E _ S T A T I C _ L I N K E R _ F L A G S _ D E B U G
V C P K G _ D E T E C T E D _ C M A K E _ S T A T I C _ L I N K E R _ F L A G S _ R E L E A S E
V C P K G _ D E T E C T E D _ C M A K E _ C _ S T A N D A R D _ L I B R A R I E S
V C P K G _ D E T E C T E D _ C M A K E _ C X X _ S T A N D A R D _ L I B R A R I E S
)
separate_arguments ( cmake_list NATIVE_COMMAND "${${var}}" )
list ( JOIN cmake_list " " "${var}" )
endforeach ( )
2020-11-11 01:52:02 +08:00
if ( DEFINED VCPKG_MAKE_BUILD_TRIPLET )
2021-10-21 05:12:58 +08:00
set ( arg_BUILD_TRIPLET ${ VCPKG_MAKE_BUILD_TRIPLET } ) # Triplet overwrite for crosscompiling
2020-11-11 01:52:02 +08:00
endif ( )
2021-10-21 05:12:58 +08:00
set ( src_dir "${arg_SOURCE_PATH}/${arg_PROJECT_SUBPATH}" )
2020-11-11 01:52:02 +08:00
2021-10-21 05:12:58 +08:00
set ( requires_autogen OFF ) # use autogen.sh
set ( requires_autoconfig OFF ) # use autotools and configure.ac
2022-08-20 06:13:23 +08:00
if ( EXISTS "${src_dir}/configure" AND EXISTS "${src_dir}/configure.ac" AND arg_AUTOCONFIG ) # remove configure; rerun autoconf
set ( requires_autoconfig ON )
2023-01-07 17:01:31 +08:00
file ( REMOVE "${SRC_DIR}/configure" ) # remove possible outdated configure scripts
2021-10-21 05:12:58 +08:00
elseif ( EXISTS "${src_dir}/configure" AND NOT arg_SKIP_CONFIGURE ) # run normally; no autoconf or autogen required
elseif ( EXISTS "${src_dir}/configure.ac" ) # Run autoconfig
set ( requires_autoconfig ON )
set ( arg_AUTOCONFIG ON )
elseif ( EXISTS "${src_dir}/autogen.sh" ) # Run autogen
set ( requires_autogen ON )
2020-11-11 01:52:02 +08:00
else ( )
message ( FATAL_ERROR "Could not determine method to configure make" )
endif ( )
2021-10-21 05:12:58 +08:00
debug_message ( "requires_autogen:${requires_autogen}" )
debug_message ( "requires_autoconfig:${requires_autoconfig}" )
2021-05-27 04:48:41 +08:00
if ( CMAKE_HOST_WIN32 AND VCPKG_DETECTED_CMAKE_C_COMPILER MATCHES "cl.exe" ) #only applies to windows (clang-)cl and lib
2021-10-21 05:12:58 +08:00
if ( arg_AUTOCONFIG )
set ( arg_USE_WRAPPERS ON )
2021-05-27 04:48:41 +08:00
else ( )
# Keep the setting from portfiles.
# Without autotools we assume a custom configure script which correctly handles cl and lib.
# Otherwise the port needs to set CC|CXX|AR and probably CPP.
endif ( )
else ( )
2021-10-21 05:12:58 +08:00
set ( arg_USE_WRAPPERS OFF )
2021-05-27 04:48:41 +08:00
endif ( )
2022-08-20 06:13:23 +08:00
if ( arg_NO_WRAPPERS )
set ( arg_USE_WRAPPERS OFF )
endif ( )
2021-05-27 04:48:41 +08:00
2020-11-11 01:52:02 +08:00
# Backup environment variables
# CCAS CC C CPP CXX FC FF GC LD LF LIBTOOL OBJC OBJCXX R UPC Y
2022-08-20 06:13:23 +08:00
set ( cm_FLAGS AR AS CCAS CC C CPP CXX FC FF GC LD LF LIBTOOL OBJC OBJXX R UPC Y RC )
2021-10-21 05:12:58 +08:00
list ( TRANSFORM cm_FLAGS APPEND "FLAGS" )
vcpkg_backup_env_variables ( VARS ${ cm_FLAGS } )
2020-11-11 01:52:02 +08:00
# FC fotran compiler | FF Fortran 77 compiler
# LDFLAGS -> pass -L flags
# LIBS -> pass -l flags
#Used by gcc/linux
2021-10-21 05:12:58 +08:00
vcpkg_backup_env_variables ( VARS C_INCLUDE_PATH CPLUS_INCLUDE_PATH LIBRARY_PATH LD_LIBRARY_PATH )
2020-11-11 01:52:02 +08:00
#Used by cl
2021-10-21 05:12:58 +08:00
vcpkg_backup_env_variables ( VARS INCLUDE LIB LIBPATH )
2020-11-11 01:52:02 +08:00
2021-10-21 05:12:58 +08:00
set ( vcm_paths_with_spaces OFF )
2020-11-11 01:52:02 +08:00
if ( CURRENT_PACKAGES_DIR MATCHES " " OR CURRENT_INSTALLED_DIR MATCHES " " )
# Don't bother with whitespace. The tools will probably fail and I tried very hard trying to make it work (no success so far)!
message ( WARNING "Detected whitespace in root directory. Please move the path to one without whitespaces! The required tools do not handle whitespaces correctly and the build will most likely fail" )
2021-10-21 05:12:58 +08:00
set ( vcm_paths_with_spaces ON )
2020-11-11 01:52:02 +08:00
endif ( )
2021-10-21 05:12:58 +08:00
set ( configure_env "V=1" )
2023-02-11 04:02:13 +08:00
2023-03-20 15:04:15 +08:00
# Establish a bash environment as expected by autotools.
if ( CMAKE_HOST_WIN32 )
2023-05-29 14:24:09 +08:00
list ( APPEND msys_require_packages autoconf-wrapper automake-wrapper binutils libtool make pkgconf which )
2023-03-20 15:04:15 +08:00
vcpkg_acquire_msys ( MSYS_ROOT PACKAGES ${ msys_require_packages } ${ arg_ADDITIONAL_MSYS_PACKAGES } )
set ( base_cmd "${MSYS_ROOT}/usr/bin/bash.exe" --noprofile --norc --debug )
vcpkg_list ( SET add_to_env )
if ( arg_USE_WRAPPERS AND VCPKG_TARGET_IS_WINDOWS )
vcpkg_list ( APPEND add_to_env "${SCRIPTS}/buildsystems/make_wrapper" ) # Other required wrappers are also located there
vcpkg_list ( APPEND add_to_env "${MSYS_ROOT}/usr/share/automake-1.16" )
endif ( )
cmake_path ( CONVERT "$ENV{PATH}" TO_CMAKE_PATH_LIST path_list NORMALIZE )
cmake_path ( CONVERT "$ENV{SystemRoot}" TO_CMAKE_PATH_LIST system_root NORMALIZE )
cmake_path ( CONVERT "$ENV{LOCALAPPDATA}" TO_CMAKE_PATH_LIST local_app_data NORMALIZE )
file ( REAL_PATH "${system_root}" system_root )
2023-07-27 02:04:33 +08:00
string ( TOUPPER "${system_root}" system_root_upper )
2023-03-20 15:04:15 +08:00
message ( DEBUG "path_list:${path_list}" ) # Just to have --trace-expand output
vcpkg_list ( SET find_system_dirs
" $ { s y s t e m _ r o o t } / s y s t e m 3 2 "
" $ { s y s t e m _ r o o t } / S y s t e m 3 2 "
" $ { s y s t e m _ r o o t } / s y s t e m 3 2 / "
" $ { s y s t e m _ r o o t } / S y s t e m 3 2 / "
2023-07-27 02:04:33 +08:00
" $ { s y s t e m _ r o o t _ u p p e r } / s y s t e m 3 2 "
" $ { s y s t e m _ r o o t _ u p p e r } / S y s t e m 3 2 "
" $ { s y s t e m _ r o o t _ u p p e r } / s y s t e m 3 2 / "
" $ { s y s t e m _ r o o t _ u p p e r } / S y s t e m 3 2 / "
2023-03-20 15:04:15 +08:00
" $ { l o c a l _ a p p _ d a t a } / M i c r o s o f t / W i n d o w s A p p s "
" $ { l o c a l _ a p p _ d a t a } / M i c r o s o f t / W i n d o w s A p p s / "
)
string ( TOUPPER "${find_system_dirs}" find_system_dirs_upper )
set ( index 0 )
set ( appending TRUE )
foreach ( item IN LISTS path_list )
if ( item IN_LIST find_system_dirs OR item IN_LIST find_system_dirs_upper )
set ( appending FALSE )
break ( )
endif ( )
math ( EXPR index "${index} + 1" )
endforeach ( )
if ( appending )
message ( WARNING "Unable to find system dir in the PATH variable! Appending required msys paths!" )
endif ( )
vcpkg_list ( INSERT path_list "${index}" ${ add_to_env } "${MSYS_ROOT}/usr/bin" )
cmake_path ( CONVERT "${path_list}" TO_NATIVE_PATH_LIST native_path_list )
set ( ENV{PATH} "${native_path_list}" )
else ( )
find_program ( base_cmd bash REQUIRED )
endif ( )
# macOS - cross-compiling support
2023-02-11 04:02:13 +08:00
if ( VCPKG_TARGET_IS_OSX OR VCPKG_TARGET_IS_IOS )
if ( requires_autoconfig AND NOT arg_BUILD_TRIPLET OR arg_DETERMINE_BUILD_TRIPLET )
z_vcpkg_determine_autotools_host_arch_mac ( BUILD_ARCH ) # machine you are building on => --build=
z_vcpkg_determine_autotools_target_arch_mac ( TARGET_ARCH )
# --build: the machine you are building on
# --host: the machine you are building for
# --target: the machine that CC will produce binaries for
# https://stackoverflow.com/questions/21990021/how-to-determine-host-value-for-configure-when-using-cross-compiler
# Only for ports using autotools so we can assume that they follow the common conventions for build/target/host
if ( NOT "${TARGET_ARCH}" STREQUAL "${BUILD_ARCH}" OR NOT VCPKG_TARGET_IS_OSX ) # we don't need to specify the additional flags if we build natively.
set ( arg_BUILD_TRIPLET "--host=${TARGET_ARCH}-apple-darwin" ) # (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}" )
endif ( )
endif ( )
# Linux - cross-compiling support
if ( VCPKG_TARGET_IS_LINUX )
if ( requires_autoconfig AND NOT arg_BUILD_TRIPLET OR arg_DETERMINE_BUILD_TRIPLET )
# The regex below takes the prefix from the resulting CMAKE_C_COMPILER variable eg. arm-linux-gnueabihf-gcc
# set in the common toolchains/linux.cmake
# 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)
endif ( )
debug_message ( "Using make triplet: ${arg_BUILD_TRIPLET}" )
endif ( )
endif ( )
2023-03-20 15:04:15 +08:00
2020-11-11 01:52:02 +08:00
# Pre-processing windows configure requirements
2021-05-01 02:26:05 +08:00
if ( VCPKG_TARGET_IS_WINDOWS )
2021-11-04 12:29:29 +08:00
if ( arg_DETERMINE_BUILD_TRIPLET OR NOT arg_BUILD_TRIPLET )
2021-10-21 05:12:58 +08:00
z_vcpkg_determine_autotools_host_cpu ( BUILD_ARCH ) # VCPKG_HOST => machine you are building on => --build=
z_vcpkg_determine_autotools_target_cpu ( TARGET_ARCH )
2020-11-11 01:52:02 +08:00
# --build: the machine you are building on
# --host: the machine you are building for
# --target: the machine that CC will produce binaries for
# https://stackoverflow.com/questions/21990021/how-to-determine-host-value-for-configure-when-using-cross-compiler
# Only for ports using autotools so we can assume that they follow the common conventions for build/target/host
2021-05-01 02:26:05 +08:00
if ( CMAKE_HOST_WIN32 )
2023-01-07 17:01:31 +08:00
# Respect host triplet when determining --build
if ( NOT VCPKG_CROSSCOMPILING )
set ( _win32_build_arch "${TARGET_ARCH}" )
else ( )
set ( _win32_build_arch "${BUILD_ARCH}" )
endif ( )
# This is required since we are running in a msys
# shell which will be otherwise identified as ${BUILD_ARCH}-pc-msys
set ( arg_BUILD_TRIPLET "--build=${_win32_build_arch}-pc-mingw32" )
2021-05-01 02:26:05 +08:00
endif ( )
if ( NOT TARGET_ARCH MATCHES "${BUILD_ARCH}" OR NOT CMAKE_HOST_WIN32 ) # we don't need to specify the additional flags if we build nativly, this does not hold when we are not on windows
2021-10-21 05:12:58 +08:00
string ( APPEND arg_BUILD_TRIPLET " --host=${TARGET_ARCH}-pc-mingw32" ) # (Host activates crosscompilation; The name given here is just the prefix of the host tools for the target)
2020-11-11 01:52:02 +08:00
endif ( )
2021-10-21 05:12:58 +08:00
if ( VCPKG_TARGET_IS_UWP AND NOT arg_BUILD_TRIPLET MATCHES "--host" )
2020-11-11 01:52:02 +08:00
# Needs to be different from --build to enable cross builds.
2021-10-21 05:12:58 +08:00
string ( APPEND arg_BUILD_TRIPLET " --host=${TARGET_ARCH}-unknown-mingw32" )
2020-11-11 01:52:02 +08:00
endif ( )
2021-10-21 05:12:58 +08:00
debug_message ( "Using make triplet: ${arg_BUILD_TRIPLET}" )
2020-11-11 01:52:02 +08:00
endif ( )
2021-04-08 03:41:56 +08:00
# Remove full filepaths due to spaces and prepend filepaths to PATH (cross-compiling tools are unlikely on path by default)
2020-11-11 01:52:02 +08:00
set ( progs VCPKG_DETECTED_CMAKE_C_COMPILER VCPKG_DETECTED_CMAKE_CXX_COMPILER VCPKG_DETECTED_CMAKE_AR
V C P K G _ D E T E C T E D _ C M A K E _ L I N K E R V C P K G _ D E T E C T E D _ C M A K E _ R A N L I B V C P K G _ D E T E C T E D _ C M A K E _ O B J D U M P
V C P K G _ D E T E C T E D _ C M A K E _ S T R I P V C P K G _ D E T E C T E D _ C M A K E _ N M V C P K G _ D E T E C T E D _ C M A K E _ D L L T O O L V C P K G _ D E T E C T E D _ C M A K E _ R C _ C O M P I L E R )
foreach ( prog IN LISTS progs )
if ( ${ prog } )
2021-04-08 03:41:56 +08:00
set ( path "${${prog}}" )
unset ( prog_found CACHE )
2020-11-11 01:52:02 +08:00
get_filename_component ( ${ prog } "${${prog}}" NAME )
2021-04-08 03:41:56 +08:00
find_program ( prog_found ${ ${prog } } PATHS ENV PATH NO_DEFAULT_PATH )
if ( NOT path STREQUAL prog_found )
get_filename_component ( path "${path}" DIRECTORY )
vcpkg_add_to_path ( PREPEND ${ path } )
endif ( )
2020-11-11 01:52:02 +08:00
endif ( )
endforeach ( )
2021-10-21 05:12:58 +08:00
if ( arg_USE_WRAPPERS )
z_vcpkg_append_to_configure_environment ( configure_env CPP "compile ${VCPKG_DETECTED_CMAKE_C_COMPILER} -E" )
z_vcpkg_append_to_configure_environment ( configure_env CC "compile ${VCPKG_DETECTED_CMAKE_C_COMPILER}" )
2023-02-11 04:02:13 +08:00
if ( NOT arg_BUILD_TRIPLET MATCHES "--host" )
2022-08-20 06:13:23 +08:00
z_vcpkg_append_to_configure_environment ( configure_env CC_FOR_BUILD "compile ${VCPKG_DETECTED_CMAKE_C_COMPILER}" )
z_vcpkg_append_to_configure_environment ( configure_env CPP_FOR_BUILD "compile ${VCPKG_DETECTED_CMAKE_C_COMPILER} -E" )
z_vcpkg_append_to_configure_environment ( configure_env CXX_FOR_BUILD "compile ${VCPKG_DETECTED_CMAKE_CXX_COMPILER}" )
else ( )
# Silly trick to make configure accept CC_FOR_BUILD but in reallity CC_FOR_BUILD is deactivated.
z_vcpkg_append_to_configure_environment ( configure_env CC_FOR_BUILD "touch a.out | touch conftest${VCPKG_HOST_EXECUTABLE_SUFFIX} | true" )
z_vcpkg_append_to_configure_environment ( configure_env CPP_FOR_BUILD "touch a.out | touch conftest${VCPKG_HOST_EXECUTABLE_SUFFIX} | true" )
z_vcpkg_append_to_configure_environment ( configure_env CXX_FOR_BUILD "touch a.out | touch conftest${VCPKG_HOST_EXECUTABLE_SUFFIX} | true" )
endif ( )
2021-10-21 05:12:58 +08:00
z_vcpkg_append_to_configure_environment ( configure_env CXX "compile ${VCPKG_DETECTED_CMAKE_CXX_COMPILER}" )
z_vcpkg_append_to_configure_environment ( configure_env RC "windres-rc ${VCPKG_DETECTED_CMAKE_RC_COMPILER}" )
z_vcpkg_append_to_configure_environment ( configure_env WINDRES "windres-rc ${VCPKG_DETECTED_CMAKE_RC_COMPILER}" )
2020-11-11 01:52:02 +08:00
if ( VCPKG_DETECTED_CMAKE_AR )
2021-10-21 05:12:58 +08:00
z_vcpkg_append_to_configure_environment ( configure_env AR "ar-lib ${VCPKG_DETECTED_CMAKE_AR}" )
2020-11-11 01:52:02 +08:00
else ( )
2021-10-21 05:12:58 +08:00
z_vcpkg_append_to_configure_environment ( configure_env AR "ar-lib lib.exe -verbose" )
2020-11-11 01:52:02 +08:00
endif ( )
else ( )
2021-10-21 05:12:58 +08:00
z_vcpkg_append_to_configure_environment ( configure_env CPP "${VCPKG_DETECTED_CMAKE_C_COMPILER} -E" )
z_vcpkg_append_to_configure_environment ( configure_env CC "${VCPKG_DETECTED_CMAKE_C_COMPILER}" )
2023-02-11 04:02:13 +08:00
if ( NOT arg_BUILD_TRIPLET MATCHES "--host" )
2022-08-20 06:13:23 +08:00
z_vcpkg_append_to_configure_environment ( configure_env CC_FOR_BUILD "${VCPKG_DETECTED_CMAKE_C_COMPILER}" )
z_vcpkg_append_to_configure_environment ( configure_env CPP_FOR_BUILD "${VCPKG_DETECTED_CMAKE_C_COMPILER} -E" )
z_vcpkg_append_to_configure_environment ( configure_env CXX_FOR_BUILD "${VCPKG_DETECTED_CMAKE_CXX_COMPILER}" )
else ( )
z_vcpkg_append_to_configure_environment ( configure_env CC_FOR_BUILD "touch a.out | touch conftest${VCPKG_HOST_EXECUTABLE_SUFFIX} | true" )
z_vcpkg_append_to_configure_environment ( configure_env CPP_FOR_BUILD "touch a.out | touch conftest${VCPKG_HOST_EXECUTABLE_SUFFIX} | true" )
z_vcpkg_append_to_configure_environment ( configure_env CXX_FOR_BUILD "touch a.out | touch conftest${VCPKG_HOST_EXECUTABLE_SUFFIX} | true" )
endif ( )
2021-10-21 05:12:58 +08:00
z_vcpkg_append_to_configure_environment ( configure_env CXX "${VCPKG_DETECTED_CMAKE_CXX_COMPILER}" )
z_vcpkg_append_to_configure_environment ( configure_env RC "${VCPKG_DETECTED_CMAKE_RC_COMPILER}" )
z_vcpkg_append_to_configure_environment ( configure_env WINDRES "${VCPKG_DETECTED_CMAKE_RC_COMPILER}" )
2020-11-11 01:52:02 +08:00
if ( VCPKG_DETECTED_CMAKE_AR )
2021-10-21 05:12:58 +08:00
z_vcpkg_append_to_configure_environment ( configure_env AR "${VCPKG_DETECTED_CMAKE_AR}" )
2020-11-11 01:52:02 +08:00
else ( )
2021-10-21 05:12:58 +08:00
z_vcpkg_append_to_configure_environment ( configure_env AR "lib.exe -verbose" )
2020-11-11 01:52:02 +08:00
endif ( )
endif ( )
2021-10-21 05:12:58 +08:00
z_vcpkg_append_to_configure_environment ( configure_env LD "${VCPKG_DETECTED_CMAKE_LINKER} -verbose" )
2020-11-11 01:52:02 +08:00
if ( VCPKG_DETECTED_CMAKE_RANLIB )
2021-10-21 05:12:58 +08:00
z_vcpkg_append_to_configure_environment ( configure_env RANLIB "${VCPKG_DETECTED_CMAKE_RANLIB}" ) # Trick to ignore the RANLIB call
2020-11-11 01:52:02 +08:00
else ( )
2021-10-21 05:12:58 +08:00
z_vcpkg_append_to_configure_environment ( configure_env RANLIB ":" )
2020-11-11 01:52:02 +08:00
endif ( )
if ( VCPKG_DETECTED_CMAKE_OBJDUMP ) #Objdump is required to make shared libraries. Otherwise define lt_cv_deplibs_check_method=pass_all
2021-10-21 05:12:58 +08:00
z_vcpkg_append_to_configure_environment ( configure_env OBJDUMP "${VCPKG_DETECTED_CMAKE_OBJDUMP}" ) # Trick to ignore the RANLIB call
2020-11-11 01:52:02 +08:00
endif ( )
if ( VCPKG_DETECTED_CMAKE_STRIP ) # If required set the ENV variable STRIP in the portfile correctly
2021-10-21 05:12:58 +08:00
z_vcpkg_append_to_configure_environment ( configure_env STRIP "${VCPKG_DETECTED_CMAKE_STRIP}" )
2020-11-11 01:52:02 +08:00
else ( )
2021-10-21 05:12:58 +08:00
z_vcpkg_append_to_configure_environment ( configure_env STRIP ":" )
list ( APPEND arg_OPTIONS ac_cv_prog_ac_ct_STRIP=: )
2020-11-11 01:52:02 +08:00
endif ( )
if ( VCPKG_DETECTED_CMAKE_NM ) # If required set the ENV variable NM in the portfile correctly
2021-10-21 05:12:58 +08:00
z_vcpkg_append_to_configure_environment ( configure_env NM "${VCPKG_DETECTED_CMAKE_NM}" )
2020-11-11 01:52:02 +08:00
else ( )
# Would be better to have a true nm here! Some symbols (mainly exported variables) get not properly imported with dumpbin as nm
# and require __declspec(dllimport) for some reason (same problem CMake has with WINDOWS_EXPORT_ALL_SYMBOLS)
2021-10-21 05:12:58 +08:00
z_vcpkg_append_to_configure_environment ( configure_env NM "dumpbin.exe -symbols -headers" )
2020-11-11 01:52:02 +08:00
endif ( )
if ( VCPKG_DETECTED_CMAKE_DLLTOOL ) # If required set the ENV variable DLLTOOL in the portfile correctly
2021-10-21 05:12:58 +08:00
z_vcpkg_append_to_configure_environment ( configure_env DLLTOOL "${VCPKG_DETECTED_CMAKE_DLLTOOL}" )
2020-11-11 01:52:02 +08:00
else ( )
2021-10-21 05:12:58 +08:00
z_vcpkg_append_to_configure_environment ( configure_env DLLTOOL "link.exe -verbose -dll" )
2020-11-11 01:52:02 +08:00
endif ( )
2021-10-21 05:12:58 +08:00
z_vcpkg_append_to_configure_environment ( configure_env CCAS ":" ) # If required set the ENV variable CCAS in the portfile correctly
z_vcpkg_append_to_configure_environment ( configure_env AS ":" ) # If required set the ENV variable AS in the portfile correctly
2020-11-11 01:52:02 +08:00
2021-10-21 05:12:58 +08:00
foreach ( _env IN LISTS arg_CONFIGURE_ENVIRONMENT_VARIABLES )
z_vcpkg_append_to_configure_environment ( configure_env ${ _env } "${${_env}}" )
2020-11-11 01:52:02 +08:00
endforeach ( )
2021-10-21 05:12:58 +08:00
debug_message ( "configure_env: '${configure_env}'" )
2020-11-11 01:52:02 +08:00
# Other maybe interesting variables to control
# COMPILE This is the command used to actually compile a C source file. The file name is appended to form the complete command line.
# LINK This is the command used to actually link a C program.
# CXXCOMPILE The command used to actually compile a C++ source file. The file name is appended to form the complete command line.
# CXXLINK The command used to actually link a C++ program.
# Variables not correctly detected by configure. In release builds.
2021-10-21 05:12:58 +08:00
list ( APPEND arg_OPTIONS gl_cv_double_slash_root=yes
2020-11-11 01:52:02 +08:00
a c _ c v _ f u n c _ m e m m o v e = y e s )
2021-10-21 05:12:58 +08:00
#list(APPEND arg_OPTIONS lt_cv_deplibs_check_method=pass_all) # Just ignore libtool checks
2021-01-20 11:40:30 +08:00
if ( VCPKG_TARGET_ARCHITECTURE MATCHES "^[Aa][Rr][Mm]64$" )
2021-10-21 05:12:58 +08:00
list ( APPEND arg_OPTIONS gl_cv_host_cpu_c_abi=no )
2021-01-20 11:40:30 +08:00
# Currently needed for arm64 because objdump yields: "unrecognised machine type (0xaa64) in Import Library Format archive"
2021-10-21 05:12:58 +08:00
list ( APPEND arg_OPTIONS lt_cv_deplibs_check_method=pass_all )
2021-01-20 11:40:30 +08:00
elseif ( VCPKG_TARGET_ARCHITECTURE MATCHES "^[Aa][Rr][Mm]$" )
# Currently needed for arm because objdump yields: "unrecognised machine type (0x1c4) in Import Library Format archive"
2021-10-21 05:12:58 +08:00
list ( APPEND arg_OPTIONS lt_cv_deplibs_check_method=pass_all )
2020-11-11 01:52:02 +08:00
endif ( )
2022-10-14 00:40:52 +08:00
else ( )
2022-08-20 06:13:23 +08:00
# Because OSX dosn't like CMAKE_C(XX)_COMPILER (cc) in CC/CXX and rather wants to have gcc/g++
function ( z_vcpkg_make_set_env envvar cmakevar )
set ( prog "${VCPKG_DETECTED_CMAKE_${cmakevar}} ${ARGN}" )
string ( STRIP "${prog}" prog )
if ( DEFINED ENV{ ${ envvar } } )
return ( )
endif ( )
if ( VCPKG_DETECTED_CMAKE_ ${ cmakevar } )
set ( ENV{ ${ envvar } } "${prog}" )
endif ( )
endfunction ( )
z_vcpkg_make_set_env ( CC C_COMPILER )
2023-02-11 04:02:13 +08:00
if ( NOT arg_BUILD_TRIPLET MATCHES "--host" )
2022-08-20 06:13:23 +08:00
z_vcpkg_make_set_env ( CC_FOR_BUILD C_COMPILER )
z_vcpkg_make_set_env ( CPP_FOR_BUILD C_COMPILER "-E" )
z_vcpkg_make_set_env ( CXX_FOR_BUILD C_COMPILER )
else ( )
set ( ENV{CC_FOR_BUILD} "touch a.out | touch conftest${VCPKG_HOST_EXECUTABLE_SUFFIX} | true" )
set ( ENV{CPP_FOR_BUILD} "touch a.out | touch conftest${VCPKG_HOST_EXECUTABLE_SUFFIX} | true" )
set ( ENV{CXX_FOR_BUILD} "touch a.out | touch conftest${VCPKG_HOST_EXECUTABLE_SUFFIX} | true" )
endif ( )
z_vcpkg_make_set_env ( CXX CXX_COMPILER )
z_vcpkg_make_set_env ( NM NM )
z_vcpkg_make_set_env ( RC RC )
z_vcpkg_make_set_env ( WINDRES RC )
z_vcpkg_make_set_env ( DLLTOOL DLLTOOL )
z_vcpkg_make_set_env ( STRIP STRIP )
z_vcpkg_make_set_env ( OBJDUMP OBJDUMP )
z_vcpkg_make_set_env ( RANLIB RANLIB )
z_vcpkg_make_set_env ( AR AR )
z_vcpkg_make_set_env ( LD LINKER )
unset ( z_vcpkg_make_set_env )
2021-05-01 02:26:05 +08:00
endif ( )
2021-10-01 14:58:36 +08:00
# Some PATH handling for dealing with spaces....some tools will still fail with that!
# In particular, the libtool install command is unable to install correctly to paths with spaces.
# CURRENT_INSTALLED_DIR: Pristine native path (unprotected spaces, Windows drive letters)
2021-10-21 05:12:58 +08:00
# z_vcpkg_installed_path: Native path with escaped space characters
# z_vcpkg_prefix_path: Path with unprotected spaces, but drive letters transformed for mingw/msys
string ( REPLACE " " "\\ " z_vcpkg_installed_path "${CURRENT_INSTALLED_DIR}" )
2021-05-01 02:26:05 +08:00
if ( CMAKE_HOST_WIN32 )
2021-10-21 05:12:58 +08:00
string ( REGEX REPLACE "([a-zA-Z]):/" "/\\1/" z_vcpkg_prefix_path "${CURRENT_INSTALLED_DIR}" )
2020-11-11 01:52:02 +08:00
else ( )
2021-10-21 05:12:58 +08:00
set ( z_vcpkg_prefix_path "${CURRENT_INSTALLED_DIR}" )
2020-11-11 01:52:02 +08:00
endif ( )
# Cleanup previous build dirs
file ( REMOVE_RECURSE "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel"
" $ { C U R R E N T _ B U I L D T R E E S _ D I R } / $ { T A R G E T _ T R I P L E T } - d b g "
" $ { C U R R E N T _ B U I L D T R E E S _ D I R } / $ { T A R G E T _ T R I P L E T } " )
# Set configure paths
2021-10-21 05:12:58 +08:00
set ( arg_OPTIONS_RELEASE ${ arg_OPTIONS_RELEASE } "--prefix=${z_vcpkg_prefix_path}" )
set ( arg_OPTIONS_DEBUG ${ arg_OPTIONS_DEBUG } "--prefix=${z_vcpkg_prefix_path}/debug" )
if ( NOT arg_NO_ADDITIONAL_PATHS )
2021-10-01 14:58:36 +08:00
# ${prefix} has an extra backslash to prevent early expansion when calling `bash -c configure "..."`.
2021-10-21 05:12:58 +08:00
set ( arg_OPTIONS_RELEASE ${ arg_OPTIONS_RELEASE }
2020-11-11 01:52:02 +08:00
# Important: These should all be relative to prefix!
2021-10-01 14:58:36 +08:00
" - - b i n d i r = \ \ \ $ { p r e f i x } / t o o l s / $ { P O R T } / b i n "
" - - s b i n d i r = \ \ \ $ { p r e f i x } / t o o l s / $ { P O R T } / s b i n "
" - - l i b d i r = \ \ \ $ { p r e f i x } / l i b " # On some Linux distributions lib64 is the default
2020-11-11 01:52:02 +08:00
#"--includedir='\${prefix}'/include" # already the default!
2021-10-01 14:58:36 +08:00
" - - m a n d i r = \ \ \ $ { p r e f i x } / s h a r e / $ { P O R T } "
" - - d o c d i r = \ \ \ $ { p r e f i x } / s h a r e / $ { P O R T } "
" - - d a t a r o o t d i r = \ \ \ $ { p r e f i x } / s h a r e / $ { P O R T } " )
2021-10-21 05:12:58 +08:00
set ( arg_OPTIONS_DEBUG ${ arg_OPTIONS_DEBUG }
2020-11-11 01:52:02 +08:00
# Important: These should all be relative to prefix!
2021-10-01 14:58:36 +08:00
" - - b i n d i r = \ \ \ $ { p r e f i x } / . . / t o o l s / $ { P O R T } / d e b u g / b i n "
" - - s b i n d i r = \ \ \ $ { p r e f i x } / . . / t o o l s / $ { P O R T } / d e b u g / s b i n "
" - - l i b d i r = \ \ \ $ { p r e f i x } / l i b " # On some Linux distributions lib64 is the default
" - - i n c l u d e d i r = \ \ \ $ { p r e f i x } / . . / i n c l u d e "
" - - d a t a r o o t d i r = \ \ \ $ { p r e f i x } / s h a r e / $ { P O R T } " )
2020-11-11 01:52:02 +08:00
endif ( )
# Setup common options
2021-10-21 05:12:58 +08:00
if ( NOT arg_DISABLE_VERBOSE_FLAGS )
list ( APPEND arg_OPTIONS --disable-silent-rules --verbose )
2020-11-11 01:52:02 +08:00
endif ( )
if ( VCPKG_LIBRARY_LINKAGE STREQUAL dynamic )
2021-10-21 05:12:58 +08:00
list ( APPEND arg_OPTIONS --enable-shared --disable-static )
2020-11-11 01:52:02 +08:00
else ( )
2021-10-21 05:12:58 +08:00
list ( APPEND arg_OPTIONS --disable-shared --enable-static )
2020-11-11 01:52:02 +08:00
endif ( )
2021-06-09 00:50:09 +08:00
# Can be set in the triplet to append options for configure
2021-10-21 05:12:58 +08:00
if ( DEFINED VCPKG_CONFIGURE_MAKE_OPTIONS )
list ( APPEND arg_OPTIONS ${ VCPKG_CONFIGURE_MAKE_OPTIONS } )
2021-06-09 00:50:09 +08:00
endif ( )
2021-10-21 05:12:58 +08:00
if ( DEFINED VCPKG_CONFIGURE_MAKE_OPTIONS_RELEASE )
list ( APPEND arg_OPTIONS_RELEASE ${ VCPKG_CONFIGURE_MAKE_OPTIONS_RELEASE } )
2021-06-09 00:50:09 +08:00
endif ( )
2021-10-21 05:12:58 +08:00
if ( DEFINED VCPKG_CONFIGURE_MAKE_OPTIONS_DEBUG )
list ( APPEND arg_OPTIONS_DEBUG ${ VCPKG_CONFIGURE_MAKE_OPTIONS_DEBUG } )
2021-06-09 00:50:09 +08:00
endif ( )
2021-10-21 05:12:58 +08:00
file ( RELATIVE_PATH relative_build_path "${CURRENT_BUILDTREES_DIR}" "${arg_SOURCE_PATH}/${arg_PROJECT_SUBPATH}" )
2020-11-11 01:52:02 +08:00
# Used by CL
2022-05-21 05:41:10 +08:00
vcpkg_host_path_list ( PREPEND ENV{INCLUDE} "${CURRENT_INSTALLED_DIR}/include" )
2020-11-11 01:52:02 +08:00
# Used by GCC
2022-05-21 05:41:10 +08:00
vcpkg_host_path_list ( PREPEND ENV{C_INCLUDE_PATH} "${CURRENT_INSTALLED_DIR}/include" )
vcpkg_host_path_list ( PREPEND ENV{CPLUS_INCLUDE_PATH} "${CURRENT_INSTALLED_DIR}/include" )
2020-11-11 01:52:02 +08:00
# Flags should be set in the toolchain instead (Setting this up correctly requires a function named vcpkg_determined_cmake_compiler_flags which can also be used to setup CC and CXX etc.)
if ( VCPKG_TARGET_IS_WINDOWS )
2021-10-21 05:12:58 +08:00
vcpkg_backup_env_variables ( VARS _CL_ _LINK_ )
2020-11-11 01:52:02 +08:00
# TODO: Should be CPP flags instead -> rewrite when vcpkg_determined_cmake_compiler_flags defined
if ( VCPKG_TARGET_IS_UWP )
# Be aware that configure thinks it is crosscompiling due to:
# error while loading shared libraries: VCRUNTIME140D_APP.dll:
# cannot open shared object file: No such file or directory
# IMPORTANT: The only way to pass linker flags through libtool AND the compile wrapper
# is to use the CL and LINK environment variables !!!
# (This is due to libtool and compiler wrapper using the same set of options to pass those variables around)
2022-04-28 09:12:48 +08:00
file ( TO_CMAKE_PATH "$ENV{VCToolsInstallDir}" VCToolsInstallDir )
set ( _replacement -FU\ "${VCToolsInstallDir}/lib/x86/store/references/platform.winmd\" )
string ( REPLACE "${_replacement}" "" VCPKG_DETECTED_CMAKE_CXX_FLAGS_DEBUG "${VCPKG_DETECTED_CMAKE_CXX_FLAGS_DEBUG}" )
string ( REPLACE "${_replacement}" "" VCPKG_DETECTED_CMAKE_C_FLAGS_DEBUG "${VCPKG_DETECTED_CMAKE_C_FLAGS_DEBUG}" )
string ( REPLACE "${_replacement}" "" VCPKG_DETECTED_CMAKE_CXX_FLAGS_RELEASE "${VCPKG_DETECTED_CMAKE_CXX_FLAGS_RELEASE}" )
string ( REPLACE "${_replacement}" "" VCPKG_DETECTED_CMAKE_C_FLAGS_RELEASE "${VCPKG_DETECTED_CMAKE_C_FLAGS_RELEASE}" )
2020-11-11 01:52:02 +08:00
# Can somebody please check if CMake's compiler flags for UWP are correct?
2022-04-28 09:12:48 +08:00
set ( ENV{_CL_} "$ENV{_CL_} -FU\" ${ VCToolsInstallDir } /lib/x86/store/references/platform.winmd\ "" )
set ( ENV{_LINK_} "$ENV{_LINK_} ${VCPKG_DETECTED_CMAKE_C_STANDARD_LIBRARIES} ${VCPKG_DETECTED_CMAKE_CXX_STANDARD_LIBRARIES}" )
2020-11-11 01:52:02 +08:00
endif ( )
endif ( )
2021-10-21 05:12:58 +08:00
z_convert_to_list ( VCPKG_DETECTED_CMAKE_C_STANDARD_LIBRARIES c_libs_list )
z_convert_to_list ( VCPKG_DETECTED_CMAKE_CXX_STANDARD_LIBRARIES cxx_libs_list )
set ( all_libs_list ${ c_libs_list } ${ cxx_libs_list } )
list ( REMOVE_DUPLICATES all_libs_list )
list ( TRANSFORM all_libs_list STRIP )
2020-11-18 01:18:59 +08:00
#Do lib list transformation from name.lib to -lname if necessary
2021-10-21 05:12:58 +08:00
set ( x_vcpkg_transform_libs ON )
2020-11-18 01:18:59 +08:00
if ( VCPKG_TARGET_IS_UWP )
2021-10-21 05:12:58 +08:00
set ( x_vcpkg_transform_libs OFF )
2020-11-18 01:18:59 +08:00
# Avoid libtool choke: "Warning: linker path does not have real file for library -lWindowsApp."
# The problem with the choke is that libtool always falls back to built a static library even if a dynamic was requested.
# Note: Env LIBPATH;LIB are on the search path for libtool by default on windows.
# It even does unix/dos-short/unix transformation with the path to get rid of spaces.
endif ( )
2021-10-21 05:12:58 +08:00
set ( l_prefix )
if ( x_vcpkg_transform_libs )
set ( l_prefix "-l" )
list ( TRANSFORM all_libs_list REPLACE "(.dll.lib|.lib|.a|.so)$" "" )
2020-11-18 01:18:59 +08:00
if ( VCPKG_TARGET_IS_WINDOWS )
2021-10-21 05:12:58 +08:00
list ( REMOVE_ITEM all_libs_list "uuid" )
2020-11-18 01:18:59 +08:00
endif ( )
2021-10-21 05:12:58 +08:00
list ( TRANSFORM all_libs_list REPLACE "^(${l_prefix})" "" )
2020-11-11 01:52:02 +08:00
endif ( )
2021-10-21 05:12:58 +08:00
list ( JOIN all_libs_list " ${l_prefix}" all_libs_string )
2021-05-27 00:13:16 +08:00
if ( VCPKG_TARGET_IS_MINGW AND VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic" )
# libtool must be told explicitly that there is no dynamic linkage for uuid.
# The "-Wl,..." syntax is understood by libtool and gcc, but no by ld.
2021-10-21 05:12:58 +08:00
string ( REPLACE " -luuid" " -Wl,-Bstatic,-luuid,-Bdynamic" all_libs_string "${all_libs_string}" )
2021-05-27 00:13:16 +08:00
endif ( )
2020-11-11 01:52:02 +08:00
2021-10-21 05:12:58 +08:00
if ( all_libs_string )
set ( all_libs_string "${l_prefix}${all_libs_string}" )
2020-11-11 01:52:02 +08:00
if ( DEFINED ENV{LIBS} )
2021-10-21 05:12:58 +08:00
set ( ENV{LIBS} "$ENV{LIBS} ${all_libs_string}" )
2020-11-11 01:52:02 +08:00
else ( )
2021-10-21 05:12:58 +08:00
set ( ENV{LIBS} "${all_libs_string}" )
2020-11-11 01:52:02 +08:00
endif ( )
endif ( )
2021-06-04 05:56:25 +08:00
debug_message ( "ENV{LIBS}:$ENV{LIBS}" )
2020-11-11 01:52:02 +08:00
# Run autoconf if necessary
2022-08-20 06:13:23 +08:00
if ( arg_AUTOCONFIG OR requires_autoconfig AND NOT arg_NO_AUTOCONFIG )
2020-11-11 01:52:02 +08:00
find_program ( AUTORECONF autoreconf )
if ( NOT AUTORECONF )
message ( FATAL_ERROR "${PORT} requires autoconf from the system package manager (example: \" sudo apt-get install autoconf\ ")" )
endif ( )
message ( STATUS "Generating configure for ${TARGET_TRIPLET}" )
if ( CMAKE_HOST_WIN32 )
vcpkg_execute_required_process (
C O M M A N D $ { b a s e _ c m d } - c " a u t o r e c o n f - v f i "
2021-10-21 05:12:58 +08:00
W O R K I N G _ D I R E C T O R Y " $ { s r c _ d i r } "
L O G N A M E " a u t o c o n f - $ { T A R G E T _ T R I P L E T } "
2020-11-11 01:52:02 +08:00
)
else ( )
vcpkg_execute_required_process (
2021-10-21 05:12:58 +08:00
C O M M A N D " $ { A U T O R E C O N F } " - v f i
W O R K I N G _ D I R E C T O R Y " $ { s r c _ d i r } "
L O G N A M E " a u t o c o n f - $ { T A R G E T _ T R I P L E T } "
2020-11-11 01:52:02 +08:00
)
endif ( )
message ( STATUS "Finished generating configure for ${TARGET_TRIPLET}" )
endif ( )
2021-10-21 05:12:58 +08:00
if ( requires_autogen )
2020-11-11 01:52:02 +08:00
message ( STATUS "Generating configure for ${TARGET_TRIPLET} via autogen.sh" )
if ( CMAKE_HOST_WIN32 )
vcpkg_execute_required_process (
C O M M A N D $ { b a s e _ c m d } - c " . / a u t o g e n . s h "
2021-10-21 05:12:58 +08:00
W O R K I N G _ D I R E C T O R Y " $ { s r c _ d i r } "
L O G N A M E " a u t o c o n f - $ { T A R G E T _ T R I P L E T } "
2020-11-11 01:52:02 +08:00
)
else ( )
vcpkg_execute_required_process (
C O M M A N D " . / a u t o g e n . s h "
2021-10-21 05:12:58 +08:00
W O R K I N G _ D I R E C T O R Y " $ { s r c _ d i r } "
L O G N A M E " a u t o c o n f - $ { T A R G E T _ T R I P L E T } "
2020-11-11 01:52:02 +08:00
)
endif ( )
message ( STATUS "Finished generating configure for ${TARGET_TRIPLET}" )
endif ( )
2021-10-21 05:12:58 +08:00
if ( arg_PRERUN_SHELL )
2020-11-11 01:52:02 +08:00
message ( STATUS "Prerun shell with ${TARGET_TRIPLET}" )
2021-10-21 05:12:58 +08:00
if ( CMAKE_HOST_WIN32 )
vcpkg_execute_required_process (
C O M M A N D $ { b a s e _ c m d } - c " $ { a r g _ P R E R U N _ S H E L L } "
W O R K I N G _ D I R E C T O R Y " $ { s r c _ d i r } "
L O G N A M E " p r e r u n - $ { T A R G E T _ T R I P L E T } "
)
else ( )
vcpkg_execute_required_process (
C O M M A N D " $ { b a s e _ c m d } " - c " $ { a r g _ P R E R U N _ S H E L L } "
W O R K I N G _ D I R E C T O R Y " $ { s r c _ d i r } "
L O G N A M E " p r e r u n - $ { T A R G E T _ T R I P L E T } "
)
endif ( )
endif ( )
2022-08-20 06:13:23 +08:00
macro ( z_vcpkg_setup_make_linker_flags_vars var_suffix )
2020-11-11 01:52:02 +08:00
if ( VCPKG_LIBRARY_LINKAGE STREQUAL "static" )
2021-10-21 05:12:58 +08:00
set ( LINKER_FLAGS_ ${ var_suffix } "${VCPKG_DETECTED_CMAKE_STATIC_LINKER_FLAGS_${var_suffix}}" )
2020-11-11 01:52:02 +08:00
else ( ) # dynamic
2021-10-21 05:12:58 +08:00
set ( LINKER_FLAGS_ ${ var_suffix } "${VCPKG_DETECTED_CMAKE_SHARED_LINKER_FLAGS_${var_suffix}}" )
2020-11-11 01:52:02 +08:00
endif ( )
2022-08-20 06:13:23 +08:00
set ( ARFLAGS_ ${ var_suffix } "${VCPKG_DETECTED_CMAKE_STATIC_LINKER_FLAGS_${var_suffix}}" )
set ( LDFLAGS_ ${ var_suffix } "${VCPKG_DETECTED_CMAKE_SHARED_LINKER_FLAGS_${var_suffix}}" )
if ( CMAKE_HOST_WIN32 AND VCPKG_DETECTED_CMAKE_C_COMPILER_ID MATCHES [[cl\.exe $ ]] )
2021-10-21 05:12:58 +08:00
if ( NOT vcm_paths_with_spaces )
2022-08-20 06:13:23 +08:00
string ( APPEND LDFLAGS_ ${ var_suffix } " -L${z_vcpkg_installed_path}${path_suffix_${var_suffix}}/lib -L${z_vcpkg_installed_path}${path_suffix_${var_suffix}}/lib/manual-link" )
2020-11-11 01:52:02 +08:00
endif ( )
if ( DEFINED ENV{_LINK_} )
2021-10-21 05:12:58 +08:00
set ( LINK_ENV_ ${ var_suffix } "$ENV{_LINK_} ${LINKER_FLAGS_${var_suffix}}" )
2020-11-11 01:52:02 +08:00
else ( )
2021-10-21 05:12:58 +08:00
set ( LINK_ENV_ ${ var_suffix } "${LINKER_FLAGS_${var_suffix}}" )
2020-11-11 01:52:02 +08:00
endif ( )
else ( )
2022-08-20 06:13:23 +08:00
set ( link_required_dirs "" )
2021-10-21 05:12:58 +08:00
if ( EXISTS "${CURRENT_INSTALLED_DIR}${path_suffix_${var_suffix}}/lib" )
set ( link_required_dirs "-L${z_vcpkg_installed_path}${path_suffix_${var_suffix}}/lib" )
2021-04-03 04:41:17 +08:00
endif ( )
2021-10-21 05:12:58 +08:00
if ( EXISTS "{CURRENT_INSTALLED_DIR}${path_suffix_${var_suffix}}/lib/manual-link" )
set ( link_required_dirs "${link_required_dirs} -L${z_vcpkg_installed_path}${path_suffix_${var_suffix}}/lib/manual-link" )
2021-04-03 04:41:17 +08:00
endif ( )
2021-10-21 05:12:58 +08:00
string ( STRIP "${link_required_dirs}" link_required_dirs )
2022-08-20 06:13:23 +08:00
if ( link_required_dirs )
string ( PREPEND LDFLAGS_ ${ var_suffix } "${link_required_dirs} " )
# ARFLAGS doesn't need -L search paths since it just bundles object files
endif ( )
if ( ARFLAGS_ ${ var_suffix } )
# ARFLAGS need to know the command for creating an archive (Maybe needs user customization?)
# or extract it from CMake via CMAKE_${lang}_ARCHIVE_CREATE ?
# or from CMAKE_${lang}_${rule} with rule being one of CREATE_SHARED_MODULE CREATE_SHARED_LIBRARY LINK_EXECUTABLE
string ( PREPEND ARFLAGS_ ${ var_suffix } "cr " )
endif ( )
string ( STRIP "${LDFLAGS_${var_suffix}}" LDFLAGS_ ${ var_suffix } )
string ( STRIP "${ARFLAGS_${var_suffix}}" ARFLAGS_ ${ var_suffix } )
if ( VCPKG_TARGET_IS_WINDOWS AND VCPKG_DETECTED_CMAKE_LINKER MATCHES [[link\.exe $ ]] )
# Do not touch autotools quirks incoming!
# -Xlinker is repeated three times because:
# - libtool script eats -Xlinker
# - the compile wrapper eats -Xlinker
# - passing through both tools requires 3 -Xlinker; two being eaten in the first script.
# passing only through one script will keep one -Xlinker (done in configure)
# but cl will just ignore those with a warning. (Just like -Xcompiler)
separate_arguments ( LDFLAGS_LIST NATIVE_COMMAND "${LDFLAGS_${var_suffix}}" )
list ( JOIN LDFLAGS_LIST " -Xlinker -Xlinker -Xlinker " LDFLAGS_ ${ var_suffix } )
string ( PREPEND LDFLAGS_ ${ var_suffix } "-Xlinker -Xlinker -Xlinker " )
endif ( )
2020-11-11 01:52:02 +08:00
endif ( )
2022-08-20 06:13:23 +08:00
endmacro ( )
if ( NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug" AND NOT arg_NO_DEBUG )
set ( var_suffix DEBUG )
set ( path_suffix_ ${ var_suffix } "/debug" )
set ( short_name_ ${ var_suffix } "dbg" )
list ( APPEND all_buildtypes ${ var_suffix } )
z_vcpkg_extract_cpp_flags_and_set_cflags_and_cxxflags ( ${ var_suffix } )
z_vcpkg_setup_make_linker_flags_vars ( ${ var_suffix } )
2021-10-21 05:12:58 +08:00
unset ( var_suffix )
2020-11-11 01:52:02 +08:00
endif ( )
if ( NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release" )
2021-10-21 05:12:58 +08:00
set ( var_suffix RELEASE )
set ( path_suffix_ ${ var_suffix } "" )
set ( short_name_ ${ var_suffix } "rel" )
list ( APPEND all_buildtypes ${ var_suffix } )
z_vcpkg_extract_cpp_flags_and_set_cflags_and_cxxflags ( ${ var_suffix } )
2022-08-20 06:13:23 +08:00
z_vcpkg_setup_make_linker_flags_vars ( ${ var_suffix } )
2021-10-21 05:12:58 +08:00
unset ( var_suffix )
2020-11-11 01:52:02 +08:00
endif ( )
2021-10-21 05:12:58 +08:00
foreach ( var IN ITEMS arg_OPTIONS arg_OPTIONS_RELEASE arg_OPTIONS_DEBUG )
2021-10-01 14:58:36 +08:00
vcpkg_list ( SET tmp )
foreach ( element IN LISTS "${var}" )
string ( REPLACE [[ "]] [[\" ]] element "${element}" )
vcpkg_list ( APPEND tmp "\" ${ element } \"")
endforeach ( )
vcpkg_list ( JOIN tmp " " "${var}" )
endforeach ( )
2021-10-21 05:12:58 +08:00
foreach ( current_buildtype IN LISTS all_buildtypes )
foreach ( ENV_VAR ${ arg_CONFIG_DEPENDENT_ENVIRONMENT } )
2020-11-11 01:52:02 +08:00
if ( DEFINED ENV{ ${ ENV_VAR } } )
2021-10-21 05:12:58 +08:00
set ( backup_config_ ${ ENV_VAR } "$ENV{${ENV_VAR}}" )
2020-11-11 01:52:02 +08:00
endif ( )
2021-10-21 05:12:58 +08:00
set ( ENV{ ${ ENV_VAR } } "${${ENV_VAR}_${current_buildtype}}" )
2020-11-11 01:52:02 +08:00
endforeach ( )
2021-10-21 05:12:58 +08:00
set ( target_dir "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${short_name_${current_buildtype}}" )
file ( MAKE_DIRECTORY "${target_dir}" )
file ( RELATIVE_PATH relative_build_path "${target_dir}" "${src_dir}" )
2020-11-11 01:52:02 +08:00
2021-10-21 05:12:58 +08:00
if ( arg_COPY_SOURCE )
file ( COPY "${src_dir}/" DESTINATION "${target_dir}" )
set ( relative_build_path . )
2020-11-11 01:52:02 +08:00
endif ( )
# Setup PKG_CONFIG_PATH
2022-05-10 08:23:32 +08:00
if ( "${current_buildtype}" STREQUAL "DEBUG" )
z_vcpkg_setup_pkgconfig_path ( BASE_DIRS "${CURRENT_INSTALLED_DIR}/debug" )
2020-11-11 01:52:02 +08:00
else ( )
2022-05-10 08:23:32 +08:00
z_vcpkg_setup_pkgconfig_path ( BASE_DIRS "${CURRENT_INSTALLED_DIR}" )
2020-11-11 01:52:02 +08:00
endif ( )
# Setup environment
2021-10-21 05:12:58 +08:00
set ( ENV{CPPFLAGS} "${CPPFLAGS_${current_buildtype}}" )
2022-10-14 00:40:52 +08:00
set ( ENV{CPPFLAGS_FOR_BUILD} "${CPPFLAGS_${current_buildtype}}" )
2021-10-21 05:12:58 +08:00
set ( ENV{CFLAGS} "${CFLAGS_${current_buildtype}}" )
2022-10-14 00:40:52 +08:00
set ( ENV{CFLAGS_FOR_BUILD} "${CFLAGS_${current_buildtype}}" )
2021-10-21 05:12:58 +08:00
set ( ENV{CXXFLAGS} "${CXXFLAGS_${current_buildtype}}" )
2022-10-14 00:40:52 +08:00
#set(ENV{CXXFLAGS_FOR_BUILD} "${CXXFLAGS_${current_buildtype}}") -> doesn't exist officially
2021-10-21 05:12:58 +08:00
set ( ENV{RCFLAGS} "${VCPKG_DETECTED_CMAKE_RC_FLAGS_${current_buildtype}}" )
set ( ENV{LDFLAGS} "${LDFLAGS_${current_buildtype}}" )
2022-10-14 00:40:52 +08:00
set ( ENV{LDFLAGS_FOR_BUILD} "${LDFLAGS_${current_buildtype}}" )
2022-08-20 06:13:23 +08:00
if ( ARFLAGS_ ${ current_buildtype } AND NOT ( arg_USE_WRAPPERS AND VCPKG_TARGET_IS_WINDOWS ) )
# Target windows with wrappers enabled cannot forward ARFLAGS since it breaks the wrapper
set ( ENV{ARFLAGS} "${ARFLAGS_${current_buildtype}}" )
endif ( )
2021-07-27 01:53:47 +08:00
# https://www.gnu.org/software/libtool/manual/html_node/Link-mode.html
# -avoid-version is handled specially by libtool link mode, this flag is not forwarded to linker,
# and libtool tries to avoid versioning for shared libraries and no symbolic links are created.
if ( VCPKG_TARGET_IS_ANDROID )
set ( ENV{LDFLAGS} "-avoid-version $ENV{LDFLAGS}" )
2022-10-14 00:40:52 +08:00
set ( ENV{LDFLAGS_FOR_BUILD} "-avoid-version $ENV{LDFLAGS_FOR_BUILD}" )
endif ( )
if ( VCPKG_TARGET_IS_OSX OR VCPKG_TARGET_IS_IOS )
# configure not using all flags to check if compiler works ...
set ( ENV{CC} "$ENV{CC} $ENV{CPPFLAGS} $ENV{CFLAGS}" )
set ( ENV{CC_FOR_BUILD} "$ENV{CC_FOR_BUILD} $ENV{CPPFLAGS} $ENV{CFLAGS}" )
2021-07-27 01:53:47 +08:00
endif ( )
2021-10-21 05:12:58 +08:00
if ( LINK_ENV_ ${ current_buildtype } )
set ( link_config_backup "$ENV{_LINK_}" )
set ( ENV{_LINK_} "${LINK_ENV_${current_buildtype}}" )
2023-03-14 06:02:32 +08:00
else ( )
unset ( link_config_backup )
2020-11-11 01:52:02 +08:00
endif ( )
2022-02-16 10:31:16 +08:00
vcpkg_list ( APPEND lib_env_vars LIB LIBPATH LIBRARY_PATH ) # LD_LIBRARY_PATH)
2021-10-21 05:12:58 +08:00
foreach ( lib_env_var IN LISTS lib_env_vars )
if ( EXISTS "${CURRENT_INSTALLED_DIR}${path_suffix_${current_buildtype}}/lib" )
vcpkg_host_path_list ( PREPEND ENV{ ${ lib_env_var } } "${CURRENT_INSTALLED_DIR}${path_suffix_${current_buildtype}}/lib" )
2021-04-03 04:41:17 +08:00
endif ( )
2021-10-21 05:12:58 +08:00
if ( EXISTS "${CURRENT_INSTALLED_DIR}${path_suffix_${current_buildtype}}/lib/manual-link" )
2022-02-16 10:31:16 +08:00
vcpkg_host_path_list ( PREPEND ENV{ ${ lib_env_var } } "${CURRENT_INSTALLED_DIR}${path_suffix_${current_buildtype}}/lib/manual-link" )
2021-04-03 04:41:17 +08:00
endif ( )
endforeach ( )
2021-10-21 05:12:58 +08:00
unset ( lib_env_vars )
2020-11-11 01:52:02 +08:00
2021-10-21 05:12:58 +08:00
set ( command "${base_cmd}" -c "${configure_env} ./${relative_build_path}/configure ${arg_BUILD_TRIPLET} ${arg_OPTIONS} ${arg_OPTIONS_${current_buildtype}}" )
2021-05-01 02:26:05 +08:00
2021-10-21 05:12:58 +08:00
if ( arg_ADD_BIN_TO_PATH )
set ( path_backup $ENV{ PATH } )
vcpkg_add_to_path ( "${CURRENT_INSTALLED_DIR}${path_suffix_${current_buildtype}}/bin" )
2020-11-11 01:52:02 +08:00
endif ( )
debug_message ( "Configure command:'${command}'" )
2021-10-21 05:12:58 +08:00
if ( NOT arg_SKIP_CONFIGURE )
message ( STATUS "Configuring ${TARGET_TRIPLET}-${short_name_${current_buildtype}}" )
2020-11-11 01:52:02 +08:00
vcpkg_execute_required_process (
C O M M A N D $ { c o m m a n d }
2021-10-21 05:12:58 +08:00
W O R K I N G _ D I R E C T O R Y " $ { t a r g e t _ d i r } "
L O G N A M E " c o n f i g - $ { T A R G E T _ T R I P L E T } - $ { s h o r t _ n a m e _ $ { c u r r e n t _ b u i l d t y p e } } "
2022-07-08 05:58:03 +08:00
S A V E _ L O G _ F I L E S c o n f i g . l o g
2020-11-11 01:52:02 +08:00
)
2020-12-02 06:13:58 +08:00
if ( VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW AND VCPKG_LIBRARY_LINKAGE STREQUAL dynamic )
2021-10-21 05:12:58 +08:00
file ( GLOB_RECURSE libtool_files "${target_dir}*/libtool" )
foreach ( lt_file IN LISTS libtool_files )
2020-11-11 01:52:02 +08:00
file ( READ "${lt_file}" _contents )
string ( REPLACE ".dll.lib" ".lib" _contents "${_contents}" )
file ( WRITE "${lt_file}" "${_contents}" )
endforeach ( )
endif ( )
endif ( )
2022-05-10 08:23:32 +08:00
z_vcpkg_restore_pkgconfig_path ( )
2020-11-11 01:52:02 +08:00
2023-03-14 06:02:32 +08:00
if ( DEFINED link_config_backup )
2021-10-21 05:12:58 +08:00
set ( ENV{_LINK_} "${link_config_backup}" )
2020-11-11 01:52:02 +08:00
endif ( )
2021-10-21 05:12:58 +08:00
if ( arg_ADD_BIN_TO_PATH )
set ( ENV{PATH} "${path_backup}" )
2020-11-11 01:52:02 +08:00
endif ( )
# Restore environment (config dependent)
2021-10-21 05:12:58 +08:00
foreach ( ENV_VAR IN LISTS ${ arg_CONFIG_DEPENDENT_ENVIRONMENT } )
if ( backup_config_ ${ ENV_VAR } )
set ( ENV{ ${ ENV_VAR } } "${backup_config_${ENV_VAR}}" )
2020-11-11 01:52:02 +08:00
else ( )
unset ( ENV{ ${ ENV_VAR } } )
endif ( )
endforeach ( )
endforeach ( )
2021-08-07 22:48:44 +08:00
# Export matching make program for vcpkg_build_make (cache variable)
if ( CMAKE_HOST_WIN32 AND MSYS_ROOT )
find_program ( Z_VCPKG_MAKE make PATHS "${MSYS_ROOT}/usr/bin" NO_DEFAULT_PATH REQUIRED )
elseif ( VCPKG_HOST_IS_OPENBSD )
find_program ( Z_VCPKG_MAKE gmake REQUIRED )
else ( )
find_program ( Z_VCPKG_MAKE make REQUIRED )
endif ( )
2020-11-11 01:52:02 +08:00
# Restore environment
2021-10-21 05:12:58 +08:00
vcpkg_restore_env_variables ( VARS ${ cm_FLAGS } LIB LIBPATH LIBRARY_PATH LD_LIBRARY_PATH )
2020-11-11 01:52:02 +08:00
2021-10-21 05:12:58 +08:00
set ( _VCPKG_PROJECT_SOURCE_PATH ${ arg_SOURCE_PATH } PARENT_SCOPE )
set ( _VCPKG_PROJECT_SUBPATH ${ arg_PROJECT_SUBPATH } PARENT_SCOPE )
2022-03-03 05:43:19 +08:00
set ( _VCPKG_MAKE_NO_DEBUG ${ arg_NO_DEBUG } PARENT_SCOPE )
2020-11-11 01:52:02 +08:00
endfunction ( )