From eecb0173dc7ce25bd03094a2e6e19ec8f42e3612 Mon Sep 17 00:00:00 2001 From: Mathieu Pellerin Date: Wed, 15 Jan 2025 15:43:09 +0700 Subject: [PATCH 1/6] Update QGIS to 3.40.2 final --- vcpkg/ports/qgis/portfile.cmake | 4 ++-- vcpkg/ports/qgis/processing.patch | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/vcpkg/ports/qgis/portfile.cmake b/vcpkg/ports/qgis/portfile.cmake index a8231c6489..5403884877 100644 --- a/vcpkg/ports/qgis/portfile.cmake +++ b/vcpkg/ports/qgis/portfile.cmake @@ -1,5 +1,5 @@ -set(QGIS_REF final-3_40_1) -set(QGIS_SHA512 58d42dafe9174ec6962d851eea5754f30b88dfbe281f5c17c69edfb379658da310c5426882200210c6a95e08d08b36e84cd7288c5e3893aebf8ec3418d911e3a) +set(QGIS_REF final-3_40_2) +set(QGIS_SHA512 1389c1254d23fc02daa4b50f6c1fa8133659aa10186c7a1ee2b65f9ebcfc8128b0680cbe3067a5aa5b3cfb89d021a3f8a1c84973fa99529af2fcfda9e93bcb08) vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH diff --git a/vcpkg/ports/qgis/processing.patch b/vcpkg/ports/qgis/processing.patch index a1a58c77f9..b24a8df2c4 100644 --- a/vcpkg/ports/qgis/processing.patch +++ b/vcpkg/ports/qgis/processing.patch @@ -1,8 +1,8 @@ diff --git a/src/analysis/processing/qgsnativealgorithms.cpp b/src/analysis/processing/qgsnativealgorithms.cpp -index a74cdfc700b..2b2412c933a 100644 +index 7b50c49a..f850a311 100644 --- a/src/analysis/processing/qgsnativealgorithms.cpp +++ b/src/analysis/processing/qgsnativealgorithms.cpp -@@ -31,7 +31,6 @@ +@@ -32,7 +32,6 @@ #include "qgsalgorithmaspect.h" #include "qgsalgorithmassignprojection.h" #include "qgsalgorithmattributeindex.h" @@ -10,15 +10,15 @@ index a74cdfc700b..2b2412c933a 100644 #include "qgsalgorithmbasicstatistics.h" #include "qgsalgorithmbatchnominatimgeocode.h" #include "qgsalgorithmboundary.h" -@@ -100,7 +99,6 @@ +@@ -101,7 +100,6 @@ #include "qgsalgorithmforcerhr.h" #include "qgsalgorithmfuzzifyraster.h" #include "qgsalgorithmgeometrybyexpression.h" -#include "qgsalgorithmgltftovector.h" - #if QT_CONFIG(process) + #if QT_CONFIG( process ) #include "qgsalgorithmgpsbabeltools.h" #endif -@@ -204,7 +202,6 @@ +@@ -205,7 +203,6 @@ #include "qgsalgorithmsinglesidedbuffer.h" #include "qgsalgorithmslope.h" #include "qgsalgorithmsmooth.h" @@ -26,7 +26,7 @@ index a74cdfc700b..2b2412c933a 100644 #include "qgsalgorithmsnaptogrid.h" #include "qgsalgorithmspatialindex.h" #include "qgsalgorithmsplitfeaturesbyattributecharacter.h" -@@ -300,7 +297,6 @@ void QgsNativeAlgorithms::loadAlgorithms() +@@ -301,7 +298,6 @@ void QgsNativeAlgorithms::loadAlgorithms() addAlgorithm( new QgsAspectAlgorithm() ); addAlgorithm( new QgsAssignProjectionAlgorithm() ); addAlgorithm( new QgsAttributeIndexAlgorithm() ); @@ -34,15 +34,15 @@ index a74cdfc700b..2b2412c933a 100644 addAlgorithm( new QgsBasicStatisticsAlgorithm() ); addAlgorithm( new QgsBatchNominatimGeocodeAlgorithm() ); addAlgorithm( new QgsBookmarksToLayerAlgorithm() ); -@@ -384,7 +380,6 @@ void QgsNativeAlgorithms::loadAlgorithms() +@@ -385,7 +381,6 @@ void QgsNativeAlgorithms::loadAlgorithms() addAlgorithm( new QgsFuzzifyRasterGaussianMembershipAlgorithm() ); addAlgorithm( new QgsFuzzifyRasterNearMembershipAlgorithm() ); addAlgorithm( new QgsGeometryByExpressionAlgorithm() ); - addAlgorithm( new QgsGltfToVectorFeaturesAlgorithm() ); - #if QT_CONFIG(process) + #if QT_CONFIG( process ) addAlgorithm( new QgsConvertGpxFeatureTypeAlgorithm() ); addAlgorithm( new QgsConvertGpsDataAlgorithm() ); -@@ -519,7 +514,6 @@ void QgsNativeAlgorithms::loadAlgorithms() +@@ -520,7 +515,6 @@ void QgsNativeAlgorithms::loadAlgorithms() addAlgorithm( new QgsSingleSidedBufferAlgorithm() ); addAlgorithm( new QgsSlopeAlgorithm() ); addAlgorithm( new QgsSmoothAlgorithm() ); From 26842eaca34ebc361aafb2690044f516e2205cf0 Mon Sep 17 00:00:00 2001 From: Mathieu Pellerin Date: Wed, 15 Jan 2025 15:44:10 +0700 Subject: [PATCH 2/6] Update vcpkg revision (in prep. for Qt 6.8.2) --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 513eac4ecb..6ca4bb3bed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ # CMake settings cmake_minimum_required(VERSION 3.19) -set(VCPKG_TAG 19847ac3d8cad7599e96bd531f9bc1f0ebae6131) +set(VCPKG_TAG d4f3e122069912636c123b7ece673f6e01513cea) set(QML_IMPORT_PATH ${CMAKE_SOURCE_DIR}/src/qml/imports CACHE PATH "QML import path for Qt Creator to detect custom modules properly") From 9eb4f41f161eac67904834749336756899a3944c Mon Sep 17 00:00:00 2001 From: Mathieu Pellerin Date: Thu, 16 Jan 2025 09:47:25 +0700 Subject: [PATCH 3/6] Fix compilation on macos / iOS --- vcpkg/ports/vcpkg-make/portfile.cmake | 43 ++ .../ports/vcpkg-make/vcpkg-port-config.cmake | 6 + vcpkg/ports/vcpkg-make/vcpkg.json | 13 + vcpkg/ports/vcpkg-make/vcpkg_make.cmake | 277 ++++++++ .../ports/vcpkg-make/vcpkg_make_common.cmake | 660 ++++++++++++++++++ .../vcpkg-make/vcpkg_make_configure.cmake | 135 ++++ .../ports/vcpkg-make/vcpkg_make_install.cmake | 134 ++++ vcpkg/ports/vcpkg-make/vcpkg_scripts.cmake | 203 ++++++ .../ports/vcpkg-make/wrappers/cl_cpp_wrapper | 95 +++ vcpkg/ports/vcpkg-make/wrappers/windres-rc | 122 ++++ 10 files changed, 1688 insertions(+) create mode 100644 vcpkg/ports/vcpkg-make/portfile.cmake create mode 100644 vcpkg/ports/vcpkg-make/vcpkg-port-config.cmake create mode 100644 vcpkg/ports/vcpkg-make/vcpkg.json create mode 100644 vcpkg/ports/vcpkg-make/vcpkg_make.cmake create mode 100644 vcpkg/ports/vcpkg-make/vcpkg_make_common.cmake create mode 100644 vcpkg/ports/vcpkg-make/vcpkg_make_configure.cmake create mode 100644 vcpkg/ports/vcpkg-make/vcpkg_make_install.cmake create mode 100644 vcpkg/ports/vcpkg-make/vcpkg_scripts.cmake create mode 100644 vcpkg/ports/vcpkg-make/wrappers/cl_cpp_wrapper create mode 100644 vcpkg/ports/vcpkg-make/wrappers/windres-rc diff --git a/vcpkg/ports/vcpkg-make/portfile.cmake b/vcpkg/ports/vcpkg-make/portfile.cmake new file mode 100644 index 0000000000..1b1d146f31 --- /dev/null +++ b/vcpkg/ports/vcpkg-make/portfile.cmake @@ -0,0 +1,43 @@ +set(VCPKG_POLICY_CMAKE_HELPER_PORT enabled) + +set(automake_version 1.17) +vcpkg_download_distfile(ARCHIVE + URLS https://ftp.gnu.org/gnu/automake/automake-${automake_version}.tar.gz + https://www.mirrorservice.org/sites/ftp.gnu.org/gnu/automake/automake-${automake_version}.tar.gz + FILENAME automake-${automake_version}.tar.gz + SHA512 11357dfab8cbf4b5d94d9d06e475732ca01df82bef1284888a34bd558afc37b1a239bed1b5eb18a9dbcc326344fb7b1b301f77bb8385131eb8e1e118b677883a +) + +vcpkg_extract_source_archive( + automake_source + ARCHIVE "${ARCHIVE}" +) + +file(INSTALL + "${CMAKE_CURRENT_LIST_DIR}/vcpkg_make_configure.cmake" + "${CMAKE_CURRENT_LIST_DIR}/vcpkg_make_install.cmake" + "${CMAKE_CURRENT_LIST_DIR}/vcpkg_make_common.cmake" + "${CMAKE_CURRENT_LIST_DIR}/vcpkg_make.cmake" + "${CMAKE_CURRENT_LIST_DIR}/vcpkg_scripts.cmake" + "${CMAKE_CURRENT_LIST_DIR}/vcpkg-port-config.cmake" + DESTINATION + "${CURRENT_PACKAGES_DIR}/share/${PORT}" +) + +file(INSTALL + "${automake_source}/lib/ar-lib" + "${automake_source}/lib/compile" + DESTINATION + "${CURRENT_PACKAGES_DIR}/share/${PORT}/wrappers" +) + +vcpkg_install_copyright( + COMMENT [[ +The cmake scripts are under vcpkg's MIT license terms, see LICENSE.txt below. +The port also installs shell scripts from GNU Automake. +These scripts are under GPL-2.0-or-later, see COPYING below. +]] + FILE_LIST + "${VCPKG_ROOT_DIR}/LICENSE.txt" + "${automake_source}/COPYING" +) diff --git a/vcpkg/ports/vcpkg-make/vcpkg-port-config.cmake b/vcpkg/ports/vcpkg-make/vcpkg-port-config.cmake new file mode 100644 index 0000000000..9bce16b970 --- /dev/null +++ b/vcpkg/ports/vcpkg-make/vcpkg-port-config.cmake @@ -0,0 +1,6 @@ +include("${CMAKE_CURRENT_LIST_DIR}/../vcpkg-cmake-get-vars/vcpkg-port-config.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/vcpkg_make_configure.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/vcpkg_make_install.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/vcpkg_make_common.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/vcpkg_make.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/vcpkg_scripts.cmake") diff --git a/vcpkg/ports/vcpkg-make/vcpkg.json b/vcpkg/ports/vcpkg-make/vcpkg.json new file mode 100644 index 0000000000..59046f78a1 --- /dev/null +++ b/vcpkg/ports/vcpkg-make/vcpkg.json @@ -0,0 +1,13 @@ +{ + "name": "vcpkg-make", + "version-date": "2024-12-27", + "documentation": "https://learn.microsoft.com/vcpkg/maintainers/functions/vcpkg_make_configure", + "license": null, + "supports": "native", + "dependencies": [ + { + "name": "vcpkg-cmake-get-vars", + "host": true + } + ] +} diff --git a/vcpkg/ports/vcpkg-make/vcpkg_make.cmake b/vcpkg/ports/vcpkg-make/vcpkg_make.cmake new file mode 100644 index 0000000000..ee3ec778fc --- /dev/null +++ b/vcpkg/ports/vcpkg-make/vcpkg_make.cmake @@ -0,0 +1,277 @@ +# Be aware of https://github.com/microsoft/vcpkg/pull/31228 +include_guard(GLOBAL) +include("${CMAKE_CURRENT_LIST_DIR}/vcpkg_make_common.cmake") + +function(vcpkg_run_shell) + cmake_parse_arguments(PARSE_ARGV 0 arg + "" + "WORKING_DIRECTORY;LOGNAME" + "SHELL;COMMAND;SAVE_LOG_FILES" + ) + z_vcpkg_unparsed_args(FATAL_ERROR) + z_vcpkg_required_args(SHELL WORKING_DIRECTORY COMMAND LOGNAME) + + + set(extra_opts "") + if(arg_SAVE_LOG_FILES) + set(extra_opts SAVE_LOG_FILES ${arg_SAVE_LOG_FILES}) + endif() + + # In the construction of the shell command, we need to handle environment variable assignments and configure options differently: + # + # 1. Environment variable assignments (e.g., CC, CXX, etc.): + # - These must not be quoted. + # - If the environment variable names (e.g., CC, CXX, CC_FOR_BUILD) are quoted, the shell will treat them as part of the value, breaking the declaration. + # - For example, CC='/usr/bin/gcc' is valid, but "CC='/usr/bin/gcc'" would cause an error because the shell would try to use the entire quoted string as the variable name. + # + # 2. Options passed to the configure script: + # - The options should be quoted to ensure that any option containing spaces or special characters is treated as a single argument. + # - For instance, --prefix=/some path/with spaces would break if not quoted, as the shell would interpret each word as a separate argument. + # - By quoting the options like "--prefix=/some path/with spaces", we ensure they are passed correctly to the configure script as a single argument. + # + # The resulting command should look something like this: + # V=1 CC='/Library/Developer/CommandLineTools/usr/bin/cc -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk -arch arm64' + # CXX='/Library/Developer/CommandLineTools/usr/bin/c++ -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk -arch arm64' + # CC_FOR_BUILD='/Library/Developer/CommandLineTools/usr/bin/cc -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk -arch arm64' + # CPP_FOR_BUILD='/Library/Developer/CommandLineTools/usr/bin/cc -E -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk -arch arm64' + # CXX_FOR_BUILD='/Library/Developer/CommandLineTools/usr/bin/c++ -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk -arch arm64' + # .... + # ./../src/8bc98c3a0d-84009aba94.clean/configure "--enable-pic" "--disable-lavf" "--disable-swscale" "--disable-avs" ... + vcpkg_list(JOIN arg_COMMAND " " arg_COMMAND) + vcpkg_execute_required_process( + COMMAND ${arg_SHELL} -c "${arg_COMMAND}" + WORKING_DIRECTORY "${arg_WORKING_DIRECTORY}" + LOGNAME "${arg_LOGNAME}" + ${extra_opts} + ) +endfunction() + +function(vcpkg_run_shell_as_build) + cmake_parse_arguments(PARSE_ARGV 0 arg + "" + "WORKING_DIRECTORY;LOGNAME" + "SHELL;COMMAND;NO_PARALLEL_COMMAND;SAVE_LOG_FILES" + ) + z_vcpkg_unparsed_args(FATAL_ERROR) + z_vcpkg_required_args(SHELL WORKINK_DIRECTORY COMMAND LOGNAME) + + set(extra_opts "") + if(arg_SAVE_LOG_FILES) + set(extra_opts SAVE_LOG_FILES ${arg_SAVE_LOG_FILES}) + endif() + + list(JOIN arg_COMMAND " " cmd) + list(JOIN arg_NO_PARALLEL_COMMAND " " no_par_cmd) + vcpkg_execute_build_process( + COMMAND ${arg_SHELL} -c "${cmd}" + NO_PARALLEL_COMMAND ${arg_SHELL} -c "${no_par_cmd}" + WORKING_DIRECTORY "${arg_WORKING_DIRECTORY}" + LOGNAME "${arg_LOGNAME}" + ${extra_opts} + ) +endfunction() + +function(vcpkg_run_autoreconf shell_cmd work_dir) + find_program(AUTORECONF NAMES autoreconf) + if(NOT AUTORECONF) + message(FATAL_ERROR "${PORT} currently requires the following programs from the system package manager: + autoconf automake autoconf-archive + On Debian and Ubuntu derivatives: + sudo apt-get install autoconf automake autoconf-archive + On recent Red Hat and Fedora derivatives: + sudo dnf install autoconf automake autoconf-archive + On Arch Linux and derivatives: + sudo pacman -S autoconf automake autoconf-archive + On Alpine: + apk add autoconf automake autoconf-archive + On macOS: + brew install autoconf automake autoconf-archive\n") + endif() + message(STATUS "Generating configure for ${TARGET_TRIPLET}") + vcpkg_run_shell( + SHELL ${shell_cmd} + COMMAND "${AUTORECONF}" -vfi + WORKING_DIRECTORY "${work_dir}" + LOGNAME "autoconf-${TARGET_TRIPLET}" + ) + message(STATUS "Finished generating configure for ${TARGET_TRIPLET}") +endfunction() + +function(vcpkg_make_setup_win_msys msys_out) + list(APPEND msys_require_packages autoconf-wrapper automake-wrapper binutils libtool make which) + vcpkg_insert_msys_into_path(msys PACKAGES ${msys_require_packages}) + find_program(PKGCONFIG NAMES pkgconf NAMES_PER_DIR PATHS "${CURRENT_HOST_INSTALLED_DIR}/tools/pkgconf" NO_DEFAULT_PATH) + set("${msys_out}" "${msys}" PARENT_SCOPE) +endfunction() + +function(vcpkg_make_get_shell out_var) + set(shell_options "") + if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW) + vcpkg_make_setup_win_msys(msys_root) + set(shell_options --noprofile --norc --debug) + set(shell_cmd "${msys_root}/usr/bin/bash.exe") + endif() + find_program(shell_cmd NAMES bash sh zsh REQUIRED) + set("${out_var}" "${shell_cmd}" ${shell_options} PARENT_SCOPE) +endfunction() + +function(z_vcpkg_make_get_configure_triplets out) + cmake_parse_arguments(PARSE_ARGV 1 arg + "" + "COMPILER_NAME" + "" + ) + z_vcpkg_unparsed_args(FATAL_ERROR) + # --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 + z_vcpkg_make_determine_target_arch(TARGET_ARCH) + z_vcpkg_make_determine_host_arch(BUILD_ARCH) + + set(build_triplet_opt "") + if(CMAKE_HOST_WIN32 AND VCPKG_TARGET_IS_WINDOWS) + # This is required since we are running in a msys + # shell which will be otherwise identified as ${BUILD_ARCH}-pc-msys + set(build_triplet_opt "--build=${BUILD_ARCH}-pc-mingw32") + endif() + + set(host_triplet "") + if(VCPKG_CROSSCOMPILING) + if(VCPKG_TARGET_IS_WINDOWS) + if(NOT TARGET_ARCH MATCHES "${BUILD_ARCH}" OR NOT CMAKE_HOST_WIN32) + set(host_triplet_opt "--host=${TARGET_ARCH}-pc-mingw32") + elseif(VCPKG_TARGET_IS_UWP) + # Needs to be different from --build to enable cross builds. + set(host_triplet_opt "--host=${TARGET_ARCH}-unknown-mingw32") + endif() + elseif(VCPKG_TARGET_IS_IOS OR VCPKG_TARGET_IS_OSX AND NOT "${TARGET_ARCH}" STREQUAL "${BUILD_ARCH}") + set(host_triplet_opt "--host=${TARGET_ARCH}-apple-darwin") + elseif(VCPKG_TARGET_IS_LINUX) + if("${arg_COMPILER_NAME}" MATCHES "([^\/]*)-gcc$" AND CMAKE_MATCH_1 AND NOT CMAKE_MATCH_1 MATCHES "^gcc") + set(host_triplet_opt "--host=${CMAKE_MATCH_1}") # (Host activates crosscompilation; The name given here is just the prefix of the host tools for the target) + endif() + endif() + endif() + + set(output "${build_triplet_opt};${host_triplet_opt}") + string(STRIP "${output}" output) + set("${out}" "${output}" PARENT_SCOPE) +endfunction() + +function(z_vcpkg_make_prepare_env config) + cmake_parse_arguments(PARSE_ARGV 1 arg + "ADD_BIN_TO_PATH" + "" + "" + ) + z_vcpkg_unparsed_args(FATAL_ERROR) + # Used by CL + vcpkg_host_path_list(PREPEND ENV{INCLUDE} "${CURRENT_INSTALLED_DIR}/include") + # Used by GCC + 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") + + # 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) + vcpkg_backup_env_variables(VARS _CL_ _LINK_) + # 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) + 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}") + 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}") + endif() + endif() + + # Setup environment + set(ENV{CPPFLAGS} "${CPPFLAGS_${config}}") + set(ENV{CPPFLAGS_FOR_BUILD} "${CPPFLAGS_${config}}") + set(ENV{CFLAGS} "${CFLAGS_${config}}") + set(ENV{CFLAGS_FOR_BUILD} "${CFLAGS_${config}}") + set(ENV{CXXFLAGS} "${CXXFLAGS_${config}}") + set(ENV{RCFLAGS} "${RCFLAGS_${config}}") + set(ENV{LDFLAGS} "${LDFLAGS_${config}}") + set(ENV{LDFLAGS_FOR_BUILD} "${LDFLAGS_${config}}") + if(ARFLAGS_${config} 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_${config}}") + endif() + + if(LINK_ENV_${config}) + set(ENV{_LINK_} "${LINK_ENV_${config}}") + endif() + + vcpkg_list(APPEND lib_env_vars LIB LIBPATH LIBRARY_PATH) + foreach(lib_env_var IN LISTS lib_env_vars) + if(EXISTS "${CURRENT_INSTALLED_DIR}${path_suffix_${config}}/lib") + vcpkg_host_path_list(PREPEND ENV{${lib_env_var}} "${CURRENT_INSTALLED_DIR}${path_suffix_${config}}/lib") + endif() + if(EXISTS "${CURRENT_INSTALLED_DIR}${path_suffix_${config}}/lib/manual-link") + vcpkg_host_path_list(PREPEND ENV{${lib_env_var}} "${CURRENT_INSTALLED_DIR}${path_suffix_${config}}/lib/manual-link") + endif() + endforeach() +endfunction() + +function(z_vcpkg_make_restore_env) + # Only variables which are inspected in vcpkg_make_prepare_env need to be restored here. + # Rest is restored add the end of configure. + vcpkg_restore_env_variables(VARS + LIBRARY_PATH LIB LIBPATH + PATH + ) +endfunction() + +function(vcpkg_make_run_configure) + cmake_parse_arguments(PARSE_ARGV 0 arg + "ADD_BIN_TO_PATH" + "CONFIG;SHELL;WORKING_DIRECTORY;CONFIGURE_PATH;CONFIGURE_ENV" + "OPTIONS" + ) + z_vcpkg_unparsed_args(FATAL_ERROR) + z_vcpkg_required_args(SHELL CONFIG WORKING_DIRECTORY CONFIGURE_PATH) + + vcpkg_prepare_pkgconfig("${arg_CONFIG}") + + set(prepare_env_opts "") + + z_vcpkg_make_prepare_env("${arg_CONFIG}" ${prepare_env_opts}) + + vcpkg_list(SET tmp) + foreach(element IN LISTS arg_OPTIONS) + string(REPLACE [["]] [[\"]] element "${element}") + vcpkg_list(APPEND tmp "\"${element}\"") + endforeach() + vcpkg_list(JOIN tmp " " "arg_OPTIONS") + set(command ${arg_CONFIGURE_ENV} ${arg_CONFIGURE_PATH} ${arg_OPTIONS}) + + message(STATUS "Configuring ${TARGET_TRIPLET}-${suffix_${arg_CONFIG}}") + vcpkg_run_shell( + WORKING_DIRECTORY "${arg_WORKING_DIRECTORY}" + LOGNAME "config-${TARGET_TRIPLET}-${suffix_${arg_CONFIG}}" + SAVE_LOG_FILES config.log + SHELL ${arg_SHELL} + COMMAND V=1 ${command} + ) + if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW AND VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) + file(GLOB_RECURSE libtool_files "${arg_WORKING_DIRECTORY}*/libtool") + foreach(lt_file IN LISTS libtool_files) + file(READ "${lt_file}" _contents) + string(REPLACE ".dll.lib" ".lib" _contents "${_contents}") + file(WRITE "${lt_file}" "${_contents}") + endforeach() + endif() + z_vcpkg_make_restore_env() + vcpkg_restore_pkgconfig() +endfunction() diff --git a/vcpkg/ports/vcpkg-make/vcpkg_make_common.cmake b/vcpkg/ports/vcpkg-make/vcpkg_make_common.cmake new file mode 100644 index 0000000000..575f3b81f8 --- /dev/null +++ b/vcpkg/ports/vcpkg-make/vcpkg_make_common.cmake @@ -0,0 +1,660 @@ +include_guard(GLOBAL) + +### Mapping variables +macro(z_vcpkg_make_set_common_vars) + set(path_suffix_RELEASE "") + set(path_suffix_DEBUG "/debug") + set(suffix_RELEASE "rel") + set(suffix_DEBUG "dbg") + foreach(config IN ITEMS RELEASE DEBUG) + set("workdir_${config}" "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${suffix_${config}}") + endforeach() + set(buildtypes release) + if(NOT VCPKG_BUILD_TYPE) + list(APPEND buildtypes debug) + endif() +endmacro() + +### +macro(z_vcpkg_make_get_cmake_vars) + cmake_parse_arguments(vmgcv_arg # Not just arg since macros don't define their own var scope. + "" "" "LANGUAGES" ${ARGN} + ) + + z_vcpkg_get_global_property(has_cmake_vars_file "make_cmake_vars_file" SET) + + if(NOT has_cmake_vars_file) + if(vmgcv_arg_LANGUAGES) + # Escape semicolons to prevent CMake from splitting LANGUAGES list when passing as -D option. + string(REPLACE ";" "\;" vmgcv_arg_langs "${vmgcv_arg_LANGUAGES}") + list(APPEND VCPKG_CMAKE_CONFIGURE_OPTIONS "-DVCPKG_LANGUAGES=${vmgcv_arg_langs}") + unset(langs) + endif() + + list(APPEND VCPKG_CMAKE_CONFIGURE_OPTIONS "-DVCPKG_DEFAULT_VARS_TO_CHECK=CMAKE_LIBRARY_PATH_FLAG") + vcpkg_cmake_get_vars(cmake_vars_file) + z_vcpkg_set_global_property(make_cmake_vars_file "${cmake_vars_file}") + else() + z_vcpkg_get_global_property(cmake_vars_file "make_cmake_vars_file") + endif() + + include("${cmake_vars_file}") +endmacro() + +### normalize architectures +function(z_vcpkg_make_determine_arch out_var value) + if(${value} MATCHES "^(amd|AMD|x)64$") + set(${out_var} x86_64 PARENT_SCOPE) + elseif(${value} MATCHES "^(x|X)86$") + set(${out_var} i686 PARENT_SCOPE) + elseif(${value} MATCHES "^(ARM|arm)64$") + set(${out_var} aarch64 PARENT_SCOPE) + elseif(${value} MATCHES "^(ARM|arm)$") + set(${out_var} arm PARENT_SCOPE) + elseif(${value} MATCHES "^(x86_64|i686|aarch64)$" OR NOT VCPKG_TARGET_IS_WINDOWS) + # Do nothing and assume valid architecture + set("${out_var}" "${value}" PARENT_SCOPE) + else() + message(FATAL_ERROR "Unsupported architecture '${value}' in '${CMAKE_CURRENT_FUNCTION}'!" ) + endif() +endfunction() + +function(z_vcpkg_make_determine_host_arch out_var) + if(DEFINED ENV{PROCESSOR_ARCHITEW6432}) + set(arch $ENV{PROCESSOR_ARCHITEW6432}) + elseif(DEFINED ENV{PROCESSOR_ARCHITECTURE}) + set(arch $ENV{PROCESSOR_ARCHITECTURE}) + else() + z_vcpkg_make_get_cmake_vars(#[[ LANGUAGES .... ]]) + set(arch "${VCPKG_DETECTED_CMAKE_HOST_SYSTEM_PROCESSOR}") + endif() + z_vcpkg_make_determine_arch("${out_var}" "${arch}") + set("${out_var}" "${${out_var}}" PARENT_SCOPE) +endfunction() + +function(z_vcpkg_make_determine_target_arch out_var) + list(LENGTH VCPKG_OSX_ARCHITECTURES osx_archs_num) + if(osx_archs_num GREATER_EQUAL 2 AND VCPKG_TARGET_IS_OSX) + set(${out_var} "universal") + else() + z_vcpkg_make_determine_arch(${out_var} "${VCPKG_TARGET_ARCHITECTURE}") + endif() + set("${out_var}" "${${out_var}}" PARENT_SCOPE) +endfunction() + +function(z_vcpkg_make_prepare_compile_flags) + cmake_parse_arguments(PARSE_ARGV 0 arg + "DISABLE_CPPFLAGS;NO_FLAG_ESCAPING;DISABLE_MSVC_WRAPPERS" + "COMPILER_FRONTEND;CONFIG;FLAGS_OUT" + "LANGUAGES" + ) + + z_vcpkg_unparsed_args(FATAL_ERROR) + + if(NOT DEFINED arg_LANGUAGES) + set(arg_LANGUAGES "C" "CXX") + endif() + + set(var_suffix "${arg_CONFIG}") + set(CFLAGS "") + set(CXXFLAGS "") + + # separate_aruments is needed to remove outer quotes from detected cmake variables. + # (e.g. Android NDK has "--sysroot=...") + foreach(lang IN LISTS arg_LANGUAGES) + if(NOT "${VCPKG_COMBINED_${lang}_FLAGS_${var_suffix}}" STREQUAL "") + separate_arguments(${lang}FLAGS NATIVE_COMMAND "${VCPKG_COMBINED_${lang}_FLAGS_${var_suffix}}") + else() + set(${lang}FLAGS "") + endif() + vcpkg_list(APPEND flags ${lang}FLAGS) + endforeach() + + separate_arguments(LDFLAGS NATIVE_COMMAND "${VCPKG_COMBINED_SHARED_LINKER_FLAGS_${var_suffix}}") + separate_arguments(ARFLAGS NATIVE_COMMAND "${VCPKG_COMBINED_STATIC_LINKER_FLAGS_${var_suffix}}") + set(RCFLAGS "${VCPKG_COMBINED_RC_FLAGS_${var_suffix}}") + + foreach(var IN ITEMS ABIFLAGS LDFLAGS ARFLAGS RCFLAGS) + vcpkg_list(APPEND flags ${var}) + endforeach() + + set(ABIFLAGS "") + set(pattern "") + foreach(arg IN LISTS CFLAGS) + if(NOT pattern STREQUAL "") + vcpkg_list(APPEND pattern "${arg}") + elseif(arg MATCHES "^--(sysroot|target)=.") + vcpkg_list(SET pattern "${arg}") + elseif(arg MATCHES "^-(isysroot|m32|m64|m?[Aa][Rr][Cc][Hh]|target)\$") + vcpkg_list(SET pattern "${arg}") + continue() + else() + continue() + endif() + vcpkg_list(APPEND ABIFLAGS "${pattern}") + list(REMOVE_ITEM CFLAGS "${pattern}") + list(REMOVE_ITEM CXXFLAGS "${pattern}") + list(REMOVE_ITEM LDFLAGS "${pattern}") + set(pattern "") + endforeach() + + # Filter common CPPFLAGS out of CFLAGS and CXXFLAGS + if(NOT arg_DISABLE_CPPFLAGS) + set(CPPFLAGS "") + set(pattern "") + foreach(arg IN LISTS CXXFLAGS) + if(NOT pattern STREQUAL "") + vcpkg_list(APPEND pattern "${arg}") + elseif(arg MATCHES "^-(D|isystem).") + vcpkg_list(SET pattern "${arg}") + elseif(arg MATCHES "^-(D|isystem)\$") + vcpkg_list(SET pattern "${arg}") + continue() + else() + continue() + endif() + string(FIND "${CFLAGS}" "${pattern} " index) + if(NOT index STREQUAL "-1") + vcpkg_list(APPEND CPPFLAGS ${pattern}) + list(REMOVE_ITEM CFLAGS "${pattern}") + list(REMOVE_ITEM CXXFLAGS "${pattern}") + list(REMOVE_ITEM LDFLAGS "${pattern}") + endif() + endforeach() + set(pattern "") + foreach(arg IN LISTS CFLAGS) + if(NOT pattern STREQUAL "") + vcpkg_list(APPEND pattern "${arg}") + elseif(arg MATCHES "^-(D|isystem)\$") + vcpkg_list(SET pattern "${arg}") + continue() + elseif(arg MATCHES "^-(D|isystem).") + vcpkg_list(SET pattern "${arg}") + else() + continue() + endif() + string(FIND "${CXXFLAGS}" "${pattern} " index) + if(NOT index STREQUAL "-1") + vcpkg_list(APPEND CPPFLAGS ${pattern}) + list(REMOVE_ITEM CFLAGS "${pattern}") + list(REMOVE_ITEM CXXFLAGS "${pattern}") + list(REMOVE_ITEM LDFLAGS "${pattern}") + endif() + vcpkg_list(SET pattern) + endforeach() + endif() + + # libtool tries to filter CFLAGS passed to the link stage via a allow list. + + # This approach is flawed since it fails to pass flags unknown to libtool + # but required for linking to the link stage (e.g. -fsanitize=). + # 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. + set(compiler_flag_escape "") + if(arg_COMPILER_FRONTEND STREQUAL "MSVC" AND NOT arg_NO_FLAG_ESCAPING) + set(compiler_flag_escape "-Xcompiler") + endif() + if(compiler_flag_escape) + list(TRANSFORM CFLAGS PREPEND "${compiler_flag_escape};") + list(TRANSFORM CXXFLAGS PREPEND "${compiler_flag_escape};") + endif() + + set(library_path_flag "${VCPKG_DETECTED_CMAKE_LIBRARY_PATH_FLAG}") + set(linker_flag_escape "") + if(arg_COMPILER_FRONTEND STREQUAL "MSVC" AND NOT arg_NO_FLAG_ESCAPING) + # Removed by libtool + set(linker_flag_escape "-Xlinker") + if(NOT arg_DISABLE_MSVC_WRAPPERS) + set(linker_flag_escape "-Xlinker -Xlinker -Xlinker") + endif() + if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") + string(STRIP "$ENV{_LINK_} ${VCPKG_COMBINED_STATIC_LINKER_FLAGS_${var_suffix}}" LINK_ENV) + else() + string(STRIP "$ENV{_LINK_} ${VCPKG_COMBINED_SHARED_LINKER_FLAGS_${var_suffix}}" LINK_ENV) + endif() + endif() + if(linker_flag_escape) + string(STRIP "${linker_flag_escape}" linker_flag_escape_stripped) + string(REPLACE " " ";" linker_flag_escape_stripped "${linker_flag_escape_stripped}") + list(TRANSFORM LDFLAGS PREPEND "${linker_flag_escape_stripped};") + endif() + string(REPLACE " " "\\ " current_installed_dir_escaped "${CURRENT_INSTALLED_DIR}") + if(EXISTS "${CURRENT_INSTALLED_DIR}${path_suffix_${var_suffix}}/lib/manual-link") + vcpkg_list(PREPEND LDFLAGS "${linker_flag_escape}${library_path_flag}${current_installed_dir_escaped}${path_suffix_${var_suffix}}/lib/manual-link") + endif() + if(EXISTS "${CURRENT_INSTALLED_DIR}${path_suffix_${var_suffix}}/lib") + vcpkg_list(PREPEND LDFLAGS "${linker_flag_escape}${library_path_flag}${current_installed_dir_escaped}${path_suffix_${var_suffix}}/lib") + endif() + + if(ARFLAGS AND NOT arg_COMPILER_FRONTEND STREQUAL "MSVC") + # 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 + vcpkg_list(PREPEND ARFLAGS "cr") + elseif(NOT arg_DISABLE_MSVC_WRAPPERS AND arg_COMPILER_FRONTEND STREQUAL "MSVC") + # The wrapper needs an action and that action needs to be defined AFTER all flags + vcpkg_list(APPEND ARFLAGS "cr") + endif() + + foreach(var IN LISTS flags) + list(JOIN ${var} " " string) + set("${var}_${var_suffix}" "${string}" PARENT_SCOPE) + list(APPEND flags_out "${var}_${var_suffix}") + endforeach() + set("${arg_FLAGS_OUT}" "${flags_out}" PARENT_SCOPE) +endfunction() + +### Prepare environment for configure +function(z_vcpkg_make_prepare_programs out_env) + cmake_parse_arguments(PARSE_ARGV 1 arg + "DISABLE_CPPFLAGS;DISABLE_MSVC_WRAPPERS" + "CONFIG;BUILD_TRIPLET" + "LANGUAGES" + ) + z_vcpkg_unparsed_args(FATAL_ERROR) + + z_vcpkg_make_get_cmake_vars(LANGUAGES ${arg_LANGUAGES}) + + macro(z_vcpkg_append_to_configure_environment inoutlist var defaultval) + # Allows to overwrite settings in custom triplets via the environment + if(DEFINED ENV{${var}}) + list(APPEND "${inoutlist}" "${var}='$ENV{${var}}'") + else() + list(APPEND "${inoutlist}" "${var}='${defaultval}'") + endif() + endmacro() + + set(configure_env "") + # Remove full filepaths due to spaces and prepend filepaths to PATH (cross-compiling tools are unlikely on path by default) + if (VCPKG_TARGET_IS_WINDOWS) + set(progs C_COMPILER CXX_COMPILER AR + LINKER RANLIB OBJDUMP + STRIP NM DLLTOOL RC_COMPILER) + list(TRANSFORM progs PREPEND "VCPKG_DETECTED_CMAKE_") + foreach(prog IN LISTS progs) + set(filepath "${${prog}}") + if(filepath MATCHES " ") + # CHECK: Uncertain if the compile wrappers work with absolute paths containing C:\\ + cmake_path(GET filepath FILENAME ${prog}) + vcpkg_insert_program_into_path("${filepath}") + endif() + endforeach() + + if (NOT arg_DISABLE_MSVC_WRAPPERS AND NOT VCPKG_TARGET_IS_MINGW) + 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}") + z_vcpkg_append_to_configure_environment(configure_env CXX "compile ${VCPKG_DETECTED_CMAKE_CXX_COMPILER}") + if(NOT arg_BUILD_TRIPLET MATCHES "--host") # TODO: Check if this generates problems with the new triplet approach + 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() + + 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}") + if(VCPKG_DETECTED_CMAKE_AR) + z_vcpkg_append_to_configure_environment(configure_env AR "ar-lib ${VCPKG_DETECTED_CMAKE_AR}") + else() + z_vcpkg_append_to_configure_environment(configure_env AR "ar-lib lib.exe -verbose") + endif() + else() + 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}") + z_vcpkg_append_to_configure_environment(configure_env CXX "${VCPKG_DETECTED_CMAKE_CXX_COMPILER}") + if(NOT arg_BUILD_TRIPLET MATCHES "--host") + 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() + 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}") + if(VCPKG_DETECTED_CMAKE_AR) + z_vcpkg_append_to_configure_environment(configure_env AR "${VCPKG_DETECTED_CMAKE_AR}") + else() + z_vcpkg_append_to_configure_environment(configure_env AR "lib.exe -verbose") + endif() + endif() + z_vcpkg_append_to_configure_environment(configure_env LD "${VCPKG_DETECTED_CMAKE_LINKER} -verbose") + if(VCPKG_DETECTED_CMAKE_RANLIB) + z_vcpkg_append_to_configure_environment(configure_env RANLIB "${VCPKG_DETECTED_CMAKE_RANLIB}") # Trick to ignore the RANLIB call + else() + z_vcpkg_append_to_configure_environment(configure_env RANLIB ": RANLIB-disabled") + endif() + if(VCPKG_DETECTED_CMAKE_OBJDUMP) #Objdump is required to make shared libraries. Otherwise define lt_cv_deplibs_check_method=pass_all + z_vcpkg_append_to_configure_environment(configure_env OBJDUMP "${VCPKG_DETECTED_CMAKE_OBJDUMP}") # Trick to ignore the RANLIB call + endif() + if(VCPKG_DETECTED_CMAKE_STRIP) # If required set the ENV variable STRIP in the portfile correctly + z_vcpkg_append_to_configure_environment(configure_env STRIP "${VCPKG_DETECTED_CMAKE_STRIP}") + else() + z_vcpkg_append_to_configure_environment(configure_env STRIP ": STRIP-disabled") + list(APPEND arg_OPTIONS ac_cv_prog_ac_ct_STRIP=:) + endif() + if(VCPKG_DETECTED_CMAKE_NM) # If required set the ENV variable NM in the portfile correctly + z_vcpkg_append_to_configure_environment(configure_env NM "${VCPKG_DETECTED_CMAKE_NM}") + 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) + z_vcpkg_append_to_configure_environment(configure_env NM "dumpbin.exe -symbols -headers") + endif() + if(VCPKG_DETECTED_CMAKE_DLLTOOL) # If required set the ENV variable DLLTOOL in the portfile correctly + z_vcpkg_append_to_configure_environment(configure_env DLLTOOL "${VCPKG_DETECTED_CMAKE_DLLTOOL}") + else() + z_vcpkg_append_to_configure_environment(configure_env DLLTOOL "link.exe -verbose -dll") + endif() + + if(NOT "ASM" IN_LIST arg_LANGUAGES ) + z_vcpkg_append_to_configure_environment(configure_env CCAS ": CCAS-disabled") # If required set the ENV variable CCAS in the portfile correctly + z_vcpkg_append_to_configure_environment(configure_env AS ": AS-disabled") # If required set the ENV variable AS in the portfile correctly + + else() + set(ccas "${VCPKG_DETECTED_CMAKE_ASM_COMPILER}") + if(VCPKG_DETECTED_CMAKE_ASM_COMPILER_ID STREQUAL "MSVC") + if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86") + set(asmflags "--target=i686-pc-windows-msvc -m32") + elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64") + set(asmflags "--target=x86_64-pc-windows-msvc") + elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64") + set(asmflags "--target=arm64-pc-windows-msvc") + endif() + vcpkg_find_acquire_program(CLANG) + set(ccas "${CLANG}") + if(ccas MATCHES " ") + cmake_path(GET ccas PARENT_PATH ccas_dir) + cmake_path(GET ccas FILENAME ccas_filename) + vcpkg_insert_program_into_path("${ccas_dir}") + set(ccas "${ccas_filename}") + endif() + string(APPEND ccas " ${asmflags}") + endif() + z_vcpkg_append_to_configure_environment(configure_env CCAS "${ccas} -c") + z_vcpkg_append_to_configure_environment(configure_env AS "${ccas} -c") + endif() + + else() + # OSX dosn't like CMAKE_C(XX)_COMPILER (cc) in CC/CXX and rather wants to have gcc/g++ + vcpkg_list(SET z_vcm_all_tools) + function(z_vcpkg_make_set_env envvar cmakevar) + set(prog "${VCPKG_DETECTED_CMAKE_${cmakevar}}") + if(NOT DEFINED ENV{${envvar}} AND NOT prog STREQUAL "") + vcpkg_list(APPEND z_vcm_all_tools "${prog}") + if(ARGN) + string(APPEND prog " ${ARGN}") + endif() + set(z_vcm_all_tools "${z_vcm_all_tools}" PARENT_SCOPE) + endif() + z_vcpkg_append_to_configure_environment(configure_env "${envvar}" "${prog}") + set(configure_env "${configure_env}" PARENT_SCOPE) + endfunction() + + z_vcpkg_make_set_env(CC C_COMPILER ${ABIFLAGS_${arg_CONFIG}}) + z_vcpkg_make_set_env(CXX CXX_COMPILER ${ABIFLAGS_${arg_CONFIG}}) + if(NOT arg_BUILD_TRIPLET MATCHES "--host") + z_vcpkg_make_set_env(CC_FOR_BUILD C_COMPILER ${ABIFLAGS_${arg_CONFIG}}) + z_vcpkg_make_set_env(CPP_FOR_BUILD C_COMPILER "-E" ${ABIFLAGS_${arg_CONFIG}}) + z_vcpkg_make_set_env(CXX_FOR_BUILD CXX_COMPILER ${ABIFLAGS_${arg_CONFIG}}) + else() + set(ENV{CC_FOR_BUILD} "umask 0 | touch a.out | touch conftest${VCPKG_HOST_EXECUTABLE_SUFFIX} | true") + set(ENV{CPP_FOR_BUILD} "umask 0 | touch a.out | touch conftest${VCPKG_HOST_EXECUTABLE_SUFFIX} | true") + set(ENV{CXX_FOR_BUILD} "umask 0 | touch a.out | touch conftest${VCPKG_HOST_EXECUTABLE_SUFFIX} | true") + endif() + if("ASM" IN_LIST arg_LANGUAGES) + z_vcpkg_make_set_env(CCAS ASM_COMPILER "-c" ${ABIFLAGS_${arg_CONFIG}}) + z_vcpkg_make_set_env(AS ASM_COMPILER "-c" ${ABIFLAGS_${arg_CONFIG}}) + endif() + 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) + + list(FILTER z_vcm_all_tools INCLUDE REGEX " ") + if(z_vcm_all_tools) + list(REMOVE_DUPLICATES z_vcm_all_tools) + list(JOIN z_vcm_all_tools "\n " tools) + message(STATUS "Warning: Tools with embedded space may be handled incorrectly by configure:\n ${tools}") + endif() + endif() + list(JOIN configure_env " " configure_env) + set("${out_env}" "${configure_env}" PARENT_SCOPE) +endfunction() + +function(z_vcpkg_make_prepare_link_flags) + cmake_parse_arguments(PARSE_ARGV 0 arg + "VCPKG_TRANSFORM_LIBS" + "IN_OUT_VAR" + "" + ) + + set(link_flags ${${arg_IN_OUT_VAR}}) + + if(arg_VCPKG_TRANSFORM_LIBS) + list(TRANSFORM link_flags REPLACE "[.](dll[.]lib|lib|a|so)$" "") + + if(VCPKG_TARGET_IS_WINDOWS) + list(REMOVE_ITEM link_flags "uuid") + endif() + + list(TRANSFORM link_flags REPLACE "^([^-].*)" "-l\\1") + 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. + list(TRANSFORM link_flags REPLACE "^-luuid\$" "-Wl,-Bstatic,-luuid,-Bdynamic") + endif() + endif() + + set(${arg_IN_OUT_VAR} ${link_flags} PARENT_SCOPE) +endfunction() + +function(z_vcpkg_make_prepare_flags) + cmake_parse_arguments(PARSE_ARGV 0 arg + "DISABLE_CPPFLAGS;DISABLE_MSVC_WRAPPERS;NO_FLAG_ESCAPING" + "LIBS_OUT;FRONTEND_VARIANT_OUT;C_COMPILER_NAME" + "LANGUAGES" + ) + z_vcpkg_unparsed_args(FATAL_ERROR) + + z_vcpkg_make_get_cmake_vars(LANGUAGES ${arg_LANGUAGES}) + + # ==== LIBS + # TODO: Figure out what to do with other Languages like Fortran + # Remove outer quotes from cmake variables which will be forwarded via makefile/shell variables + # substituted into makefile commands (e.g. Android NDK has "--sysroot=...") + separate_arguments(c_libs_list NATIVE_COMMAND "${VCPKG_DETECTED_CMAKE_C_STANDARD_LIBRARIES}") + separate_arguments(cxx_libs_list NATIVE_COMMAND "${VCPKG_DETECTED_CMAKE_CXX_STANDARD_LIBRARIES}") + list(REMOVE_ITEM cxx_libs_list ${c_libs_list}) + set(all_libs_list ${cxx_libs_list} ${c_libs_list}) + + # Do lib list transformation from name.lib to -lname if necessary + set(vcpkg_transform_libs VCPKG_TRANSFORM_LIBS) + if(VCPKG_DETECTED_CMAKE_C_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC" AND (arg_NO_FLAG_ESCAPING)) + set(vcpkg_transform_libs "") + endif() + + if(VCPKG_TARGET_IS_UWP) + # 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. + set(vcpkg_transform_libs "") + endif() + + z_vcpkg_make_prepare_link_flags( + IN_OUT_VAR all_libs_list + ${vcpkg_transform_libs} + ) + + if(all_libs_list) + list(JOIN all_libs_list " " all_libs_string) + if(DEFINED ENV{LIBS}) + set(ENV{LIBS} "$ENV{LIBS} ${all_libs_string}") + else() + set(ENV{LIBS} "${all_libs_string}") + endif() + endif() + + set("${arg_LIBS_OUT}" "${all_libs_string}" PARENT_SCOPE) + + # ==== /LIBS + + if(VCPKG_TARGET_IS_WINDOWS) + vcpkg_backup_env_variables(VARS _CL_ _LINK_) + # 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) + 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_COMBINED_CXX_FLAGS_DEBUG}") + string(REPLACE "${_replacement}" "" VCPKG_DETECTED_CMAKE_C_FLAGS_DEBUG "${VCPKG_COMBINED_C_FLAGS_DEBUG}") + string(REPLACE "${_replacement}" "" VCPKG_DETECTED_CMAKE_CXX_FLAGS_RELEASE "${VCPKG_COMBINED_CXX_FLAGS_RELEASE}") + string(REPLACE "${_replacement}" "" VCPKG_DETECTED_CMAKE_C_FLAGS_RELEASE "${VCPKG_COMBINED_C_FLAGS_RELEASE}") + 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}") + endif() + endif() + + #### + set(flags_opts "") + if(DEFINED arg_LANGUAGES) + list(APPEND flags_opts LANGUAGES ${arg_LANGUAGES}) + endif() + + if(arg_DISABLE_CPPFLAGS) + list(APPEND flags_opts DISABLE_CPPFLAGS) + endif() + + if(arg_DISABLE_MSVC_WRAPPERS) + list(APPEND flags_opts DISABLE_MSVC_WRAPPERS) + endif() + + if(arg_NO_FLAG_ESCAPING) + list(APPEND flags_opts NO_FLAG_ESCAPING) + endif() + + z_vcpkg_make_prepare_compile_flags( + CONFIG RELEASE + COMPILER_FRONTEND "${VCPKG_DETECTED_CMAKE_C_COMPILER_FRONTEND_VARIANT}" + FLAGS_OUT release_flags_list + ${flags_opts} + ) + if(NOT DEFINED VCPKG_BUILD_TYPE) + list(APPEND all_buildtypes DEBUG) + z_vcpkg_make_prepare_compile_flags( + CONFIG DEBUG + COMPILER_FRONTEND "${VCPKG_DETECTED_CMAKE_C_COMPILER_FRONTEND_VARIANT}" + FLAGS_OUT debug_flags_list + ${flags_opts} + ) + endif() + + foreach(flag IN LISTS release_flags_list debug_flags_list) + set("${flag}" "${${flag}}" PARENT_SCOPE) + endforeach() + + cmake_path(GET VCPKG_DETECTED_CMAKE_C_COMPILER FILENAME cname) + set("${C_COMPILER_NAME}" "${cname}" PARENT_SCOPE) # needed by z_vcpkg_make_get_configure_triplets + set("${arg_FRONTEND_VARIANT_OUT}" "${VCPKG_DETECTED_CMAKE_C_COMPILER_FRONTEND_VARIANT}" PARENT_SCOPE) +endfunction() + +function(z_vcpkg_make_default_path_and_configure_options out_var) + cmake_parse_arguments(PARSE_ARGV 1 arg + "AUTOMAKE" + "CONFIG;EXCLUDE_FILTER;INCLUDE_FILTER" + "" + ) + z_vcpkg_unparsed_args(FATAL_ERROR) + + set(opts "") + string(TOUPPER "${arg_CONFIG}" arg_CONFIG) + + z_vcpkg_make_set_common_vars() + + list(APPEND opts lt_cv_deplibs_check_method=pass_all) + + # Pre-processing windows configure requirements + if (VCPKG_TARGET_IS_WINDOWS) + # 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. + list(APPEND opts gl_cv_double_slash_root=yes + ac_cv_func_memmove=yes + ac_cv_func_memset=yes + ) + + if(VCPKG_TARGET_ARCHITECTURE MATCHES "^[Aa][Rr][Mm]64$") + list(APPEND opts gl_cv_host_cpu_c_abi=no) + endif() + endif() + + # Set configure paths + set(current_installed_dir_msys "${CURRENT_INSTALLED_DIR}") + if(CMAKE_HOST_WIN32) + string(REGEX REPLACE "^([a-zA-Z]):/" "/\\1/" current_installed_dir_msys "${current_installed_dir_msys}") + endif() + vcpkg_list(APPEND opts "--prefix=${current_installed_dir_msys}${path_suffix_${arg_CONFIG}}") + + if(arg_CONFIG STREQUAL "RELEASE") + # ${prefix} has an extra backslash to prevent early expansion when calling `bash -c configure "..."`. + vcpkg_list(APPEND opts + # Important: These should all be relative to prefix! + "--bindir=\\\${prefix}/tools/${PORT}/bin" + "--sbindir=\\\${prefix}/tools/${PORT}/sbin" + "--libdir=\\\${prefix}/lib" # On some Linux distributions lib64 is the default + "--mandir=\\\${prefix}/share/${PORT}" + "--docdir=\\\${prefix}/share/${PORT}" + "--datarootdir=\\\${prefix}/share/${PORT}") + else() + vcpkg_list(APPEND opts + # Important: These should all be relative to prefix! + "--bindir=\\\${prefix}/../tools/${PORT}${path_suffix_DEBUG}/bin" + "--sbindir=\\\${prefix}/../tools/${PORT}${path_suffix_DEBUG}/sbin" + "--libdir=\\\${prefix}/lib" # On some Linux distributions lib64 is the default + "--includedir=\\\${prefix}/../include" + "--mandir=\\\${prefix}/share/${PORT}" + "--docdir=\\\${prefix}/share/${PORT}" + "--datarootdir=\\\${prefix}/share/${PORT}") + endif() + # Setup common options + if(NOT arg_AUTOMAKE) + vcpkg_list(APPEND opts --disable-silent-rules --verbose) + endif() + + if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic") + vcpkg_list(APPEND opts --enable-shared --disable-static) + else() + vcpkg_list(APPEND opts --disable-shared --enable-static) + endif() + + if(DEFINED arg_EXCLUDE_FILTER) + list(FILTER opts EXCLUDE REGEX "${arg_EXCLUDE_FILTER}") + endif() + + if(DEFINED arg_INCLUDE_FILTER) + list(FILTER opts INCLUDE REGEX "${arg_INCLUDE_FILTER}") + endif() + + set("${out_var}" ${opts} PARENT_SCOPE) +endfunction() diff --git a/vcpkg/ports/vcpkg-make/vcpkg_make_configure.cmake b/vcpkg/ports/vcpkg-make/vcpkg_make_configure.cmake new file mode 100644 index 0000000000..d58200fdc1 --- /dev/null +++ b/vcpkg/ports/vcpkg-make/vcpkg_make_configure.cmake @@ -0,0 +1,135 @@ +include_guard(GLOBAL) +include("${CMAKE_CURRENT_LIST_DIR}/vcpkg_make.cmake") + +function(vcpkg_make_configure) + cmake_parse_arguments(PARSE_ARGV 0 arg + "AUTORECONF;COPY_SOURCE;DISABLE_MSVC_WRAPPERS;DISABLE_CPPFLAGS;DISABLE_DEFAULT_OPTIONS;DISABLE_MSVC_TRANSFORMATIONS" + "SOURCE_PATH" + "OPTIONS;OPTIONS_DEBUG;OPTIONS_RELEASE;PRE_CONFIGURE_CMAKE_COMMANDS;LANGUAGES" + ) + + z_vcpkg_unparsed_args(FATAL_ERROR) + + # Can be set in the triplet to append options for configure + if(DEFINED VCPKG_MAKE_CONFIGURE_OPTIONS) + list(APPEND arg_OPTIONS ${VCPKG_MAKE_CONFIGURE_OPTIONS}) + endif() + if(DEFINED VCPKG_MAKE_CONFIGURE_OPTIONS_RELEASE) + list(APPEND arg_OPTIONS_RELEASE ${VCPKG_MAKE_CONFIGURE_OPTIONS_RELEASE}) + endif() + if(DEFINED VCPKG_MAKE_CONFIGURE_OPTIONS_DEBUG) + list(APPEND arg_OPTIONS_DEBUG ${VCPKG_MAKE_CONFIGURE_OPTIONS_DEBUG}) + endif() + + set(src_dir "${arg_SOURCE_PATH}") + + z_vcpkg_warn_path_with_spaces() + + set(prepare_flags_opts "") + if(arg_DISABLE_MSVC_WRAPPERS) + list(APPEND prepare_flags_opts "DISABLE_MSVC_WRAPPERS") + endif() + if(arg_DISABLE_CPPFLAGS) + list(APPEND prepare_flags_opts "DISABLE_CPPFLAGS") + endif() + if(DEFINED arg_LANGUAGES) + list(APPEND prepare_flags_opts "LANGUAGES" ${arg_LANGUAGES}) + endif() + + # Create cached cmake vars for this invocation's languages + z_vcpkg_make_get_cmake_vars(LANGUAGES ${arg_LANGUAGES}) + + set(escaping "") + if(arg_DISABLE_MSVC_TRANSFORMATIONS) + set(escaping NO_FLAG_ESCAPING) + endif() + + z_vcpkg_set_global_property(make_prepare_flags_opts "${prepare_flags_opts}") + z_vcpkg_make_prepare_flags(${prepare_flags_opts} ${escaping} C_COMPILER_NAME ccname FRONTEND_VARIANT_OUT frontend) + + 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. + vcpkg_add_to_path(PREPEND "${CURRENT_HOST_INSTALLED_DIR}/share/vcpkg-make/wrappers") + endif() + + vcpkg_make_get_shell(shell_var) + set(shell_cmd "${shell_var}") + + if(arg_AUTORECONF) + vcpkg_run_autoreconf("${shell_cmd}" "${src_dir}") + endif() + + # Backup environment variables + set(cm_FLAGS AR AS CC C CCAS CPP CXX FC FF GC LD LF LIBTOOL OBJC OBJXX R RC UPC Y) + + list(TRANSFORM cm_FLAGS APPEND "FLAGS") + vcpkg_backup_env_variables(VARS + ${cm_FLAGS} + # General backup + PATH + # Used by gcc/linux + C_INCLUDE_PATH CPLUS_INCLUDE_PATH LIBRARY_PATH LD_LIBRARY_PATH + # Used by cl + INCLUDE LIB LIBPATH _CL_ _LINK_ + ) + z_vcpkg_make_set_common_vars() + + foreach(config IN LISTS buildtypes) + string(TOUPPER "${config}" configup) + set(target_dir "${workdir_${configup}}") + file(REMOVE_RECURSE "${target_dir}") + file(MAKE_DIRECTORY "${target_dir}") + file(RELATIVE_PATH relative_build_path "${target_dir}" "${src_dir}") + if(arg_COPY_SOURCE) + file(COPY "${src_dir}/" DESTINATION "${target_dir}") + set(relative_build_path ".") + endif() + + z_vcpkg_make_prepare_programs(configure_env ${prepare_flags_opts} CONFIG "${configup}" BUILD_TRIPLET "${BUILD_TRIPLET}") + + set(opts "") + if(NOT arg_DISABLE_DEFAULT_OPTIONS) + z_vcpkg_make_default_path_and_configure_options(opts AUTOMAKE CONFIG "${configup}") + vcpkg_list(APPEND arg_OPTIONS ${opts}) + endif() + + set(configure_path_from_wd "./${relative_build_path}/configure") + + foreach(cmd IN LISTS arg_PRE_CONFIGURE_CMAKE_COMMANDS) + cmake_language(CALL ${cmd} ${configup}) + endforeach() + + vcpkg_make_run_configure(SHELL + "${shell_cmd}" + CONFIG + "${configup}" + CONFIGURE_ENV + "${configure_env}" + CONFIGURE_PATH + "${configure_path_from_wd}" + OPTIONS + ${BUILD_TRIPLET} + ${arg_OPTIONS} + ${arg_OPTIONS_${configup}} + WORKING_DIRECTORY + "${target_dir}" + ${extra_configure_opts} + ) + endforeach() + + # Restore environment + vcpkg_restore_env_variables(VARS + ${cm_FLAGS} + C_INCLUDE_PATH CPLUS_INCLUDE_PATH LIBRARY_PATH LD_LIBRARY_PATH + INCLUDE LIB LIBPATH _CL_ _LINK_ + ) + + find_program(Z_VCPKG_MAKE NAMES make gmake NAMES_PER_DIR REQUIRED) +endfunction() diff --git a/vcpkg/ports/vcpkg-make/vcpkg_make_install.cmake b/vcpkg/ports/vcpkg-make/vcpkg_make_install.cmake new file mode 100644 index 0000000000..76bfae4051 --- /dev/null +++ b/vcpkg/ports/vcpkg-make/vcpkg_make_install.cmake @@ -0,0 +1,134 @@ +include_guard(GLOBAL) +include("${CMAKE_CURRENT_LIST_DIR}/vcpkg_make.cmake") + +function(vcpkg_make_install) + cmake_parse_arguments(PARSE_ARGV 0 arg + "DISABLE_PARALLEL" + "LOGFILE_ROOT;MAKEFILE;TARGETS" + "OPTIONS;OPTIONS_DEBUG;OPTIONS_RELEASE" + ) + z_vcpkg_unparsed_args(FATAL_ERROR) + + if(NOT DEFINED arg_LOGFILE_ROOT) + set(arg_LOGFILE_ROOT "make") + endif() + + if(NOT DEFINED arg_TARGETS) + set(arg_TARGETS "all;install") + endif() + + if (NOT DEFINED arg_MAKEFILE) + set(arg_MAKEFILE Makefile) + endif() + + # Can be set in the triplet to append options for configure + if(DEFINED VCPKG_MAKE_OPTIONS) + list(APPEND arg_OPTIONS ${VCPKG_MAKE_OPTIONS}) + endif() + if(DEFINED VCPKG_MAKE_OPTIONS_RELEASE) + list(APPEND arg_OPTIONS_RELEASE ${VCPKG_MAKE_OPTIONS_RELEASE}) + endif() + if(DEFINED VCPKG_MAKE_OPTIONS_DEBUG) + list(APPEND arg_OPTIONS_DEBUG ${VCPKG_MAKE_OPTIONS_DEBUG}) + endif() + + if(CMAKE_HOST_WIN32) + set(Z_VCPKG_INSTALLED "${CURRENT_INSTALLED_DIR}") + else() + string(REPLACE " " "\ " Z_VCPKG_INSTALLED "${CURRENT_INSTALLED_DIR}") + endif() + + vcpkg_make_get_shell(shell_var) + set(shell_cmd "${shell_var}") + + find_program(Z_VCPKG_MAKE NAMES make gmake NAMES_PER_DIR REQUIRED) + set(make_command "${Z_VCPKG_MAKE}") + + set(destdir "${CURRENT_PACKAGES_DIR}") + if (CMAKE_HOST_WIN32) + set(path_backup "$ENV{PATH}") + vcpkg_add_to_path(PREPEND "${CURRENT_HOST_INSTALLED_DIR}/share/vcpkg-make/wrappers") + string(REPLACE " " [[\ ]] vcpkg_package_prefix "${CURRENT_PACKAGES_DIR}") + string(REGEX REPLACE [[([a-zA-Z]):/]] [[/\1/]] destdir "${vcpkg_package_prefix}") + endif() + + vcpkg_backup_env_variables(VARS LIB LIBPATH LIBRARY_PATH LD_LIBRARY_PATH CPPFLAGS CFLAGS CXXFLAGS RCFLAGS PATH) + + z_vcpkg_make_set_common_vars() + z_vcpkg_get_global_property(prepare_flags_opts "make_prepare_flags_opts") + + z_vcpkg_make_prepare_flags(${prepare_flags_opts}) + + set(prepare_env_opts "") + + foreach(buildtype IN LISTS buildtypes) + string(TOUPPER "${buildtype}" cmake_buildtype) + set(short_buildtype "${suffix_${cmake_buildtype}}") + set(path_suffix "${path_suffix_${cmake_buildtype}}") + + set(working_directory "${workdir_${cmake_buildtype}}") + message(STATUS "Building/Installing ${TARGET_TRIPLET}-${short_buildtype}") + + # Setup environment + z_vcpkg_make_prepare_env("${cmake_buildtype}" ${prepare_env_opts}) + z_vcpkg_make_prepare_programs(configure_env ${prepare_flags_opts} CONFIG "${cmake_buildtype}") + + set(destdir_opt "DESTDIR=${destdir}") + + set(extra_opts "") + if(NOT VCPKG_TARGET_IS_OSX) + set(extra_opts --trace) + endif() + + foreach(target IN LISTS arg_TARGETS) + vcpkg_list(SET make_cmd_line ${make_command} ${arg_OPTIONS} ${arg_OPTIONS_${cmake_buildtype}} V=1 -j ${VCPKG_CONCURRENCY} ${extra_opts} -f ${arg_MAKEFILE} ${target} ${destdir_opt}) + vcpkg_list(SET no_parallel_make_cmd_line ${make_command} ${arg_OPTIONS} ${arg_OPTIONS_${cmake_buildtype}} V=1 -j 1 ${extra_opts} -f ${arg_MAKEFILE} ${target} ${destdir_opt}) + message(STATUS "Making target '${target}' for ${TARGET_TRIPLET}-${short_buildtype}") + if (arg_DISABLE_PARALLEL) + vcpkg_run_shell_as_build( + WORKING_DIRECTORY "${working_directory}" + LOGNAME "${arg_LOGFILE_ROOT}-${target}-${TARGET_TRIPLET}-${short_buildtype}" + SHELL ${shell_cmd} + NO_PARALLEL_COMMAND ${configure_env} ${no_parallel_make_cmd_line} + ) + else() + vcpkg_run_shell_as_build( + WORKING_DIRECTORY "${working_directory}" + LOGNAME "${arg_LOGFILE_ROOT}-${target}-${TARGET_TRIPLET}-${short_buildtype}" + SHELL ${shell_cmd} + COMMAND ${configure_env} ${no_parallel_make_cmd_line} + NO_PARALLEL_COMMAND ${configure_env} ${no_parallel_make_cmd_line} + ) + endif() + file(READ "${CURRENT_BUILDTREES_DIR}/${arg_LOGFILE_ROOT}-${target}-${TARGET_TRIPLET}-${short_buildtype}-out.log" logdata) + if(logdata MATCHES "Warning: linker path does not have real file for library") + message(FATAL_ERROR "libtool could not find a file being linked against!") + endif() + endforeach() + + z_vcpkg_make_restore_env() + + vcpkg_restore_env_variables(VARS LIB LIBPATH LIBRARY_PATH) + endforeach() + + ## TODO: Fix DESTDIR handling + string(REGEX REPLACE "([a-zA-Z]):/" "/\\1/" destdir_suffix "${CURRENT_INSTALLED_DIR}") + if (EXISTS "${CURRENT_PACKAGES_DIR}${destdir_suffix}") # <- Means DESTDIR was correctly used; need to move files. + file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}_tmp") + file(RENAME "${CURRENT_PACKAGES_DIR}" "${CURRENT_PACKAGES_DIR}_tmp") + file(RENAME "${CURRENT_PACKAGES_DIR}_tmp${destdir_suffix}" "${CURRENT_PACKAGES_DIR}") + file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}_tmp") + endif() + + # Remove libtool files since they contain absolute paths and are not necessary. + file(GLOB_RECURSE libtool_files "${CURRENT_PACKAGES_DIR}/**/*.la") + if(libtool_files) + file(REMOVE ${libtool_files}) + endif() + + if (CMAKE_HOST_WIN32) + set(ENV{PATH} "${path_backup}") + endif() + + vcpkg_restore_env_variables(VARS LIB LIBPATH LIBRARY_PATH LD_LIBRARY_PATH CPPFLAGS CFLAGS CXXFLAGS RCFLAGS) +endfunction() diff --git a/vcpkg/ports/vcpkg-make/vcpkg_scripts.cmake b/vcpkg/ports/vcpkg-make/vcpkg_scripts.cmake new file mode 100644 index 0000000000..6489635a8c --- /dev/null +++ b/vcpkg/ports/vcpkg-make/vcpkg_scripts.cmake @@ -0,0 +1,203 @@ +include_guard(GLOBAL) +function(vcpkg_insert_into_path) + cmake_parse_arguments(PARSE_ARGV 0 arg + "" + "PATH_OUT;APPENDED_OUT" + "BEFORE;INSERT" + ) + z_vcpkg_unparsed_args(FATAL_ERROR) + cmake_path(CONVERT "$ENV{PATH}" TO_CMAKE_PATH_LIST path_list NORMALIZE) + + string(TOUPPER "${arg_BEFORE}" before_upper) + + set(index 0) + set(appending TRUE) + foreach(item IN LISTS path_list) + string(TOUPPER "${item}" item_upper) + if(item IN_LIST arg_BEFORE OR item_upper IN_LIST before_upper) + set(appending FALSE) + break() + endif() + math(EXPR index "${index} + 1") + endforeach() + + vcpkg_list(INSERT path_list "${index}" ${arg_INSERT}) + + cmake_path(CONVERT "${path_list}" TO_NATIVE_PATH_LIST native_path_list) + set(ENV{PATH} "${native_path_list}") + if(DEFINED arg_PATH_OUT) + set("${arg_PATH_OUT}" "${path_list}" PARENT_SCOPE) + endif() + if(appending) + set("${arg_APPENDED_OUT}" "TRUE" PARENT_SCOPE) + else() + set("${arg_APPENDED_OUT}" "FALSE" PARENT_SCOPE) + endif() +endfunction() + +function(vcpkg_insert_program_into_path prog) + set(filepath "${prog}") + cmake_path(GET filepath FILENAME ${prog}) + find_program(z_vcm_prog_found NAMES "${${prog}}" PATHS ENV PATH NO_DEFAULT_PATH NO_CACHE) + if(NOT z_vcm_prog_found STREQUAL filepath) + cmake_path(GET z_vcm_prog_found PARENT_PATH before_dir) + cmake_path(GET filepath PARENT_PATH dir) + vcpkg_insert_into_path( + INSERT "${dir}" + BEFORE "${before_dir}" + ) + endif() +endfunction() + +function(vcpkg_insert_msys_into_path msys_out) + cmake_parse_arguments(PARSE_ARGV 1 arg + "" + "PATH_OUT" + "PACKAGES" + ) + z_vcpkg_unparsed_args(FATAL_ERROR) + vcpkg_acquire_msys(MSYS_ROOT PACKAGES ${arg_PACKAGES}) + 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) + + vcpkg_list(SET find_system_dirs + "${system_root}/system32" + "${system_root}/System32" + "${system_root}/system32/" + "${system_root}/System32/" + "${local_app_data}/Microsoft/WindowsApps" + "${local_app_data}/Microsoft/WindowsApps/" + ) + + vcpkg_insert_into_path( + INSERT "${MSYS_ROOT}/usr/bin" + BEFORE ${find_system_dirs} + PATH_OUT path_out + APPENDED_OUT appending + ) + + if(appending) + message(WARNING "Unable to find system dir in the PATH variable! Appending required msys paths!") + endif() + + if(DEFINED arg_PATH_OUT) + set("${arg_PATH_OUT}" "${path_out}" PARENT_SCOPE) + endif() + + set("${msys_out}" "${MSYS_ROOT}" PARENT_SCOPE) +endfunction() + +### Helper macros for argument checking +macro(z_vcpkg_unparsed_args warning_level) + if(DEFINED arg_UNPARSED_ARGUMENTS) + message("${warning_level}" "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}") + endif() +endmacro() + +macro(z_vcpkg_conflicting_args) + set(conflicting_args_set "") + foreach(z_vcpkg_conflicting_args_index RANGE 0 "${ARGC}") + if(${ARGV${z_vcpkg_conflicting_args_index}}) + list(APPEND conflicting_args_set "${ARGV${z_vcpkg_conflicting_args_index}}") + endif() + endforeach() + list(LENGTH conflicting_args_set conflicting_args_set_length) + if(conflicting_args_set_length GREATER 1) + message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} was passed conflicting arguments:'${conflicting_args_set}'. Only one of those arguments can be passed") + endif() + unset(conflicting_args_set_length) + unset(conflicting_args_set) + unset(z_vcpkg_conflicting_args_index) +endmacro() + +macro(z_vcpkg_required_args arg) + foreach(arg IN ITEMS ${ARGN}) + if(NOT DEFINED arg_${arg}) + message("FATAL_ERROR" "${CMAKE_CURRENT_FUNCTION} requires argument: ${arg}") + endif() + endforeach() +endmacro() + +function(z_vcpkg_set_global_property property value) + if(NOT ARGN STREQUAL "" AND NOT ARGN MATCHES "^APPEND(_STRING)?$") + message(FATAL_ERROR "'${CMAKE_CURRENT_FUNCTION}' called with invalid arguments '${ARGN}'") + endif() + set_property(GLOBAL ${ARGN} PROPERTY "z_vcpkg_global_property_${property}" "${value}") +endfunction() + +function(z_vcpkg_get_global_property outvar property) + if(NOT ARGN STREQUAL "" AND NOT ARGN STREQUAL "SET") + message(FATAL_ERROR "'${CMAKE_CURRENT_FUNCTION}' called with invalid arguments '${ARGN}'") + endif() + get_property(outprop GLOBAL PROPERTY "z_vcpkg_global_property_${property}" ${ARGN}) + set(${outvar} "${outprop}" PARENT_SCOPE) +endfunction() + +function(vcpkg_prepare_pkgconfig config) + set(subdir "") + if(config MATCHES "(DEBUG|debug)") + set(subdir "/debug") + endif() + + z_vcpkg_get_global_property(has_backup "make-pkg-config-backup-${envvar}" SET) + if(has_backup) + message(FATAL_ERROR "'${CMAKE_CURRENT_FUNCTION}' does not (yet) support recursive backups. Need to restore previous state first!") + endif() + + foreach(envvar IN ITEMS PKG_CONFIG PKG_CONFIG_PATH) + if(DEFINED ENV{${envvar}}) + z_vcpkg_set_global_property("make-pkg-config-backup-${envvar}" "$ENV{${envvar}}") + else() + z_vcpkg_set_global_property("make-pkg-config-backup-${envvar}" "") + endif() + endforeach() + + vcpkg_find_acquire_program(PKGCONFIG) + set(ENV{PKG_CONFIG} "${PKGCONFIG}") + + vcpkg_host_path_list(PREPEND ENV{PKG_CONFIG_PATH} + # After installation, (merged) 'lib' is always searched before 'share'. + "${CURRENT_PACKAGES_DIR}${subdir}/lib/pkgconfig" + "${CURRENT_INSTALLED_DIR}${subdir}/lib/pkgconfig" + "${CURRENT_PACKAGES_DIR}/share/pkgconfig" + "${CURRENT_INSTALLED_DIR}/share/pkgconfig" + ) +endfunction() + +function(vcpkg_restore_pkgconfig) + foreach(envvar IN ITEMS PKG_CONFIG PKG_CONFIG_PATH) + z_vcpkg_get_global_property(has_backup "make-pkg-config-backup-${envvar}" SET) + if(has_backup) + z_vcpkg_get_global_property(backup "make-pkg-config-backup-${envvar}") + set("ENV{${envvar}}" "${backup}") + z_vcpkg_set_global_property("make-pkg-config-backup-${envvar}" "") + else() + unset("ENV{${envvar}}") + endif() + endforeach() +endfunction() + +function(z_vcpkg_escape_spaces_in_path outvar invar) + string(REPLACE " " "\\ " current_installed_dir_escaped "${invar}") + set("${outvar}" "${current_installed_dir_escaped}" PARENT_SCOPE) +endfunction() + +function(z_vcpkg_warn_path_with_spaces) + vcpkg_list(SET z_vcm_paths_with_spaces) + if(CURRENT_BUILDTREES_DIR MATCHES " ") + vcpkg_list(APPEND z_vcm_paths_with_spaces "${CURRENT_BUILDTREES_DIR}") + endif() + if(CURRENT_PACKAGES_DIR MATCHES " ") + vcpkg_list(APPEND z_vcm_paths_with_spaces "${CURRENT_PACKAGES_DIR}") + endif() + if(CURRENT_INSTALLED_DIR MATCHES " ") + vcpkg_list(APPEND z_vcm_paths_with_spaces "${CURRENT_INSTALLED_DIR}") + endif() + if(z_vcm_paths_with_spaces) + # Don't bother with whitespace. The tools will probably fail and I tried very hard trying to make it work (no success so far)! + vcpkg_list(APPEND z_vcm_paths_with_spaces "Please move the path to one without whitespaces!") + list(JOIN z_vcm_paths_with_spaces "\n " z_vcm_paths_with_spaces) + message(STATUS "Warning: Paths with embedded space may be handled incorrectly by configure:\n ${z_vcm_paths_with_spaces}") + endif() +endfunction() diff --git a/vcpkg/ports/vcpkg-make/wrappers/cl_cpp_wrapper b/vcpkg/ports/vcpkg-make/wrappers/cl_cpp_wrapper new file mode 100644 index 0000000000..fb83f7b886 --- /dev/null +++ b/vcpkg/ports/vcpkg-make/wrappers/cl_cpp_wrapper @@ -0,0 +1,95 @@ +#!/usr/bin/bash +# cl_cpp_wrapper +# Wrapper around MS's cl.exe to make it act more like Unix cpp + +PATH="$PATH:/usr/bin" + +case $MACHTYPE in + *-msys) + slash="-" + ;; + *) + slash="/" + ;; +esac + +# prog specifies the program that should be run cl.exe +prog=cl.exe +debug= +cppopt=("${slash}nologo") +cppopt+=("${slash}E") +verbose= +shared_index=-1 + +processargs() +{ +### Run through every option and convert it to the proper MS one +while test $# -gt 0; do + case "$1" in + -D*) optarg= ;; + -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;; + *) optarg= ;; + esac + gotparam=1 + case "$1" in + --help) + usage + exit 0 + ;; + --verbose) + verbose=1 + ;; + -*) + # Remaining '-' options are passed to the compiler + if test x$optarg != x ; then + cppopt+=("${slash}${1:1}=$optarg") + else + cppopt+=("${slash}${1:1}") + fi + ;; + + /*) + # All '/' options are assumed to be for cpp and are passed through + cppopt+=("${slash}${1:1}") + ;; + + *) + file=$1 + #cppopt+=("$1") + ;; + esac + shift +done +} + +# Whitespace in paths is dealt with by setting IFS and using bash arrays + +# processargs $CPP_FLAGS +IFS="" +processargs $@ + +if test x$V = x1 ; then + verbose=1 +fi + +if test -n "$verbose" ; then + echo -n "$prog" + for opt in "${cppopt[@]}" ; do + echo -n " \"$opt\"" + done + echo "" +fi + +[ $# -ge 1 -a -f "$1" ] && input="$file" || input="-" + +input_file="${file:-/proc/self/fd/0}" +if [ "$input_file" == "/proc/self/fd/0" ]; then + # CL does not support reading from STDIN so it is wrapped here. + tmpout=cpp_wrapper_$RANDOM.h + /usr/bin/cp $input_file $tmpout + exec $prog ${cppopt[@]} $tmpout + rm -f $tmpout +else + exec $prog ${cppopt[@]} $input_file +fi + diff --git a/vcpkg/ports/vcpkg-make/wrappers/windres-rc b/vcpkg/ports/vcpkg-make/wrappers/windres-rc new file mode 100644 index 0000000000..93e0b127d3 --- /dev/null +++ b/vcpkg/ports/vcpkg-make/wrappers/windres-rc @@ -0,0 +1,122 @@ +#! /bin/sh +# Wrapper for windres to rc which do not understand '-i -o --output-format'. +# cvtres is invoked by the linker +scriptversion=2022-08-24.12; # UTC + + +nl=' +' + +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent tools from complaining about whitespace usage. +IFS=" "" $nl" + +file_conv= + +# func_file_conv build_file lazy +# Convert a $build file to $host form and store it in $file +# Currently only supports Windows hosts. If the determined conversion +# type is listed in (the comma separated) LAZY, no conversion will +# take place. +func_file_conv () +{ + file=$1 + case $file in + / | /[!/]*) # absolute file, and not a UNC file + if test -z "$file_conv"; then + # lazily determine how to convert abs files + case `uname -s` in + MINGW*) + file_conv=mingw + ;; + CYGWIN* | MSYS*) + file_conv=cygwin + ;; + *) + file_conv=wine + ;; + esac + fi + case $file_conv/,$2, in + *,$file_conv,*) + ;; + mingw/*) + file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` + ;; + cygwin/* | msys/*) + file=`cygpath -m "$file" || echo "$file"` + ;; + wine/*) + file=`winepath -w "$file" || echo "$file"` + ;; + esac + ;; + esac +} + +# func_windres_wrapper rc args... +# Adjust compile command to suit rc instead of windres +func_windres_wrapper () +{ + # Assume a capable shell + bin= + in= + out= + + for arg + do + if test -z "$bin"; then + bin=$1 + elif test -n "$eat"; then + eat= + else + case $1 in + --output-format=*) + ;; + --define*) + eat=1 + set -- "$@" "-d $2" + ;; + --include-dir*) + eat=1 + func_file_conv "$2" + set -- "$@" "-I $file" + ;; + -o) + eat=1 + func_file_conv "$2" + out="$file" + echo "OUTPUT:$file" + ;; + *.obj) + func_file_conv "$1" + out="$file" + echo "OUTPUT:$file" + ;; + -i) + eat=1 + func_file_conv "$2" mingw + in="$file" + echo "INPUT:$file" + ;; + -*) + set -- "$@" "${1//\\\"/\"}" + ;; + *) + # libtool reorders arguments; save unqualified one as input + func_file_conv "$1" + in="$file" + echo "INPUT:$file" + ;; + esac + fi + shift + done + echo "$bin" "$@" -fo "$out" "$in" + exec "$bin" "$@" -fo "$out" "$in" + exit 1 +} + +eat= + +func_windres_wrapper "$@" From eb47018eaf1a7ff75af2385377cb9111ae09eaa1 Mon Sep 17 00:00:00 2001 From: Mathieu Pellerin Date: Thu, 16 Jan 2025 15:40:11 +0700 Subject: [PATCH 4/6] Add a couple of ports to fix iOS and windows building --- vcpkg/ports/libb2/portfile.cmake | 29 +++++++++++++++++ vcpkg/ports/libb2/vcpkg.json | 8 +++++ vcpkg/ports/nu-book-zxing-cpp/portfile.cmake | 34 ++++++++++++++++++++ vcpkg/ports/nu-book-zxing-cpp/vcpkg.json | 17 ++++++++++ 4 files changed, 88 insertions(+) create mode 100644 vcpkg/ports/libb2/portfile.cmake create mode 100644 vcpkg/ports/libb2/vcpkg.json create mode 100644 vcpkg/ports/nu-book-zxing-cpp/portfile.cmake create mode 100644 vcpkg/ports/nu-book-zxing-cpp/vcpkg.json diff --git a/vcpkg/ports/libb2/portfile.cmake b/vcpkg/ports/libb2/portfile.cmake new file mode 100644 index 0000000000..452218f280 --- /dev/null +++ b/vcpkg/ports/libb2/portfile.cmake @@ -0,0 +1,29 @@ +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO BLAKE2/libb2 + REF 2c5142f12a2cd52f3ee0a43e50a3a76f75badf85 + SHA512 cf29cf9391ae37a978eb6618de6f856f3defa622b8f56c2d5a519ab34fd5e4d91f3bb868601a44e9c9164a2992e80dde188ccc4d1605dffbdf93687336226f8d + HEAD_REF master +) + +set(OPTIONS) +if(CMAKE_HOST_WIN32) + set(OPTIONS --disable-native) # requires cpuid +endif() + +vcpkg_configure_make( + AUTOCONFIG + SOURCE_PATH ${SOURCE_PATH} + OPTIONS + ax_cv_check_cflags___O3=no # see https://github.com/microsoft/vcpkg/pull/17912#issuecomment-840514179 + ${OPTIONS} +) +vcpkg_install_make() +vcpkg_fixup_pkgconfig() + + +file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) + +vcpkg_copy_pdbs() + +file(INSTALL ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) diff --git a/vcpkg/ports/libb2/vcpkg.json b/vcpkg/ports/libb2/vcpkg.json new file mode 100644 index 0000000000..e8ef8ec057 --- /dev/null +++ b/vcpkg/ports/libb2/vcpkg.json @@ -0,0 +1,8 @@ +{ + "name": "libb2", + "version": "0.98.1", + "port-version": 6, + "description": "C library providing BLAKE2b, BLAKE2s, BLAKE2bp, BLAKE2sp", + "homepage": "https://github.com/BLAKE2/libb2", + "supports": "!windows" +} diff --git a/vcpkg/ports/nu-book-zxing-cpp/portfile.cmake b/vcpkg/ports/nu-book-zxing-cpp/portfile.cmake new file mode 100644 index 0000000000..4b32698193 --- /dev/null +++ b/vcpkg/ports/nu-book-zxing-cpp/portfile.cmake @@ -0,0 +1,34 @@ +vcpkg_check_linkage(ONLY_STATIC_LIBRARY) + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO zxing-cpp/zxing-cpp + REF "v${VERSION}" + SHA512 f1de8df783061a152a18cd9102ac0c579c40c76ab4a5ba9f30bcb8ddb532f3fac08736840a631adbf7c30a7fa00ce8d65625c8cd695288620601708e8f256a53 + HEAD_REF master +) + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + -DBUILD_BLACKBOX_TESTS=OFF + -DBUILD_EXAMPLES=OFF +) + +vcpkg_cmake_install() +vcpkg_fixup_pkgconfig() + +vcpkg_cmake_config_fixup( + CONFIG_PATH lib/cmake/ZXing + PACKAGE_NAME ZXing +) + +file(READ "${CURRENT_PACKAGES_DIR}/share/ZXing/ZXingConfig.cmake" _contents) +file(WRITE "${CURRENT_PACKAGES_DIR}/share/ZXing/ZXingConfig.cmake" " +include(CMakeFindDependencyMacro) +find_dependency(Threads) +${_contents}") + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") + +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE") diff --git a/vcpkg/ports/nu-book-zxing-cpp/vcpkg.json b/vcpkg/ports/nu-book-zxing-cpp/vcpkg.json new file mode 100644 index 0000000000..c1669e0c63 --- /dev/null +++ b/vcpkg/ports/nu-book-zxing-cpp/vcpkg.json @@ -0,0 +1,17 @@ +{ + "name": "nu-book-zxing-cpp", + "version": "2.2.1", + "description": "Barcode detection and decoding library.", + "homepage": "https://github.com/zxing-cpp/zxing-cpp", + "license": "Apache-2.0", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ] +} From f3d6eb379ecde987c9e1f3fa0d22e4164da4e8b3 Mon Sep 17 00:00:00 2001 From: Mathieu Pellerin Date: Fri, 17 Jan 2025 11:33:53 +0700 Subject: [PATCH 5/6] Fix handling of constraints when starting a new track to avoid data loss --- src/core/tracker.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/tracker.cpp b/src/core/tracker.cpp index 73836ffaff..a3f5463b6b 100644 --- a/src/core/tracker.cpp +++ b/src/core/tracker.cpp @@ -161,7 +161,7 @@ void Tracker::trackPosition() return; } - if ( !qgsDoubleNear( mMaximumDistance, 0.0 ) && mCurrentDistance > mMaximumDistance ) + if ( mRubberbandModel->vertexCount() > 1 && !qgsDoubleNear( mMaximumDistance, 0.0 ) && mCurrentDistance > mMaximumDistance ) { // Simple logic to avoid getting stuck in an infinite erroneous distance having somehow actually moved beyond the safeguard threshold if ( ++mMaximumDistanceFailuresCount < MAXIMUM_DISTANCE_FAILURES ) @@ -190,7 +190,7 @@ void Tracker::positionReceived() return; } - if ( !qgsDoubleNear( mMinimumDistance, 0.0 ) || !qgsDoubleNear( mMaximumDistance, 0.0 ) ) + if ( mRubberbandModel->vertexCount() > 1 && ( !qgsDoubleNear( mMinimumDistance, 0.0 ) || !qgsDoubleNear( mMaximumDistance, 0.0 ) ) ) { QVector points = mRubberbandModel->flatPointSequence( QgsProject::instance()->crs() ); @@ -210,7 +210,7 @@ void Tracker::positionReceived() if ( !qgsDoubleNear( mMinimumDistance, 0.0 ) ) { - mMinimumDistanceFulfilled = mCurrentDistance >= mMinimumDistance; + mMinimumDistanceFulfilled = mRubberbandModel->vertexCount() == 1 || mCurrentDistance >= mMinimumDistance; if ( !mConjunction && mMinimumDistanceFulfilled ) { @@ -221,7 +221,7 @@ void Tracker::positionReceived() if ( !qgsDoubleNear( mTimeInterval, 0.0 ) ) { - mTimeIntervalFulfilled = ( mLastDevicePositionTimestamp.toMSecsSinceEpoch() - mLastVertexPositionTimestamp.toMSecsSinceEpoch() ) >= mTimeInterval * 1000; + mTimeIntervalFulfilled = mRubberbandModel->vertexCount() == 1 || ( ( mLastDevicePositionTimestamp.toMSecsSinceEpoch() - mLastVertexPositionTimestamp.toMSecsSinceEpoch() ) >= mTimeInterval * 1000 ); if ( !mConjunction && mTimeIntervalFulfilled ) { From 9e26119970b0865c42812f7c8368553c4931daa6 Mon Sep 17 00:00:00 2001 From: Mathieu Pellerin Date: Fri, 17 Jan 2025 14:36:50 +0700 Subject: [PATCH 6/6] Remove vcpkg-make port, not needed since we downgraded libb2 --- vcpkg/ports/vcpkg-make/portfile.cmake | 43 -- .../ports/vcpkg-make/vcpkg-port-config.cmake | 6 - vcpkg/ports/vcpkg-make/vcpkg.json | 13 - vcpkg/ports/vcpkg-make/vcpkg_make.cmake | 277 -------- .../ports/vcpkg-make/vcpkg_make_common.cmake | 660 ------------------ .../vcpkg-make/vcpkg_make_configure.cmake | 135 ---- .../ports/vcpkg-make/vcpkg_make_install.cmake | 134 ---- vcpkg/ports/vcpkg-make/vcpkg_scripts.cmake | 203 ------ .../ports/vcpkg-make/wrappers/cl_cpp_wrapper | 95 --- vcpkg/ports/vcpkg-make/wrappers/windres-rc | 122 ---- 10 files changed, 1688 deletions(-) delete mode 100644 vcpkg/ports/vcpkg-make/portfile.cmake delete mode 100644 vcpkg/ports/vcpkg-make/vcpkg-port-config.cmake delete mode 100644 vcpkg/ports/vcpkg-make/vcpkg.json delete mode 100644 vcpkg/ports/vcpkg-make/vcpkg_make.cmake delete mode 100644 vcpkg/ports/vcpkg-make/vcpkg_make_common.cmake delete mode 100644 vcpkg/ports/vcpkg-make/vcpkg_make_configure.cmake delete mode 100644 vcpkg/ports/vcpkg-make/vcpkg_make_install.cmake delete mode 100644 vcpkg/ports/vcpkg-make/vcpkg_scripts.cmake delete mode 100644 vcpkg/ports/vcpkg-make/wrappers/cl_cpp_wrapper delete mode 100644 vcpkg/ports/vcpkg-make/wrappers/windres-rc diff --git a/vcpkg/ports/vcpkg-make/portfile.cmake b/vcpkg/ports/vcpkg-make/portfile.cmake deleted file mode 100644 index 1b1d146f31..0000000000 --- a/vcpkg/ports/vcpkg-make/portfile.cmake +++ /dev/null @@ -1,43 +0,0 @@ -set(VCPKG_POLICY_CMAKE_HELPER_PORT enabled) - -set(automake_version 1.17) -vcpkg_download_distfile(ARCHIVE - URLS https://ftp.gnu.org/gnu/automake/automake-${automake_version}.tar.gz - https://www.mirrorservice.org/sites/ftp.gnu.org/gnu/automake/automake-${automake_version}.tar.gz - FILENAME automake-${automake_version}.tar.gz - SHA512 11357dfab8cbf4b5d94d9d06e475732ca01df82bef1284888a34bd558afc37b1a239bed1b5eb18a9dbcc326344fb7b1b301f77bb8385131eb8e1e118b677883a -) - -vcpkg_extract_source_archive( - automake_source - ARCHIVE "${ARCHIVE}" -) - -file(INSTALL - "${CMAKE_CURRENT_LIST_DIR}/vcpkg_make_configure.cmake" - "${CMAKE_CURRENT_LIST_DIR}/vcpkg_make_install.cmake" - "${CMAKE_CURRENT_LIST_DIR}/vcpkg_make_common.cmake" - "${CMAKE_CURRENT_LIST_DIR}/vcpkg_make.cmake" - "${CMAKE_CURRENT_LIST_DIR}/vcpkg_scripts.cmake" - "${CMAKE_CURRENT_LIST_DIR}/vcpkg-port-config.cmake" - DESTINATION - "${CURRENT_PACKAGES_DIR}/share/${PORT}" -) - -file(INSTALL - "${automake_source}/lib/ar-lib" - "${automake_source}/lib/compile" - DESTINATION - "${CURRENT_PACKAGES_DIR}/share/${PORT}/wrappers" -) - -vcpkg_install_copyright( - COMMENT [[ -The cmake scripts are under vcpkg's MIT license terms, see LICENSE.txt below. -The port also installs shell scripts from GNU Automake. -These scripts are under GPL-2.0-or-later, see COPYING below. -]] - FILE_LIST - "${VCPKG_ROOT_DIR}/LICENSE.txt" - "${automake_source}/COPYING" -) diff --git a/vcpkg/ports/vcpkg-make/vcpkg-port-config.cmake b/vcpkg/ports/vcpkg-make/vcpkg-port-config.cmake deleted file mode 100644 index 9bce16b970..0000000000 --- a/vcpkg/ports/vcpkg-make/vcpkg-port-config.cmake +++ /dev/null @@ -1,6 +0,0 @@ -include("${CMAKE_CURRENT_LIST_DIR}/../vcpkg-cmake-get-vars/vcpkg-port-config.cmake") -include("${CMAKE_CURRENT_LIST_DIR}/vcpkg_make_configure.cmake") -include("${CMAKE_CURRENT_LIST_DIR}/vcpkg_make_install.cmake") -include("${CMAKE_CURRENT_LIST_DIR}/vcpkg_make_common.cmake") -include("${CMAKE_CURRENT_LIST_DIR}/vcpkg_make.cmake") -include("${CMAKE_CURRENT_LIST_DIR}/vcpkg_scripts.cmake") diff --git a/vcpkg/ports/vcpkg-make/vcpkg.json b/vcpkg/ports/vcpkg-make/vcpkg.json deleted file mode 100644 index 59046f78a1..0000000000 --- a/vcpkg/ports/vcpkg-make/vcpkg.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "vcpkg-make", - "version-date": "2024-12-27", - "documentation": "https://learn.microsoft.com/vcpkg/maintainers/functions/vcpkg_make_configure", - "license": null, - "supports": "native", - "dependencies": [ - { - "name": "vcpkg-cmake-get-vars", - "host": true - } - ] -} diff --git a/vcpkg/ports/vcpkg-make/vcpkg_make.cmake b/vcpkg/ports/vcpkg-make/vcpkg_make.cmake deleted file mode 100644 index ee3ec778fc..0000000000 --- a/vcpkg/ports/vcpkg-make/vcpkg_make.cmake +++ /dev/null @@ -1,277 +0,0 @@ -# Be aware of https://github.com/microsoft/vcpkg/pull/31228 -include_guard(GLOBAL) -include("${CMAKE_CURRENT_LIST_DIR}/vcpkg_make_common.cmake") - -function(vcpkg_run_shell) - cmake_parse_arguments(PARSE_ARGV 0 arg - "" - "WORKING_DIRECTORY;LOGNAME" - "SHELL;COMMAND;SAVE_LOG_FILES" - ) - z_vcpkg_unparsed_args(FATAL_ERROR) - z_vcpkg_required_args(SHELL WORKING_DIRECTORY COMMAND LOGNAME) - - - set(extra_opts "") - if(arg_SAVE_LOG_FILES) - set(extra_opts SAVE_LOG_FILES ${arg_SAVE_LOG_FILES}) - endif() - - # In the construction of the shell command, we need to handle environment variable assignments and configure options differently: - # - # 1. Environment variable assignments (e.g., CC, CXX, etc.): - # - These must not be quoted. - # - If the environment variable names (e.g., CC, CXX, CC_FOR_BUILD) are quoted, the shell will treat them as part of the value, breaking the declaration. - # - For example, CC='/usr/bin/gcc' is valid, but "CC='/usr/bin/gcc'" would cause an error because the shell would try to use the entire quoted string as the variable name. - # - # 2. Options passed to the configure script: - # - The options should be quoted to ensure that any option containing spaces or special characters is treated as a single argument. - # - For instance, --prefix=/some path/with spaces would break if not quoted, as the shell would interpret each word as a separate argument. - # - By quoting the options like "--prefix=/some path/with spaces", we ensure they are passed correctly to the configure script as a single argument. - # - # The resulting command should look something like this: - # V=1 CC='/Library/Developer/CommandLineTools/usr/bin/cc -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk -arch arm64' - # CXX='/Library/Developer/CommandLineTools/usr/bin/c++ -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk -arch arm64' - # CC_FOR_BUILD='/Library/Developer/CommandLineTools/usr/bin/cc -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk -arch arm64' - # CPP_FOR_BUILD='/Library/Developer/CommandLineTools/usr/bin/cc -E -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk -arch arm64' - # CXX_FOR_BUILD='/Library/Developer/CommandLineTools/usr/bin/c++ -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk -arch arm64' - # .... - # ./../src/8bc98c3a0d-84009aba94.clean/configure "--enable-pic" "--disable-lavf" "--disable-swscale" "--disable-avs" ... - vcpkg_list(JOIN arg_COMMAND " " arg_COMMAND) - vcpkg_execute_required_process( - COMMAND ${arg_SHELL} -c "${arg_COMMAND}" - WORKING_DIRECTORY "${arg_WORKING_DIRECTORY}" - LOGNAME "${arg_LOGNAME}" - ${extra_opts} - ) -endfunction() - -function(vcpkg_run_shell_as_build) - cmake_parse_arguments(PARSE_ARGV 0 arg - "" - "WORKING_DIRECTORY;LOGNAME" - "SHELL;COMMAND;NO_PARALLEL_COMMAND;SAVE_LOG_FILES" - ) - z_vcpkg_unparsed_args(FATAL_ERROR) - z_vcpkg_required_args(SHELL WORKINK_DIRECTORY COMMAND LOGNAME) - - set(extra_opts "") - if(arg_SAVE_LOG_FILES) - set(extra_opts SAVE_LOG_FILES ${arg_SAVE_LOG_FILES}) - endif() - - list(JOIN arg_COMMAND " " cmd) - list(JOIN arg_NO_PARALLEL_COMMAND " " no_par_cmd) - vcpkg_execute_build_process( - COMMAND ${arg_SHELL} -c "${cmd}" - NO_PARALLEL_COMMAND ${arg_SHELL} -c "${no_par_cmd}" - WORKING_DIRECTORY "${arg_WORKING_DIRECTORY}" - LOGNAME "${arg_LOGNAME}" - ${extra_opts} - ) -endfunction() - -function(vcpkg_run_autoreconf shell_cmd work_dir) - find_program(AUTORECONF NAMES autoreconf) - if(NOT AUTORECONF) - message(FATAL_ERROR "${PORT} currently requires the following programs from the system package manager: - autoconf automake autoconf-archive - On Debian and Ubuntu derivatives: - sudo apt-get install autoconf automake autoconf-archive - On recent Red Hat and Fedora derivatives: - sudo dnf install autoconf automake autoconf-archive - On Arch Linux and derivatives: - sudo pacman -S autoconf automake autoconf-archive - On Alpine: - apk add autoconf automake autoconf-archive - On macOS: - brew install autoconf automake autoconf-archive\n") - endif() - message(STATUS "Generating configure for ${TARGET_TRIPLET}") - vcpkg_run_shell( - SHELL ${shell_cmd} - COMMAND "${AUTORECONF}" -vfi - WORKING_DIRECTORY "${work_dir}" - LOGNAME "autoconf-${TARGET_TRIPLET}" - ) - message(STATUS "Finished generating configure for ${TARGET_TRIPLET}") -endfunction() - -function(vcpkg_make_setup_win_msys msys_out) - list(APPEND msys_require_packages autoconf-wrapper automake-wrapper binutils libtool make which) - vcpkg_insert_msys_into_path(msys PACKAGES ${msys_require_packages}) - find_program(PKGCONFIG NAMES pkgconf NAMES_PER_DIR PATHS "${CURRENT_HOST_INSTALLED_DIR}/tools/pkgconf" NO_DEFAULT_PATH) - set("${msys_out}" "${msys}" PARENT_SCOPE) -endfunction() - -function(vcpkg_make_get_shell out_var) - set(shell_options "") - if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW) - vcpkg_make_setup_win_msys(msys_root) - set(shell_options --noprofile --norc --debug) - set(shell_cmd "${msys_root}/usr/bin/bash.exe") - endif() - find_program(shell_cmd NAMES bash sh zsh REQUIRED) - set("${out_var}" "${shell_cmd}" ${shell_options} PARENT_SCOPE) -endfunction() - -function(z_vcpkg_make_get_configure_triplets out) - cmake_parse_arguments(PARSE_ARGV 1 arg - "" - "COMPILER_NAME" - "" - ) - z_vcpkg_unparsed_args(FATAL_ERROR) - # --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 - z_vcpkg_make_determine_target_arch(TARGET_ARCH) - z_vcpkg_make_determine_host_arch(BUILD_ARCH) - - set(build_triplet_opt "") - if(CMAKE_HOST_WIN32 AND VCPKG_TARGET_IS_WINDOWS) - # This is required since we are running in a msys - # shell which will be otherwise identified as ${BUILD_ARCH}-pc-msys - set(build_triplet_opt "--build=${BUILD_ARCH}-pc-mingw32") - endif() - - set(host_triplet "") - if(VCPKG_CROSSCOMPILING) - if(VCPKG_TARGET_IS_WINDOWS) - if(NOT TARGET_ARCH MATCHES "${BUILD_ARCH}" OR NOT CMAKE_HOST_WIN32) - set(host_triplet_opt "--host=${TARGET_ARCH}-pc-mingw32") - elseif(VCPKG_TARGET_IS_UWP) - # Needs to be different from --build to enable cross builds. - set(host_triplet_opt "--host=${TARGET_ARCH}-unknown-mingw32") - endif() - elseif(VCPKG_TARGET_IS_IOS OR VCPKG_TARGET_IS_OSX AND NOT "${TARGET_ARCH}" STREQUAL "${BUILD_ARCH}") - set(host_triplet_opt "--host=${TARGET_ARCH}-apple-darwin") - elseif(VCPKG_TARGET_IS_LINUX) - if("${arg_COMPILER_NAME}" MATCHES "([^\/]*)-gcc$" AND CMAKE_MATCH_1 AND NOT CMAKE_MATCH_1 MATCHES "^gcc") - set(host_triplet_opt "--host=${CMAKE_MATCH_1}") # (Host activates crosscompilation; The name given here is just the prefix of the host tools for the target) - endif() - endif() - endif() - - set(output "${build_triplet_opt};${host_triplet_opt}") - string(STRIP "${output}" output) - set("${out}" "${output}" PARENT_SCOPE) -endfunction() - -function(z_vcpkg_make_prepare_env config) - cmake_parse_arguments(PARSE_ARGV 1 arg - "ADD_BIN_TO_PATH" - "" - "" - ) - z_vcpkg_unparsed_args(FATAL_ERROR) - # Used by CL - vcpkg_host_path_list(PREPEND ENV{INCLUDE} "${CURRENT_INSTALLED_DIR}/include") - # Used by GCC - 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") - - # 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) - vcpkg_backup_env_variables(VARS _CL_ _LINK_) - # 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) - 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}") - 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}") - endif() - endif() - - # Setup environment - set(ENV{CPPFLAGS} "${CPPFLAGS_${config}}") - set(ENV{CPPFLAGS_FOR_BUILD} "${CPPFLAGS_${config}}") - set(ENV{CFLAGS} "${CFLAGS_${config}}") - set(ENV{CFLAGS_FOR_BUILD} "${CFLAGS_${config}}") - set(ENV{CXXFLAGS} "${CXXFLAGS_${config}}") - set(ENV{RCFLAGS} "${RCFLAGS_${config}}") - set(ENV{LDFLAGS} "${LDFLAGS_${config}}") - set(ENV{LDFLAGS_FOR_BUILD} "${LDFLAGS_${config}}") - if(ARFLAGS_${config} 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_${config}}") - endif() - - if(LINK_ENV_${config}) - set(ENV{_LINK_} "${LINK_ENV_${config}}") - endif() - - vcpkg_list(APPEND lib_env_vars LIB LIBPATH LIBRARY_PATH) - foreach(lib_env_var IN LISTS lib_env_vars) - if(EXISTS "${CURRENT_INSTALLED_DIR}${path_suffix_${config}}/lib") - vcpkg_host_path_list(PREPEND ENV{${lib_env_var}} "${CURRENT_INSTALLED_DIR}${path_suffix_${config}}/lib") - endif() - if(EXISTS "${CURRENT_INSTALLED_DIR}${path_suffix_${config}}/lib/manual-link") - vcpkg_host_path_list(PREPEND ENV{${lib_env_var}} "${CURRENT_INSTALLED_DIR}${path_suffix_${config}}/lib/manual-link") - endif() - endforeach() -endfunction() - -function(z_vcpkg_make_restore_env) - # Only variables which are inspected in vcpkg_make_prepare_env need to be restored here. - # Rest is restored add the end of configure. - vcpkg_restore_env_variables(VARS - LIBRARY_PATH LIB LIBPATH - PATH - ) -endfunction() - -function(vcpkg_make_run_configure) - cmake_parse_arguments(PARSE_ARGV 0 arg - "ADD_BIN_TO_PATH" - "CONFIG;SHELL;WORKING_DIRECTORY;CONFIGURE_PATH;CONFIGURE_ENV" - "OPTIONS" - ) - z_vcpkg_unparsed_args(FATAL_ERROR) - z_vcpkg_required_args(SHELL CONFIG WORKING_DIRECTORY CONFIGURE_PATH) - - vcpkg_prepare_pkgconfig("${arg_CONFIG}") - - set(prepare_env_opts "") - - z_vcpkg_make_prepare_env("${arg_CONFIG}" ${prepare_env_opts}) - - vcpkg_list(SET tmp) - foreach(element IN LISTS arg_OPTIONS) - string(REPLACE [["]] [[\"]] element "${element}") - vcpkg_list(APPEND tmp "\"${element}\"") - endforeach() - vcpkg_list(JOIN tmp " " "arg_OPTIONS") - set(command ${arg_CONFIGURE_ENV} ${arg_CONFIGURE_PATH} ${arg_OPTIONS}) - - message(STATUS "Configuring ${TARGET_TRIPLET}-${suffix_${arg_CONFIG}}") - vcpkg_run_shell( - WORKING_DIRECTORY "${arg_WORKING_DIRECTORY}" - LOGNAME "config-${TARGET_TRIPLET}-${suffix_${arg_CONFIG}}" - SAVE_LOG_FILES config.log - SHELL ${arg_SHELL} - COMMAND V=1 ${command} - ) - if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW AND VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) - file(GLOB_RECURSE libtool_files "${arg_WORKING_DIRECTORY}*/libtool") - foreach(lt_file IN LISTS libtool_files) - file(READ "${lt_file}" _contents) - string(REPLACE ".dll.lib" ".lib" _contents "${_contents}") - file(WRITE "${lt_file}" "${_contents}") - endforeach() - endif() - z_vcpkg_make_restore_env() - vcpkg_restore_pkgconfig() -endfunction() diff --git a/vcpkg/ports/vcpkg-make/vcpkg_make_common.cmake b/vcpkg/ports/vcpkg-make/vcpkg_make_common.cmake deleted file mode 100644 index 575f3b81f8..0000000000 --- a/vcpkg/ports/vcpkg-make/vcpkg_make_common.cmake +++ /dev/null @@ -1,660 +0,0 @@ -include_guard(GLOBAL) - -### Mapping variables -macro(z_vcpkg_make_set_common_vars) - set(path_suffix_RELEASE "") - set(path_suffix_DEBUG "/debug") - set(suffix_RELEASE "rel") - set(suffix_DEBUG "dbg") - foreach(config IN ITEMS RELEASE DEBUG) - set("workdir_${config}" "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${suffix_${config}}") - endforeach() - set(buildtypes release) - if(NOT VCPKG_BUILD_TYPE) - list(APPEND buildtypes debug) - endif() -endmacro() - -### -macro(z_vcpkg_make_get_cmake_vars) - cmake_parse_arguments(vmgcv_arg # Not just arg since macros don't define their own var scope. - "" "" "LANGUAGES" ${ARGN} - ) - - z_vcpkg_get_global_property(has_cmake_vars_file "make_cmake_vars_file" SET) - - if(NOT has_cmake_vars_file) - if(vmgcv_arg_LANGUAGES) - # Escape semicolons to prevent CMake from splitting LANGUAGES list when passing as -D option. - string(REPLACE ";" "\;" vmgcv_arg_langs "${vmgcv_arg_LANGUAGES}") - list(APPEND VCPKG_CMAKE_CONFIGURE_OPTIONS "-DVCPKG_LANGUAGES=${vmgcv_arg_langs}") - unset(langs) - endif() - - list(APPEND VCPKG_CMAKE_CONFIGURE_OPTIONS "-DVCPKG_DEFAULT_VARS_TO_CHECK=CMAKE_LIBRARY_PATH_FLAG") - vcpkg_cmake_get_vars(cmake_vars_file) - z_vcpkg_set_global_property(make_cmake_vars_file "${cmake_vars_file}") - else() - z_vcpkg_get_global_property(cmake_vars_file "make_cmake_vars_file") - endif() - - include("${cmake_vars_file}") -endmacro() - -### normalize architectures -function(z_vcpkg_make_determine_arch out_var value) - if(${value} MATCHES "^(amd|AMD|x)64$") - set(${out_var} x86_64 PARENT_SCOPE) - elseif(${value} MATCHES "^(x|X)86$") - set(${out_var} i686 PARENT_SCOPE) - elseif(${value} MATCHES "^(ARM|arm)64$") - set(${out_var} aarch64 PARENT_SCOPE) - elseif(${value} MATCHES "^(ARM|arm)$") - set(${out_var} arm PARENT_SCOPE) - elseif(${value} MATCHES "^(x86_64|i686|aarch64)$" OR NOT VCPKG_TARGET_IS_WINDOWS) - # Do nothing and assume valid architecture - set("${out_var}" "${value}" PARENT_SCOPE) - else() - message(FATAL_ERROR "Unsupported architecture '${value}' in '${CMAKE_CURRENT_FUNCTION}'!" ) - endif() -endfunction() - -function(z_vcpkg_make_determine_host_arch out_var) - if(DEFINED ENV{PROCESSOR_ARCHITEW6432}) - set(arch $ENV{PROCESSOR_ARCHITEW6432}) - elseif(DEFINED ENV{PROCESSOR_ARCHITECTURE}) - set(arch $ENV{PROCESSOR_ARCHITECTURE}) - else() - z_vcpkg_make_get_cmake_vars(#[[ LANGUAGES .... ]]) - set(arch "${VCPKG_DETECTED_CMAKE_HOST_SYSTEM_PROCESSOR}") - endif() - z_vcpkg_make_determine_arch("${out_var}" "${arch}") - set("${out_var}" "${${out_var}}" PARENT_SCOPE) -endfunction() - -function(z_vcpkg_make_determine_target_arch out_var) - list(LENGTH VCPKG_OSX_ARCHITECTURES osx_archs_num) - if(osx_archs_num GREATER_EQUAL 2 AND VCPKG_TARGET_IS_OSX) - set(${out_var} "universal") - else() - z_vcpkg_make_determine_arch(${out_var} "${VCPKG_TARGET_ARCHITECTURE}") - endif() - set("${out_var}" "${${out_var}}" PARENT_SCOPE) -endfunction() - -function(z_vcpkg_make_prepare_compile_flags) - cmake_parse_arguments(PARSE_ARGV 0 arg - "DISABLE_CPPFLAGS;NO_FLAG_ESCAPING;DISABLE_MSVC_WRAPPERS" - "COMPILER_FRONTEND;CONFIG;FLAGS_OUT" - "LANGUAGES" - ) - - z_vcpkg_unparsed_args(FATAL_ERROR) - - if(NOT DEFINED arg_LANGUAGES) - set(arg_LANGUAGES "C" "CXX") - endif() - - set(var_suffix "${arg_CONFIG}") - set(CFLAGS "") - set(CXXFLAGS "") - - # separate_aruments is needed to remove outer quotes from detected cmake variables. - # (e.g. Android NDK has "--sysroot=...") - foreach(lang IN LISTS arg_LANGUAGES) - if(NOT "${VCPKG_COMBINED_${lang}_FLAGS_${var_suffix}}" STREQUAL "") - separate_arguments(${lang}FLAGS NATIVE_COMMAND "${VCPKG_COMBINED_${lang}_FLAGS_${var_suffix}}") - else() - set(${lang}FLAGS "") - endif() - vcpkg_list(APPEND flags ${lang}FLAGS) - endforeach() - - separate_arguments(LDFLAGS NATIVE_COMMAND "${VCPKG_COMBINED_SHARED_LINKER_FLAGS_${var_suffix}}") - separate_arguments(ARFLAGS NATIVE_COMMAND "${VCPKG_COMBINED_STATIC_LINKER_FLAGS_${var_suffix}}") - set(RCFLAGS "${VCPKG_COMBINED_RC_FLAGS_${var_suffix}}") - - foreach(var IN ITEMS ABIFLAGS LDFLAGS ARFLAGS RCFLAGS) - vcpkg_list(APPEND flags ${var}) - endforeach() - - set(ABIFLAGS "") - set(pattern "") - foreach(arg IN LISTS CFLAGS) - if(NOT pattern STREQUAL "") - vcpkg_list(APPEND pattern "${arg}") - elseif(arg MATCHES "^--(sysroot|target)=.") - vcpkg_list(SET pattern "${arg}") - elseif(arg MATCHES "^-(isysroot|m32|m64|m?[Aa][Rr][Cc][Hh]|target)\$") - vcpkg_list(SET pattern "${arg}") - continue() - else() - continue() - endif() - vcpkg_list(APPEND ABIFLAGS "${pattern}") - list(REMOVE_ITEM CFLAGS "${pattern}") - list(REMOVE_ITEM CXXFLAGS "${pattern}") - list(REMOVE_ITEM LDFLAGS "${pattern}") - set(pattern "") - endforeach() - - # Filter common CPPFLAGS out of CFLAGS and CXXFLAGS - if(NOT arg_DISABLE_CPPFLAGS) - set(CPPFLAGS "") - set(pattern "") - foreach(arg IN LISTS CXXFLAGS) - if(NOT pattern STREQUAL "") - vcpkg_list(APPEND pattern "${arg}") - elseif(arg MATCHES "^-(D|isystem).") - vcpkg_list(SET pattern "${arg}") - elseif(arg MATCHES "^-(D|isystem)\$") - vcpkg_list(SET pattern "${arg}") - continue() - else() - continue() - endif() - string(FIND "${CFLAGS}" "${pattern} " index) - if(NOT index STREQUAL "-1") - vcpkg_list(APPEND CPPFLAGS ${pattern}) - list(REMOVE_ITEM CFLAGS "${pattern}") - list(REMOVE_ITEM CXXFLAGS "${pattern}") - list(REMOVE_ITEM LDFLAGS "${pattern}") - endif() - endforeach() - set(pattern "") - foreach(arg IN LISTS CFLAGS) - if(NOT pattern STREQUAL "") - vcpkg_list(APPEND pattern "${arg}") - elseif(arg MATCHES "^-(D|isystem)\$") - vcpkg_list(SET pattern "${arg}") - continue() - elseif(arg MATCHES "^-(D|isystem).") - vcpkg_list(SET pattern "${arg}") - else() - continue() - endif() - string(FIND "${CXXFLAGS}" "${pattern} " index) - if(NOT index STREQUAL "-1") - vcpkg_list(APPEND CPPFLAGS ${pattern}) - list(REMOVE_ITEM CFLAGS "${pattern}") - list(REMOVE_ITEM CXXFLAGS "${pattern}") - list(REMOVE_ITEM LDFLAGS "${pattern}") - endif() - vcpkg_list(SET pattern) - endforeach() - endif() - - # libtool tries to filter CFLAGS passed to the link stage via a allow list. - - # This approach is flawed since it fails to pass flags unknown to libtool - # but required for linking to the link stage (e.g. -fsanitize=). - # 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. - set(compiler_flag_escape "") - if(arg_COMPILER_FRONTEND STREQUAL "MSVC" AND NOT arg_NO_FLAG_ESCAPING) - set(compiler_flag_escape "-Xcompiler") - endif() - if(compiler_flag_escape) - list(TRANSFORM CFLAGS PREPEND "${compiler_flag_escape};") - list(TRANSFORM CXXFLAGS PREPEND "${compiler_flag_escape};") - endif() - - set(library_path_flag "${VCPKG_DETECTED_CMAKE_LIBRARY_PATH_FLAG}") - set(linker_flag_escape "") - if(arg_COMPILER_FRONTEND STREQUAL "MSVC" AND NOT arg_NO_FLAG_ESCAPING) - # Removed by libtool - set(linker_flag_escape "-Xlinker") - if(NOT arg_DISABLE_MSVC_WRAPPERS) - set(linker_flag_escape "-Xlinker -Xlinker -Xlinker") - endif() - if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") - string(STRIP "$ENV{_LINK_} ${VCPKG_COMBINED_STATIC_LINKER_FLAGS_${var_suffix}}" LINK_ENV) - else() - string(STRIP "$ENV{_LINK_} ${VCPKG_COMBINED_SHARED_LINKER_FLAGS_${var_suffix}}" LINK_ENV) - endif() - endif() - if(linker_flag_escape) - string(STRIP "${linker_flag_escape}" linker_flag_escape_stripped) - string(REPLACE " " ";" linker_flag_escape_stripped "${linker_flag_escape_stripped}") - list(TRANSFORM LDFLAGS PREPEND "${linker_flag_escape_stripped};") - endif() - string(REPLACE " " "\\ " current_installed_dir_escaped "${CURRENT_INSTALLED_DIR}") - if(EXISTS "${CURRENT_INSTALLED_DIR}${path_suffix_${var_suffix}}/lib/manual-link") - vcpkg_list(PREPEND LDFLAGS "${linker_flag_escape}${library_path_flag}${current_installed_dir_escaped}${path_suffix_${var_suffix}}/lib/manual-link") - endif() - if(EXISTS "${CURRENT_INSTALLED_DIR}${path_suffix_${var_suffix}}/lib") - vcpkg_list(PREPEND LDFLAGS "${linker_flag_escape}${library_path_flag}${current_installed_dir_escaped}${path_suffix_${var_suffix}}/lib") - endif() - - if(ARFLAGS AND NOT arg_COMPILER_FRONTEND STREQUAL "MSVC") - # 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 - vcpkg_list(PREPEND ARFLAGS "cr") - elseif(NOT arg_DISABLE_MSVC_WRAPPERS AND arg_COMPILER_FRONTEND STREQUAL "MSVC") - # The wrapper needs an action and that action needs to be defined AFTER all flags - vcpkg_list(APPEND ARFLAGS "cr") - endif() - - foreach(var IN LISTS flags) - list(JOIN ${var} " " string) - set("${var}_${var_suffix}" "${string}" PARENT_SCOPE) - list(APPEND flags_out "${var}_${var_suffix}") - endforeach() - set("${arg_FLAGS_OUT}" "${flags_out}" PARENT_SCOPE) -endfunction() - -### Prepare environment for configure -function(z_vcpkg_make_prepare_programs out_env) - cmake_parse_arguments(PARSE_ARGV 1 arg - "DISABLE_CPPFLAGS;DISABLE_MSVC_WRAPPERS" - "CONFIG;BUILD_TRIPLET" - "LANGUAGES" - ) - z_vcpkg_unparsed_args(FATAL_ERROR) - - z_vcpkg_make_get_cmake_vars(LANGUAGES ${arg_LANGUAGES}) - - macro(z_vcpkg_append_to_configure_environment inoutlist var defaultval) - # Allows to overwrite settings in custom triplets via the environment - if(DEFINED ENV{${var}}) - list(APPEND "${inoutlist}" "${var}='$ENV{${var}}'") - else() - list(APPEND "${inoutlist}" "${var}='${defaultval}'") - endif() - endmacro() - - set(configure_env "") - # Remove full filepaths due to spaces and prepend filepaths to PATH (cross-compiling tools are unlikely on path by default) - if (VCPKG_TARGET_IS_WINDOWS) - set(progs C_COMPILER CXX_COMPILER AR - LINKER RANLIB OBJDUMP - STRIP NM DLLTOOL RC_COMPILER) - list(TRANSFORM progs PREPEND "VCPKG_DETECTED_CMAKE_") - foreach(prog IN LISTS progs) - set(filepath "${${prog}}") - if(filepath MATCHES " ") - # CHECK: Uncertain if the compile wrappers work with absolute paths containing C:\\ - cmake_path(GET filepath FILENAME ${prog}) - vcpkg_insert_program_into_path("${filepath}") - endif() - endforeach() - - if (NOT arg_DISABLE_MSVC_WRAPPERS AND NOT VCPKG_TARGET_IS_MINGW) - 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}") - z_vcpkg_append_to_configure_environment(configure_env CXX "compile ${VCPKG_DETECTED_CMAKE_CXX_COMPILER}") - if(NOT arg_BUILD_TRIPLET MATCHES "--host") # TODO: Check if this generates problems with the new triplet approach - 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() - - 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}") - if(VCPKG_DETECTED_CMAKE_AR) - z_vcpkg_append_to_configure_environment(configure_env AR "ar-lib ${VCPKG_DETECTED_CMAKE_AR}") - else() - z_vcpkg_append_to_configure_environment(configure_env AR "ar-lib lib.exe -verbose") - endif() - else() - 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}") - z_vcpkg_append_to_configure_environment(configure_env CXX "${VCPKG_DETECTED_CMAKE_CXX_COMPILER}") - if(NOT arg_BUILD_TRIPLET MATCHES "--host") - 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() - 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}") - if(VCPKG_DETECTED_CMAKE_AR) - z_vcpkg_append_to_configure_environment(configure_env AR "${VCPKG_DETECTED_CMAKE_AR}") - else() - z_vcpkg_append_to_configure_environment(configure_env AR "lib.exe -verbose") - endif() - endif() - z_vcpkg_append_to_configure_environment(configure_env LD "${VCPKG_DETECTED_CMAKE_LINKER} -verbose") - if(VCPKG_DETECTED_CMAKE_RANLIB) - z_vcpkg_append_to_configure_environment(configure_env RANLIB "${VCPKG_DETECTED_CMAKE_RANLIB}") # Trick to ignore the RANLIB call - else() - z_vcpkg_append_to_configure_environment(configure_env RANLIB ": RANLIB-disabled") - endif() - if(VCPKG_DETECTED_CMAKE_OBJDUMP) #Objdump is required to make shared libraries. Otherwise define lt_cv_deplibs_check_method=pass_all - z_vcpkg_append_to_configure_environment(configure_env OBJDUMP "${VCPKG_DETECTED_CMAKE_OBJDUMP}") # Trick to ignore the RANLIB call - endif() - if(VCPKG_DETECTED_CMAKE_STRIP) # If required set the ENV variable STRIP in the portfile correctly - z_vcpkg_append_to_configure_environment(configure_env STRIP "${VCPKG_DETECTED_CMAKE_STRIP}") - else() - z_vcpkg_append_to_configure_environment(configure_env STRIP ": STRIP-disabled") - list(APPEND arg_OPTIONS ac_cv_prog_ac_ct_STRIP=:) - endif() - if(VCPKG_DETECTED_CMAKE_NM) # If required set the ENV variable NM in the portfile correctly - z_vcpkg_append_to_configure_environment(configure_env NM "${VCPKG_DETECTED_CMAKE_NM}") - 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) - z_vcpkg_append_to_configure_environment(configure_env NM "dumpbin.exe -symbols -headers") - endif() - if(VCPKG_DETECTED_CMAKE_DLLTOOL) # If required set the ENV variable DLLTOOL in the portfile correctly - z_vcpkg_append_to_configure_environment(configure_env DLLTOOL "${VCPKG_DETECTED_CMAKE_DLLTOOL}") - else() - z_vcpkg_append_to_configure_environment(configure_env DLLTOOL "link.exe -verbose -dll") - endif() - - if(NOT "ASM" IN_LIST arg_LANGUAGES ) - z_vcpkg_append_to_configure_environment(configure_env CCAS ": CCAS-disabled") # If required set the ENV variable CCAS in the portfile correctly - z_vcpkg_append_to_configure_environment(configure_env AS ": AS-disabled") # If required set the ENV variable AS in the portfile correctly - - else() - set(ccas "${VCPKG_DETECTED_CMAKE_ASM_COMPILER}") - if(VCPKG_DETECTED_CMAKE_ASM_COMPILER_ID STREQUAL "MSVC") - if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86") - set(asmflags "--target=i686-pc-windows-msvc -m32") - elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64") - set(asmflags "--target=x86_64-pc-windows-msvc") - elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64") - set(asmflags "--target=arm64-pc-windows-msvc") - endif() - vcpkg_find_acquire_program(CLANG) - set(ccas "${CLANG}") - if(ccas MATCHES " ") - cmake_path(GET ccas PARENT_PATH ccas_dir) - cmake_path(GET ccas FILENAME ccas_filename) - vcpkg_insert_program_into_path("${ccas_dir}") - set(ccas "${ccas_filename}") - endif() - string(APPEND ccas " ${asmflags}") - endif() - z_vcpkg_append_to_configure_environment(configure_env CCAS "${ccas} -c") - z_vcpkg_append_to_configure_environment(configure_env AS "${ccas} -c") - endif() - - else() - # OSX dosn't like CMAKE_C(XX)_COMPILER (cc) in CC/CXX and rather wants to have gcc/g++ - vcpkg_list(SET z_vcm_all_tools) - function(z_vcpkg_make_set_env envvar cmakevar) - set(prog "${VCPKG_DETECTED_CMAKE_${cmakevar}}") - if(NOT DEFINED ENV{${envvar}} AND NOT prog STREQUAL "") - vcpkg_list(APPEND z_vcm_all_tools "${prog}") - if(ARGN) - string(APPEND prog " ${ARGN}") - endif() - set(z_vcm_all_tools "${z_vcm_all_tools}" PARENT_SCOPE) - endif() - z_vcpkg_append_to_configure_environment(configure_env "${envvar}" "${prog}") - set(configure_env "${configure_env}" PARENT_SCOPE) - endfunction() - - z_vcpkg_make_set_env(CC C_COMPILER ${ABIFLAGS_${arg_CONFIG}}) - z_vcpkg_make_set_env(CXX CXX_COMPILER ${ABIFLAGS_${arg_CONFIG}}) - if(NOT arg_BUILD_TRIPLET MATCHES "--host") - z_vcpkg_make_set_env(CC_FOR_BUILD C_COMPILER ${ABIFLAGS_${arg_CONFIG}}) - z_vcpkg_make_set_env(CPP_FOR_BUILD C_COMPILER "-E" ${ABIFLAGS_${arg_CONFIG}}) - z_vcpkg_make_set_env(CXX_FOR_BUILD CXX_COMPILER ${ABIFLAGS_${arg_CONFIG}}) - else() - set(ENV{CC_FOR_BUILD} "umask 0 | touch a.out | touch conftest${VCPKG_HOST_EXECUTABLE_SUFFIX} | true") - set(ENV{CPP_FOR_BUILD} "umask 0 | touch a.out | touch conftest${VCPKG_HOST_EXECUTABLE_SUFFIX} | true") - set(ENV{CXX_FOR_BUILD} "umask 0 | touch a.out | touch conftest${VCPKG_HOST_EXECUTABLE_SUFFIX} | true") - endif() - if("ASM" IN_LIST arg_LANGUAGES) - z_vcpkg_make_set_env(CCAS ASM_COMPILER "-c" ${ABIFLAGS_${arg_CONFIG}}) - z_vcpkg_make_set_env(AS ASM_COMPILER "-c" ${ABIFLAGS_${arg_CONFIG}}) - endif() - 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) - - list(FILTER z_vcm_all_tools INCLUDE REGEX " ") - if(z_vcm_all_tools) - list(REMOVE_DUPLICATES z_vcm_all_tools) - list(JOIN z_vcm_all_tools "\n " tools) - message(STATUS "Warning: Tools with embedded space may be handled incorrectly by configure:\n ${tools}") - endif() - endif() - list(JOIN configure_env " " configure_env) - set("${out_env}" "${configure_env}" PARENT_SCOPE) -endfunction() - -function(z_vcpkg_make_prepare_link_flags) - cmake_parse_arguments(PARSE_ARGV 0 arg - "VCPKG_TRANSFORM_LIBS" - "IN_OUT_VAR" - "" - ) - - set(link_flags ${${arg_IN_OUT_VAR}}) - - if(arg_VCPKG_TRANSFORM_LIBS) - list(TRANSFORM link_flags REPLACE "[.](dll[.]lib|lib|a|so)$" "") - - if(VCPKG_TARGET_IS_WINDOWS) - list(REMOVE_ITEM link_flags "uuid") - endif() - - list(TRANSFORM link_flags REPLACE "^([^-].*)" "-l\\1") - 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. - list(TRANSFORM link_flags REPLACE "^-luuid\$" "-Wl,-Bstatic,-luuid,-Bdynamic") - endif() - endif() - - set(${arg_IN_OUT_VAR} ${link_flags} PARENT_SCOPE) -endfunction() - -function(z_vcpkg_make_prepare_flags) - cmake_parse_arguments(PARSE_ARGV 0 arg - "DISABLE_CPPFLAGS;DISABLE_MSVC_WRAPPERS;NO_FLAG_ESCAPING" - "LIBS_OUT;FRONTEND_VARIANT_OUT;C_COMPILER_NAME" - "LANGUAGES" - ) - z_vcpkg_unparsed_args(FATAL_ERROR) - - z_vcpkg_make_get_cmake_vars(LANGUAGES ${arg_LANGUAGES}) - - # ==== LIBS - # TODO: Figure out what to do with other Languages like Fortran - # Remove outer quotes from cmake variables which will be forwarded via makefile/shell variables - # substituted into makefile commands (e.g. Android NDK has "--sysroot=...") - separate_arguments(c_libs_list NATIVE_COMMAND "${VCPKG_DETECTED_CMAKE_C_STANDARD_LIBRARIES}") - separate_arguments(cxx_libs_list NATIVE_COMMAND "${VCPKG_DETECTED_CMAKE_CXX_STANDARD_LIBRARIES}") - list(REMOVE_ITEM cxx_libs_list ${c_libs_list}) - set(all_libs_list ${cxx_libs_list} ${c_libs_list}) - - # Do lib list transformation from name.lib to -lname if necessary - set(vcpkg_transform_libs VCPKG_TRANSFORM_LIBS) - if(VCPKG_DETECTED_CMAKE_C_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC" AND (arg_NO_FLAG_ESCAPING)) - set(vcpkg_transform_libs "") - endif() - - if(VCPKG_TARGET_IS_UWP) - # 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. - set(vcpkg_transform_libs "") - endif() - - z_vcpkg_make_prepare_link_flags( - IN_OUT_VAR all_libs_list - ${vcpkg_transform_libs} - ) - - if(all_libs_list) - list(JOIN all_libs_list " " all_libs_string) - if(DEFINED ENV{LIBS}) - set(ENV{LIBS} "$ENV{LIBS} ${all_libs_string}") - else() - set(ENV{LIBS} "${all_libs_string}") - endif() - endif() - - set("${arg_LIBS_OUT}" "${all_libs_string}" PARENT_SCOPE) - - # ==== /LIBS - - if(VCPKG_TARGET_IS_WINDOWS) - vcpkg_backup_env_variables(VARS _CL_ _LINK_) - # 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) - 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_COMBINED_CXX_FLAGS_DEBUG}") - string(REPLACE "${_replacement}" "" VCPKG_DETECTED_CMAKE_C_FLAGS_DEBUG "${VCPKG_COMBINED_C_FLAGS_DEBUG}") - string(REPLACE "${_replacement}" "" VCPKG_DETECTED_CMAKE_CXX_FLAGS_RELEASE "${VCPKG_COMBINED_CXX_FLAGS_RELEASE}") - string(REPLACE "${_replacement}" "" VCPKG_DETECTED_CMAKE_C_FLAGS_RELEASE "${VCPKG_COMBINED_C_FLAGS_RELEASE}") - 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}") - endif() - endif() - - #### - set(flags_opts "") - if(DEFINED arg_LANGUAGES) - list(APPEND flags_opts LANGUAGES ${arg_LANGUAGES}) - endif() - - if(arg_DISABLE_CPPFLAGS) - list(APPEND flags_opts DISABLE_CPPFLAGS) - endif() - - if(arg_DISABLE_MSVC_WRAPPERS) - list(APPEND flags_opts DISABLE_MSVC_WRAPPERS) - endif() - - if(arg_NO_FLAG_ESCAPING) - list(APPEND flags_opts NO_FLAG_ESCAPING) - endif() - - z_vcpkg_make_prepare_compile_flags( - CONFIG RELEASE - COMPILER_FRONTEND "${VCPKG_DETECTED_CMAKE_C_COMPILER_FRONTEND_VARIANT}" - FLAGS_OUT release_flags_list - ${flags_opts} - ) - if(NOT DEFINED VCPKG_BUILD_TYPE) - list(APPEND all_buildtypes DEBUG) - z_vcpkg_make_prepare_compile_flags( - CONFIG DEBUG - COMPILER_FRONTEND "${VCPKG_DETECTED_CMAKE_C_COMPILER_FRONTEND_VARIANT}" - FLAGS_OUT debug_flags_list - ${flags_opts} - ) - endif() - - foreach(flag IN LISTS release_flags_list debug_flags_list) - set("${flag}" "${${flag}}" PARENT_SCOPE) - endforeach() - - cmake_path(GET VCPKG_DETECTED_CMAKE_C_COMPILER FILENAME cname) - set("${C_COMPILER_NAME}" "${cname}" PARENT_SCOPE) # needed by z_vcpkg_make_get_configure_triplets - set("${arg_FRONTEND_VARIANT_OUT}" "${VCPKG_DETECTED_CMAKE_C_COMPILER_FRONTEND_VARIANT}" PARENT_SCOPE) -endfunction() - -function(z_vcpkg_make_default_path_and_configure_options out_var) - cmake_parse_arguments(PARSE_ARGV 1 arg - "AUTOMAKE" - "CONFIG;EXCLUDE_FILTER;INCLUDE_FILTER" - "" - ) - z_vcpkg_unparsed_args(FATAL_ERROR) - - set(opts "") - string(TOUPPER "${arg_CONFIG}" arg_CONFIG) - - z_vcpkg_make_set_common_vars() - - list(APPEND opts lt_cv_deplibs_check_method=pass_all) - - # Pre-processing windows configure requirements - if (VCPKG_TARGET_IS_WINDOWS) - # 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. - list(APPEND opts gl_cv_double_slash_root=yes - ac_cv_func_memmove=yes - ac_cv_func_memset=yes - ) - - if(VCPKG_TARGET_ARCHITECTURE MATCHES "^[Aa][Rr][Mm]64$") - list(APPEND opts gl_cv_host_cpu_c_abi=no) - endif() - endif() - - # Set configure paths - set(current_installed_dir_msys "${CURRENT_INSTALLED_DIR}") - if(CMAKE_HOST_WIN32) - string(REGEX REPLACE "^([a-zA-Z]):/" "/\\1/" current_installed_dir_msys "${current_installed_dir_msys}") - endif() - vcpkg_list(APPEND opts "--prefix=${current_installed_dir_msys}${path_suffix_${arg_CONFIG}}") - - if(arg_CONFIG STREQUAL "RELEASE") - # ${prefix} has an extra backslash to prevent early expansion when calling `bash -c configure "..."`. - vcpkg_list(APPEND opts - # Important: These should all be relative to prefix! - "--bindir=\\\${prefix}/tools/${PORT}/bin" - "--sbindir=\\\${prefix}/tools/${PORT}/sbin" - "--libdir=\\\${prefix}/lib" # On some Linux distributions lib64 is the default - "--mandir=\\\${prefix}/share/${PORT}" - "--docdir=\\\${prefix}/share/${PORT}" - "--datarootdir=\\\${prefix}/share/${PORT}") - else() - vcpkg_list(APPEND opts - # Important: These should all be relative to prefix! - "--bindir=\\\${prefix}/../tools/${PORT}${path_suffix_DEBUG}/bin" - "--sbindir=\\\${prefix}/../tools/${PORT}${path_suffix_DEBUG}/sbin" - "--libdir=\\\${prefix}/lib" # On some Linux distributions lib64 is the default - "--includedir=\\\${prefix}/../include" - "--mandir=\\\${prefix}/share/${PORT}" - "--docdir=\\\${prefix}/share/${PORT}" - "--datarootdir=\\\${prefix}/share/${PORT}") - endif() - # Setup common options - if(NOT arg_AUTOMAKE) - vcpkg_list(APPEND opts --disable-silent-rules --verbose) - endif() - - if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic") - vcpkg_list(APPEND opts --enable-shared --disable-static) - else() - vcpkg_list(APPEND opts --disable-shared --enable-static) - endif() - - if(DEFINED arg_EXCLUDE_FILTER) - list(FILTER opts EXCLUDE REGEX "${arg_EXCLUDE_FILTER}") - endif() - - if(DEFINED arg_INCLUDE_FILTER) - list(FILTER opts INCLUDE REGEX "${arg_INCLUDE_FILTER}") - endif() - - set("${out_var}" ${opts} PARENT_SCOPE) -endfunction() diff --git a/vcpkg/ports/vcpkg-make/vcpkg_make_configure.cmake b/vcpkg/ports/vcpkg-make/vcpkg_make_configure.cmake deleted file mode 100644 index d58200fdc1..0000000000 --- a/vcpkg/ports/vcpkg-make/vcpkg_make_configure.cmake +++ /dev/null @@ -1,135 +0,0 @@ -include_guard(GLOBAL) -include("${CMAKE_CURRENT_LIST_DIR}/vcpkg_make.cmake") - -function(vcpkg_make_configure) - cmake_parse_arguments(PARSE_ARGV 0 arg - "AUTORECONF;COPY_SOURCE;DISABLE_MSVC_WRAPPERS;DISABLE_CPPFLAGS;DISABLE_DEFAULT_OPTIONS;DISABLE_MSVC_TRANSFORMATIONS" - "SOURCE_PATH" - "OPTIONS;OPTIONS_DEBUG;OPTIONS_RELEASE;PRE_CONFIGURE_CMAKE_COMMANDS;LANGUAGES" - ) - - z_vcpkg_unparsed_args(FATAL_ERROR) - - # Can be set in the triplet to append options for configure - if(DEFINED VCPKG_MAKE_CONFIGURE_OPTIONS) - list(APPEND arg_OPTIONS ${VCPKG_MAKE_CONFIGURE_OPTIONS}) - endif() - if(DEFINED VCPKG_MAKE_CONFIGURE_OPTIONS_RELEASE) - list(APPEND arg_OPTIONS_RELEASE ${VCPKG_MAKE_CONFIGURE_OPTIONS_RELEASE}) - endif() - if(DEFINED VCPKG_MAKE_CONFIGURE_OPTIONS_DEBUG) - list(APPEND arg_OPTIONS_DEBUG ${VCPKG_MAKE_CONFIGURE_OPTIONS_DEBUG}) - endif() - - set(src_dir "${arg_SOURCE_PATH}") - - z_vcpkg_warn_path_with_spaces() - - set(prepare_flags_opts "") - if(arg_DISABLE_MSVC_WRAPPERS) - list(APPEND prepare_flags_opts "DISABLE_MSVC_WRAPPERS") - endif() - if(arg_DISABLE_CPPFLAGS) - list(APPEND prepare_flags_opts "DISABLE_CPPFLAGS") - endif() - if(DEFINED arg_LANGUAGES) - list(APPEND prepare_flags_opts "LANGUAGES" ${arg_LANGUAGES}) - endif() - - # Create cached cmake vars for this invocation's languages - z_vcpkg_make_get_cmake_vars(LANGUAGES ${arg_LANGUAGES}) - - set(escaping "") - if(arg_DISABLE_MSVC_TRANSFORMATIONS) - set(escaping NO_FLAG_ESCAPING) - endif() - - z_vcpkg_set_global_property(make_prepare_flags_opts "${prepare_flags_opts}") - z_vcpkg_make_prepare_flags(${prepare_flags_opts} ${escaping} C_COMPILER_NAME ccname FRONTEND_VARIANT_OUT frontend) - - 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. - vcpkg_add_to_path(PREPEND "${CURRENT_HOST_INSTALLED_DIR}/share/vcpkg-make/wrappers") - endif() - - vcpkg_make_get_shell(shell_var) - set(shell_cmd "${shell_var}") - - if(arg_AUTORECONF) - vcpkg_run_autoreconf("${shell_cmd}" "${src_dir}") - endif() - - # Backup environment variables - set(cm_FLAGS AR AS CC C CCAS CPP CXX FC FF GC LD LF LIBTOOL OBJC OBJXX R RC UPC Y) - - list(TRANSFORM cm_FLAGS APPEND "FLAGS") - vcpkg_backup_env_variables(VARS - ${cm_FLAGS} - # General backup - PATH - # Used by gcc/linux - C_INCLUDE_PATH CPLUS_INCLUDE_PATH LIBRARY_PATH LD_LIBRARY_PATH - # Used by cl - INCLUDE LIB LIBPATH _CL_ _LINK_ - ) - z_vcpkg_make_set_common_vars() - - foreach(config IN LISTS buildtypes) - string(TOUPPER "${config}" configup) - set(target_dir "${workdir_${configup}}") - file(REMOVE_RECURSE "${target_dir}") - file(MAKE_DIRECTORY "${target_dir}") - file(RELATIVE_PATH relative_build_path "${target_dir}" "${src_dir}") - if(arg_COPY_SOURCE) - file(COPY "${src_dir}/" DESTINATION "${target_dir}") - set(relative_build_path ".") - endif() - - z_vcpkg_make_prepare_programs(configure_env ${prepare_flags_opts} CONFIG "${configup}" BUILD_TRIPLET "${BUILD_TRIPLET}") - - set(opts "") - if(NOT arg_DISABLE_DEFAULT_OPTIONS) - z_vcpkg_make_default_path_and_configure_options(opts AUTOMAKE CONFIG "${configup}") - vcpkg_list(APPEND arg_OPTIONS ${opts}) - endif() - - set(configure_path_from_wd "./${relative_build_path}/configure") - - foreach(cmd IN LISTS arg_PRE_CONFIGURE_CMAKE_COMMANDS) - cmake_language(CALL ${cmd} ${configup}) - endforeach() - - vcpkg_make_run_configure(SHELL - "${shell_cmd}" - CONFIG - "${configup}" - CONFIGURE_ENV - "${configure_env}" - CONFIGURE_PATH - "${configure_path_from_wd}" - OPTIONS - ${BUILD_TRIPLET} - ${arg_OPTIONS} - ${arg_OPTIONS_${configup}} - WORKING_DIRECTORY - "${target_dir}" - ${extra_configure_opts} - ) - endforeach() - - # Restore environment - vcpkg_restore_env_variables(VARS - ${cm_FLAGS} - C_INCLUDE_PATH CPLUS_INCLUDE_PATH LIBRARY_PATH LD_LIBRARY_PATH - INCLUDE LIB LIBPATH _CL_ _LINK_ - ) - - find_program(Z_VCPKG_MAKE NAMES make gmake NAMES_PER_DIR REQUIRED) -endfunction() diff --git a/vcpkg/ports/vcpkg-make/vcpkg_make_install.cmake b/vcpkg/ports/vcpkg-make/vcpkg_make_install.cmake deleted file mode 100644 index 76bfae4051..0000000000 --- a/vcpkg/ports/vcpkg-make/vcpkg_make_install.cmake +++ /dev/null @@ -1,134 +0,0 @@ -include_guard(GLOBAL) -include("${CMAKE_CURRENT_LIST_DIR}/vcpkg_make.cmake") - -function(vcpkg_make_install) - cmake_parse_arguments(PARSE_ARGV 0 arg - "DISABLE_PARALLEL" - "LOGFILE_ROOT;MAKEFILE;TARGETS" - "OPTIONS;OPTIONS_DEBUG;OPTIONS_RELEASE" - ) - z_vcpkg_unparsed_args(FATAL_ERROR) - - if(NOT DEFINED arg_LOGFILE_ROOT) - set(arg_LOGFILE_ROOT "make") - endif() - - if(NOT DEFINED arg_TARGETS) - set(arg_TARGETS "all;install") - endif() - - if (NOT DEFINED arg_MAKEFILE) - set(arg_MAKEFILE Makefile) - endif() - - # Can be set in the triplet to append options for configure - if(DEFINED VCPKG_MAKE_OPTIONS) - list(APPEND arg_OPTIONS ${VCPKG_MAKE_OPTIONS}) - endif() - if(DEFINED VCPKG_MAKE_OPTIONS_RELEASE) - list(APPEND arg_OPTIONS_RELEASE ${VCPKG_MAKE_OPTIONS_RELEASE}) - endif() - if(DEFINED VCPKG_MAKE_OPTIONS_DEBUG) - list(APPEND arg_OPTIONS_DEBUG ${VCPKG_MAKE_OPTIONS_DEBUG}) - endif() - - if(CMAKE_HOST_WIN32) - set(Z_VCPKG_INSTALLED "${CURRENT_INSTALLED_DIR}") - else() - string(REPLACE " " "\ " Z_VCPKG_INSTALLED "${CURRENT_INSTALLED_DIR}") - endif() - - vcpkg_make_get_shell(shell_var) - set(shell_cmd "${shell_var}") - - find_program(Z_VCPKG_MAKE NAMES make gmake NAMES_PER_DIR REQUIRED) - set(make_command "${Z_VCPKG_MAKE}") - - set(destdir "${CURRENT_PACKAGES_DIR}") - if (CMAKE_HOST_WIN32) - set(path_backup "$ENV{PATH}") - vcpkg_add_to_path(PREPEND "${CURRENT_HOST_INSTALLED_DIR}/share/vcpkg-make/wrappers") - string(REPLACE " " [[\ ]] vcpkg_package_prefix "${CURRENT_PACKAGES_DIR}") - string(REGEX REPLACE [[([a-zA-Z]):/]] [[/\1/]] destdir "${vcpkg_package_prefix}") - endif() - - vcpkg_backup_env_variables(VARS LIB LIBPATH LIBRARY_PATH LD_LIBRARY_PATH CPPFLAGS CFLAGS CXXFLAGS RCFLAGS PATH) - - z_vcpkg_make_set_common_vars() - z_vcpkg_get_global_property(prepare_flags_opts "make_prepare_flags_opts") - - z_vcpkg_make_prepare_flags(${prepare_flags_opts}) - - set(prepare_env_opts "") - - foreach(buildtype IN LISTS buildtypes) - string(TOUPPER "${buildtype}" cmake_buildtype) - set(short_buildtype "${suffix_${cmake_buildtype}}") - set(path_suffix "${path_suffix_${cmake_buildtype}}") - - set(working_directory "${workdir_${cmake_buildtype}}") - message(STATUS "Building/Installing ${TARGET_TRIPLET}-${short_buildtype}") - - # Setup environment - z_vcpkg_make_prepare_env("${cmake_buildtype}" ${prepare_env_opts}) - z_vcpkg_make_prepare_programs(configure_env ${prepare_flags_opts} CONFIG "${cmake_buildtype}") - - set(destdir_opt "DESTDIR=${destdir}") - - set(extra_opts "") - if(NOT VCPKG_TARGET_IS_OSX) - set(extra_opts --trace) - endif() - - foreach(target IN LISTS arg_TARGETS) - vcpkg_list(SET make_cmd_line ${make_command} ${arg_OPTIONS} ${arg_OPTIONS_${cmake_buildtype}} V=1 -j ${VCPKG_CONCURRENCY} ${extra_opts} -f ${arg_MAKEFILE} ${target} ${destdir_opt}) - vcpkg_list(SET no_parallel_make_cmd_line ${make_command} ${arg_OPTIONS} ${arg_OPTIONS_${cmake_buildtype}} V=1 -j 1 ${extra_opts} -f ${arg_MAKEFILE} ${target} ${destdir_opt}) - message(STATUS "Making target '${target}' for ${TARGET_TRIPLET}-${short_buildtype}") - if (arg_DISABLE_PARALLEL) - vcpkg_run_shell_as_build( - WORKING_DIRECTORY "${working_directory}" - LOGNAME "${arg_LOGFILE_ROOT}-${target}-${TARGET_TRIPLET}-${short_buildtype}" - SHELL ${shell_cmd} - NO_PARALLEL_COMMAND ${configure_env} ${no_parallel_make_cmd_line} - ) - else() - vcpkg_run_shell_as_build( - WORKING_DIRECTORY "${working_directory}" - LOGNAME "${arg_LOGFILE_ROOT}-${target}-${TARGET_TRIPLET}-${short_buildtype}" - SHELL ${shell_cmd} - COMMAND ${configure_env} ${no_parallel_make_cmd_line} - NO_PARALLEL_COMMAND ${configure_env} ${no_parallel_make_cmd_line} - ) - endif() - file(READ "${CURRENT_BUILDTREES_DIR}/${arg_LOGFILE_ROOT}-${target}-${TARGET_TRIPLET}-${short_buildtype}-out.log" logdata) - if(logdata MATCHES "Warning: linker path does not have real file for library") - message(FATAL_ERROR "libtool could not find a file being linked against!") - endif() - endforeach() - - z_vcpkg_make_restore_env() - - vcpkg_restore_env_variables(VARS LIB LIBPATH LIBRARY_PATH) - endforeach() - - ## TODO: Fix DESTDIR handling - string(REGEX REPLACE "([a-zA-Z]):/" "/\\1/" destdir_suffix "${CURRENT_INSTALLED_DIR}") - if (EXISTS "${CURRENT_PACKAGES_DIR}${destdir_suffix}") # <- Means DESTDIR was correctly used; need to move files. - file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}_tmp") - file(RENAME "${CURRENT_PACKAGES_DIR}" "${CURRENT_PACKAGES_DIR}_tmp") - file(RENAME "${CURRENT_PACKAGES_DIR}_tmp${destdir_suffix}" "${CURRENT_PACKAGES_DIR}") - file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}_tmp") - endif() - - # Remove libtool files since they contain absolute paths and are not necessary. - file(GLOB_RECURSE libtool_files "${CURRENT_PACKAGES_DIR}/**/*.la") - if(libtool_files) - file(REMOVE ${libtool_files}) - endif() - - if (CMAKE_HOST_WIN32) - set(ENV{PATH} "${path_backup}") - endif() - - vcpkg_restore_env_variables(VARS LIB LIBPATH LIBRARY_PATH LD_LIBRARY_PATH CPPFLAGS CFLAGS CXXFLAGS RCFLAGS) -endfunction() diff --git a/vcpkg/ports/vcpkg-make/vcpkg_scripts.cmake b/vcpkg/ports/vcpkg-make/vcpkg_scripts.cmake deleted file mode 100644 index 6489635a8c..0000000000 --- a/vcpkg/ports/vcpkg-make/vcpkg_scripts.cmake +++ /dev/null @@ -1,203 +0,0 @@ -include_guard(GLOBAL) -function(vcpkg_insert_into_path) - cmake_parse_arguments(PARSE_ARGV 0 arg - "" - "PATH_OUT;APPENDED_OUT" - "BEFORE;INSERT" - ) - z_vcpkg_unparsed_args(FATAL_ERROR) - cmake_path(CONVERT "$ENV{PATH}" TO_CMAKE_PATH_LIST path_list NORMALIZE) - - string(TOUPPER "${arg_BEFORE}" before_upper) - - set(index 0) - set(appending TRUE) - foreach(item IN LISTS path_list) - string(TOUPPER "${item}" item_upper) - if(item IN_LIST arg_BEFORE OR item_upper IN_LIST before_upper) - set(appending FALSE) - break() - endif() - math(EXPR index "${index} + 1") - endforeach() - - vcpkg_list(INSERT path_list "${index}" ${arg_INSERT}) - - cmake_path(CONVERT "${path_list}" TO_NATIVE_PATH_LIST native_path_list) - set(ENV{PATH} "${native_path_list}") - if(DEFINED arg_PATH_OUT) - set("${arg_PATH_OUT}" "${path_list}" PARENT_SCOPE) - endif() - if(appending) - set("${arg_APPENDED_OUT}" "TRUE" PARENT_SCOPE) - else() - set("${arg_APPENDED_OUT}" "FALSE" PARENT_SCOPE) - endif() -endfunction() - -function(vcpkg_insert_program_into_path prog) - set(filepath "${prog}") - cmake_path(GET filepath FILENAME ${prog}) - find_program(z_vcm_prog_found NAMES "${${prog}}" PATHS ENV PATH NO_DEFAULT_PATH NO_CACHE) - if(NOT z_vcm_prog_found STREQUAL filepath) - cmake_path(GET z_vcm_prog_found PARENT_PATH before_dir) - cmake_path(GET filepath PARENT_PATH dir) - vcpkg_insert_into_path( - INSERT "${dir}" - BEFORE "${before_dir}" - ) - endif() -endfunction() - -function(vcpkg_insert_msys_into_path msys_out) - cmake_parse_arguments(PARSE_ARGV 1 arg - "" - "PATH_OUT" - "PACKAGES" - ) - z_vcpkg_unparsed_args(FATAL_ERROR) - vcpkg_acquire_msys(MSYS_ROOT PACKAGES ${arg_PACKAGES}) - 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) - - vcpkg_list(SET find_system_dirs - "${system_root}/system32" - "${system_root}/System32" - "${system_root}/system32/" - "${system_root}/System32/" - "${local_app_data}/Microsoft/WindowsApps" - "${local_app_data}/Microsoft/WindowsApps/" - ) - - vcpkg_insert_into_path( - INSERT "${MSYS_ROOT}/usr/bin" - BEFORE ${find_system_dirs} - PATH_OUT path_out - APPENDED_OUT appending - ) - - if(appending) - message(WARNING "Unable to find system dir in the PATH variable! Appending required msys paths!") - endif() - - if(DEFINED arg_PATH_OUT) - set("${arg_PATH_OUT}" "${path_out}" PARENT_SCOPE) - endif() - - set("${msys_out}" "${MSYS_ROOT}" PARENT_SCOPE) -endfunction() - -### Helper macros for argument checking -macro(z_vcpkg_unparsed_args warning_level) - if(DEFINED arg_UNPARSED_ARGUMENTS) - message("${warning_level}" "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}") - endif() -endmacro() - -macro(z_vcpkg_conflicting_args) - set(conflicting_args_set "") - foreach(z_vcpkg_conflicting_args_index RANGE 0 "${ARGC}") - if(${ARGV${z_vcpkg_conflicting_args_index}}) - list(APPEND conflicting_args_set "${ARGV${z_vcpkg_conflicting_args_index}}") - endif() - endforeach() - list(LENGTH conflicting_args_set conflicting_args_set_length) - if(conflicting_args_set_length GREATER 1) - message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} was passed conflicting arguments:'${conflicting_args_set}'. Only one of those arguments can be passed") - endif() - unset(conflicting_args_set_length) - unset(conflicting_args_set) - unset(z_vcpkg_conflicting_args_index) -endmacro() - -macro(z_vcpkg_required_args arg) - foreach(arg IN ITEMS ${ARGN}) - if(NOT DEFINED arg_${arg}) - message("FATAL_ERROR" "${CMAKE_CURRENT_FUNCTION} requires argument: ${arg}") - endif() - endforeach() -endmacro() - -function(z_vcpkg_set_global_property property value) - if(NOT ARGN STREQUAL "" AND NOT ARGN MATCHES "^APPEND(_STRING)?$") - message(FATAL_ERROR "'${CMAKE_CURRENT_FUNCTION}' called with invalid arguments '${ARGN}'") - endif() - set_property(GLOBAL ${ARGN} PROPERTY "z_vcpkg_global_property_${property}" "${value}") -endfunction() - -function(z_vcpkg_get_global_property outvar property) - if(NOT ARGN STREQUAL "" AND NOT ARGN STREQUAL "SET") - message(FATAL_ERROR "'${CMAKE_CURRENT_FUNCTION}' called with invalid arguments '${ARGN}'") - endif() - get_property(outprop GLOBAL PROPERTY "z_vcpkg_global_property_${property}" ${ARGN}) - set(${outvar} "${outprop}" PARENT_SCOPE) -endfunction() - -function(vcpkg_prepare_pkgconfig config) - set(subdir "") - if(config MATCHES "(DEBUG|debug)") - set(subdir "/debug") - endif() - - z_vcpkg_get_global_property(has_backup "make-pkg-config-backup-${envvar}" SET) - if(has_backup) - message(FATAL_ERROR "'${CMAKE_CURRENT_FUNCTION}' does not (yet) support recursive backups. Need to restore previous state first!") - endif() - - foreach(envvar IN ITEMS PKG_CONFIG PKG_CONFIG_PATH) - if(DEFINED ENV{${envvar}}) - z_vcpkg_set_global_property("make-pkg-config-backup-${envvar}" "$ENV{${envvar}}") - else() - z_vcpkg_set_global_property("make-pkg-config-backup-${envvar}" "") - endif() - endforeach() - - vcpkg_find_acquire_program(PKGCONFIG) - set(ENV{PKG_CONFIG} "${PKGCONFIG}") - - vcpkg_host_path_list(PREPEND ENV{PKG_CONFIG_PATH} - # After installation, (merged) 'lib' is always searched before 'share'. - "${CURRENT_PACKAGES_DIR}${subdir}/lib/pkgconfig" - "${CURRENT_INSTALLED_DIR}${subdir}/lib/pkgconfig" - "${CURRENT_PACKAGES_DIR}/share/pkgconfig" - "${CURRENT_INSTALLED_DIR}/share/pkgconfig" - ) -endfunction() - -function(vcpkg_restore_pkgconfig) - foreach(envvar IN ITEMS PKG_CONFIG PKG_CONFIG_PATH) - z_vcpkg_get_global_property(has_backup "make-pkg-config-backup-${envvar}" SET) - if(has_backup) - z_vcpkg_get_global_property(backup "make-pkg-config-backup-${envvar}") - set("ENV{${envvar}}" "${backup}") - z_vcpkg_set_global_property("make-pkg-config-backup-${envvar}" "") - else() - unset("ENV{${envvar}}") - endif() - endforeach() -endfunction() - -function(z_vcpkg_escape_spaces_in_path outvar invar) - string(REPLACE " " "\\ " current_installed_dir_escaped "${invar}") - set("${outvar}" "${current_installed_dir_escaped}" PARENT_SCOPE) -endfunction() - -function(z_vcpkg_warn_path_with_spaces) - vcpkg_list(SET z_vcm_paths_with_spaces) - if(CURRENT_BUILDTREES_DIR MATCHES " ") - vcpkg_list(APPEND z_vcm_paths_with_spaces "${CURRENT_BUILDTREES_DIR}") - endif() - if(CURRENT_PACKAGES_DIR MATCHES " ") - vcpkg_list(APPEND z_vcm_paths_with_spaces "${CURRENT_PACKAGES_DIR}") - endif() - if(CURRENT_INSTALLED_DIR MATCHES " ") - vcpkg_list(APPEND z_vcm_paths_with_spaces "${CURRENT_INSTALLED_DIR}") - endif() - if(z_vcm_paths_with_spaces) - # Don't bother with whitespace. The tools will probably fail and I tried very hard trying to make it work (no success so far)! - vcpkg_list(APPEND z_vcm_paths_with_spaces "Please move the path to one without whitespaces!") - list(JOIN z_vcm_paths_with_spaces "\n " z_vcm_paths_with_spaces) - message(STATUS "Warning: Paths with embedded space may be handled incorrectly by configure:\n ${z_vcm_paths_with_spaces}") - endif() -endfunction() diff --git a/vcpkg/ports/vcpkg-make/wrappers/cl_cpp_wrapper b/vcpkg/ports/vcpkg-make/wrappers/cl_cpp_wrapper deleted file mode 100644 index fb83f7b886..0000000000 --- a/vcpkg/ports/vcpkg-make/wrappers/cl_cpp_wrapper +++ /dev/null @@ -1,95 +0,0 @@ -#!/usr/bin/bash -# cl_cpp_wrapper -# Wrapper around MS's cl.exe to make it act more like Unix cpp - -PATH="$PATH:/usr/bin" - -case $MACHTYPE in - *-msys) - slash="-" - ;; - *) - slash="/" - ;; -esac - -# prog specifies the program that should be run cl.exe -prog=cl.exe -debug= -cppopt=("${slash}nologo") -cppopt+=("${slash}E") -verbose= -shared_index=-1 - -processargs() -{ -### Run through every option and convert it to the proper MS one -while test $# -gt 0; do - case "$1" in - -D*) optarg= ;; - -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;; - *) optarg= ;; - esac - gotparam=1 - case "$1" in - --help) - usage - exit 0 - ;; - --verbose) - verbose=1 - ;; - -*) - # Remaining '-' options are passed to the compiler - if test x$optarg != x ; then - cppopt+=("${slash}${1:1}=$optarg") - else - cppopt+=("${slash}${1:1}") - fi - ;; - - /*) - # All '/' options are assumed to be for cpp and are passed through - cppopt+=("${slash}${1:1}") - ;; - - *) - file=$1 - #cppopt+=("$1") - ;; - esac - shift -done -} - -# Whitespace in paths is dealt with by setting IFS and using bash arrays - -# processargs $CPP_FLAGS -IFS="" -processargs $@ - -if test x$V = x1 ; then - verbose=1 -fi - -if test -n "$verbose" ; then - echo -n "$prog" - for opt in "${cppopt[@]}" ; do - echo -n " \"$opt\"" - done - echo "" -fi - -[ $# -ge 1 -a -f "$1" ] && input="$file" || input="-" - -input_file="${file:-/proc/self/fd/0}" -if [ "$input_file" == "/proc/self/fd/0" ]; then - # CL does not support reading from STDIN so it is wrapped here. - tmpout=cpp_wrapper_$RANDOM.h - /usr/bin/cp $input_file $tmpout - exec $prog ${cppopt[@]} $tmpout - rm -f $tmpout -else - exec $prog ${cppopt[@]} $input_file -fi - diff --git a/vcpkg/ports/vcpkg-make/wrappers/windres-rc b/vcpkg/ports/vcpkg-make/wrappers/windres-rc deleted file mode 100644 index 93e0b127d3..0000000000 --- a/vcpkg/ports/vcpkg-make/wrappers/windres-rc +++ /dev/null @@ -1,122 +0,0 @@ -#! /bin/sh -# Wrapper for windres to rc which do not understand '-i -o --output-format'. -# cvtres is invoked by the linker -scriptversion=2022-08-24.12; # UTC - - -nl=' -' - -# We need space, tab and new line, in precisely that order. Quoting is -# there to prevent tools from complaining about whitespace usage. -IFS=" "" $nl" - -file_conv= - -# func_file_conv build_file lazy -# Convert a $build file to $host form and store it in $file -# Currently only supports Windows hosts. If the determined conversion -# type is listed in (the comma separated) LAZY, no conversion will -# take place. -func_file_conv () -{ - file=$1 - case $file in - / | /[!/]*) # absolute file, and not a UNC file - if test -z "$file_conv"; then - # lazily determine how to convert abs files - case `uname -s` in - MINGW*) - file_conv=mingw - ;; - CYGWIN* | MSYS*) - file_conv=cygwin - ;; - *) - file_conv=wine - ;; - esac - fi - case $file_conv/,$2, in - *,$file_conv,*) - ;; - mingw/*) - file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` - ;; - cygwin/* | msys/*) - file=`cygpath -m "$file" || echo "$file"` - ;; - wine/*) - file=`winepath -w "$file" || echo "$file"` - ;; - esac - ;; - esac -} - -# func_windres_wrapper rc args... -# Adjust compile command to suit rc instead of windres -func_windres_wrapper () -{ - # Assume a capable shell - bin= - in= - out= - - for arg - do - if test -z "$bin"; then - bin=$1 - elif test -n "$eat"; then - eat= - else - case $1 in - --output-format=*) - ;; - --define*) - eat=1 - set -- "$@" "-d $2" - ;; - --include-dir*) - eat=1 - func_file_conv "$2" - set -- "$@" "-I $file" - ;; - -o) - eat=1 - func_file_conv "$2" - out="$file" - echo "OUTPUT:$file" - ;; - *.obj) - func_file_conv "$1" - out="$file" - echo "OUTPUT:$file" - ;; - -i) - eat=1 - func_file_conv "$2" mingw - in="$file" - echo "INPUT:$file" - ;; - -*) - set -- "$@" "${1//\\\"/\"}" - ;; - *) - # libtool reorders arguments; save unqualified one as input - func_file_conv "$1" - in="$file" - echo "INPUT:$file" - ;; - esac - fi - shift - done - echo "$bin" "$@" -fo "$out" "$in" - exec "$bin" "$@" -fo "$out" "$in" - exit 1 -} - -eat= - -func_windres_wrapper "$@"