[vcpkg-make] Add new port (#39050)

Co-authored-by: Alexander Neumann <30894796+Neumann-A@users.noreply.github.com>
Co-authored-by: Alexander Neumann <alexander.neumann@hamburg.de>
Co-authored-by: Kai Pastor <dg0yt@darc.de>
Co-authored-by: Billy O'Neal <bion@microsoft.com>
Co-authored-by: Javier Matos <javiermatos@Javiers-Laptop.local>
This commit is contained in:
Javier Matos Denizac 2024-12-23 14:58:54 -05:00 committed by GitHub
parent 1bf27ad221
commit 80d54ff62d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
32 changed files with 2027 additions and 62 deletions

View File

@ -12,10 +12,8 @@ file(COPY "${CURRENT_INSTALLED_DIR}/share/coin-or-buildtools/" DESTINATION "${SO
set(ENV{ACLOCAL} "aclocal -I \"${SOURCE_PATH}/BuildTools\"")
vcpkg_configure_make(
vcpkg_make_configure(
SOURCE_PATH "${SOURCE_PATH}"
DETERMINE_BUILD_TRIPLET
USE_WRAPPERS
OPTIONS
--with-coinutils
--with-clp
@ -29,7 +27,7 @@ vcpkg_configure_make(
--disable-readline
)
vcpkg_install_make()
vcpkg_make_install()
vcpkg_copy_pdbs()
vcpkg_fixup_pkgconfig()

View File

@ -1,6 +1,7 @@
{
"name": "coin-or-cbc",
"version-date": "2024-06-04",
"port-version": 1,
"description": "Cbc (Coin-or branch and cut) is an open-source mixed integer linear programming solver written in C++.",
"homepage": "https://github.com/coin-or/Cbc",
"license": "EPL-2.0",
@ -8,6 +9,10 @@
"coin-or-cgl",
"coin-or-clp",
"coin-or-osi",
"coinutils"
"coinutils",
{
"name": "vcpkg-make",
"host": true
}
]
}

View File

@ -12,14 +12,15 @@ if(VCPKG_TARGET_IS_WINDOWS)
set(opts "ac_cv_search_log=none required" "--without-private-namespace")
endif()
vcpkg_configure_make(
vcpkg_make_configure(
AUTORECONF
SOURCE_PATH "${SOURCE_PATH}"
AUTOCONFIG
NO_WRAPPERS
DISABLE_MSVC_WRAPPERS
DISABLE_MSVC_TRANSFORMATIONS
OPTIONS ${opts}
)
vcpkg_install_make()
vcpkg_make_install()
if(VCPKG_TARGET_IS_WINDOWS)
file(COPY "${SOURCE_PATH}/include/msvc_compat/strings.h" DESTINATION "${CURRENT_PACKAGES_DIR}/include/jemalloc/msvc_compat")

View File

@ -1,8 +1,14 @@
{
"name": "jemalloc",
"version": "5.3.0",
"port-version": 1,
"port-version": 2,
"description": "jemalloc is a general purpose malloc(3) implementation that emphasizes fragmentation avoidance and scalable concurrency support",
"homepage": "https://jemalloc.net/",
"license": "BSD-2-Clause"
"license": "BSD-2-Clause",
"dependencies": [
{
"name": "vcpkg-make",
"host": true
}
]
}

View File

@ -28,11 +28,10 @@ if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
endif()
set(ENV{GTKDOCIZE} true)
vcpkg_configure_make(
vcpkg_make_configure(
SOURCE_PATH "${SOURCE_PATH}"
AUTOCONFIG
AUTORECONF
COPY_SOURCE # include dir order problem
USE_WRAPPERS
OPTIONS
${options}
--disable-gtk-doc
@ -47,7 +46,7 @@ vcpkg_configure_make(
"CFLAGS=\$CFLAGS -I${CURRENT_INSTALLED_DIR}/include"
)
vcpkg_install_make()
vcpkg_make_install()
vcpkg_fixup_pkgconfig()
vcpkg_copy_tool_dependencies("${CURRENT_PACKAGES_DIR}/tools/${PORT}/bin")

View File

@ -1,13 +1,17 @@
{
"name": "libidn2",
"version": "2.3.7",
"port-version": 1,
"port-version": 2,
"description": "GNU Libidn is an implementation of the Stringprep, Punycode and IDNA 2003 specifications. Libidn's purpose is to encode and decode internationalized domain names.",
"homepage": "https://www.gnu.org/software/libidn/",
"license": null,
"dependencies": [
"libiconv",
"libunistring"
"libunistring",
{
"name": "vcpkg-make",
"host": true
}
],
"features": {
"nls": {

View File

@ -0,0 +1,32 @@
set(VCPKG_POLICY_CMAKE_HELPER_PORT enabled)
vcpkg_download_distfile(ARCHIVE
URLS https://ftp.gnu.org/gnu/automake/automake-1.17.tar.gz
FILENAME automake.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(FILE_LIST "${VCPKG_ROOT_DIR}/LICENSE.txt")

View File

@ -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")

View File

@ -0,0 +1,15 @@
{
"name": "vcpkg-make",
"version-date": "2023-05-15",
"documentation": "https://vcpkg.io/en/docs/maintainers/ports/vcpkg-make.html",
"license": "MIT",
"supports": "native",
"dependencies": [
{
"name": "pkgconf",
"host": true,
"platform": "windows"
},
"vcpkg-cmake-get-vars"
]
}

View File

@ -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()

View File

@ -0,0 +1,659 @@
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 an assume valid architectures
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()
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=<x>).
# libtool has an -R option so we need to guard against -RTC by using -Xcompiler.
# While configuring there might be a lot of unknown compiler option warnings
# due to that; just ignore them.
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)
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()

View File

@ -0,0 +1,132 @@
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()
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()

View File

@ -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()

View File

@ -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)
get_filename_component(pkgconfig_path "${PKGCONFIG}" DIRECTORY)
set(ENV{PKG_CONFIG} "${PKGCONFIG}")
vcpkg_host_path_list(PREPEND ENV{PKG_CONFIG_PATH}
"${CURRENT_INSTALLED_DIR}/share/pkgconfig/"
"${CURRENT_INSTALLED_DIR}${subdir}/lib/pkgconfig/"
"${CURRENT_PACKAGES_DIR}/share/pkgconfig/"
"${CURRENT_PACKAGES_DIR}${subdir}/lib/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()

View File

@ -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

View File

@ -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 "$@"

View File

@ -11,6 +11,5 @@ index 6f95e2314..e677e36f4 100644
# Standard Microsoft Visual Studio
compiler=CL
compiler_style=MS
+ CFLAGS="$CPPFLAGS $CFLAGS -nologo -GS- -DHAVE_STRING_H -I\$(SRCPATH)/extras"
- CFLAGS="$CFLAGS -nologo -GS- -DHAVE_STRING_H -I\$(SRCPATH)/extras"
CFLAGS="$CFLAGS -nologo -GS- -DHAVE_STRING_H -I\$(SRCPATH)/extras"
cpp_check '' '' '_MSC_VER > 1800 || (_MSC_VER == 1800 && _MSC_FULL_VER >= 180030324)' || die "Microsoft Visual Studio support requires Visual Studio 2013 Update 2 or newer"

View File

@ -26,36 +26,13 @@ vcpkg_from_gitlab(
configure.patch
)
# Ensure that 'ENV{PATH}' leads to tool 'name' exactly at 'filepath'.
function(ensure_tool_in_path name filepath)
unset(program_found CACHE)
find_program(program_found "${name}" PATHS ENV PATH NO_DEFAULT_PATH NO_CACHE)
if(NOT filepath STREQUAL program_found)
cmake_path(GET filepath PARENT_PATH parent_path)
vcpkg_add_to_path(PREPEND "${parent_path}")
endif()
function(add_cross_prefix)
if(configure_env MATCHES "CC=([^\/]*-)gcc$")
vcpkg_list(APPEND arg_OPTIONS "--cross-prefix=${CMAKE_MATCH_1}")
endif()
set(arg_OPTIONS "${arg_OPTIONS}" PARENT_SCOPE)
endfunction()
# Ensure that parent-scope variable 'var' doesn't contain a space,
# updating 'ENV{PATH}' and 'var' if needed.
function(transform_path_no_space var)
set(path "${${var}}")
if(path MATCHES " ")
cmake_path(GET path FILENAME program_name)
set("${var}" "${program_name}" PARENT_SCOPE)
ensure_tool_in_path("${program_name}" "${path}")
endif()
endfunction()
vcpkg_cmake_get_vars(cmake_vars_file)
include("${cmake_vars_file}")
transform_path_no_space(VCPKG_DETECTED_CMAKE_C_COMPILER)
set(ENV{CC} "${VCPKG_DETECTED_CMAKE_C_COMPILER}")
vcpkg_list(SET OPTIONS)
vcpkg_list(SET EXTRA_ARGS)
set(nasm_archs x86 x64)
set(gaspp_archs arm arm64)
if(NOT "asm" IN_LIST FEATURES)
@ -64,10 +41,8 @@ elseif(NOT "$ENV{AS}" STREQUAL "")
# Accept setting from triplet
elseif(VCPKG_TARGET_ARCHITECTURE IN_LIST nasm_archs)
vcpkg_find_acquire_program(NASM)
transform_path_no_space(NASM)
list(APPEND EXTRA_ARGS CONFIGURE_ENVIRONMENT_VARIABLES AS)
set(AS "${NASM}") # for CONFIGURE_ENVIRONMENT_VARIABLES
set(ENV{AS} "${NASM}") # for non-WIN32
vcpkg_insert_program_into_path("${NASM}")
set(ENV{AS} "${NASM}")
elseif(VCPKG_TARGET_ARCHITECTURE IN_LIST gaspp_archs AND VCPKG_TARGET_IS_WINDOWS AND VCPKG_HOST_IS_WINDOWS)
vcpkg_find_acquire_program(GASPREPROCESSOR)
list(FILTER GASPREPROCESSOR INCLUDE REGEX gas-preprocessor)
@ -93,11 +68,14 @@ if(VCPKG_TARGET_IS_UWP)
list(APPEND OPTIONS --extra-cflags=-D_WIN32_WINNT=0x0A00)
endif()
vcpkg_configure_make(
vcpkg_make_configure(
SOURCE_PATH "${SOURCE_PATH}"
NO_ADDITIONAL_PATHS
DETERMINE_BUILD_TRIPLET
${EXTRA_ARGS}
DISABLE_CPPFLAGS # Build is not using CPP/CPPFLAGS
DISABLE_MSVC_WRAPPERS
LANGUAGES ASM C CXX # Requires NASM to compile
DISABLE_MSVC_TRANSFORMATIONS # disable warnings about unknown -Xcompiler/-Xlinker flags
PRE_CONFIGURE_CMAKE_COMMANDS
add_cross_prefix
OPTIONS
${OPTIONS}
--enable-pic
@ -116,7 +94,7 @@ vcpkg_configure_make(
--disable-cli
)
vcpkg_install_make()
vcpkg_make_install()
if("tool" IN_LIST FEATURES)
vcpkg_copy_tools(TOOL_NAMES x264 AUTO_CLEAN)
@ -149,4 +127,4 @@ vcpkg_fixup_pkgconfig()
vcpkg_copy_pdbs()
file(INSTALL "${SOURCE_PATH}/COPYING" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/COPYING")

View File

@ -1,13 +1,14 @@
{
"name": "x264",
"version": "0.164.3108",
"port-version": 1,
"description": "x264 is a free software library and application for encoding video streams into the H.264/MPEG-4 AVC compression format",
"homepage": "https://www.videolan.org/developers/x264.html",
"license": "GPL-2.0-or-later",
"supports": "!xbox",
"dependencies": [
{
"name": "vcpkg-cmake-get-vars",
"name": "vcpkg-make",
"host": true
}
],

View File

@ -0,0 +1,22 @@
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
include("${CMAKE_CURRENT_LIST_DIR}/../unit-test-cmake/portfile.cmake")
if("z-vcpkg-make-prepare-compile-flags" IN_LIST FEATURES)
include("${CMAKE_CURRENT_LIST_DIR}/test-z_vcpkg_make_prepare_compile_flags.cmake")
endif()
if("z-vcpkg-make-determine-arch" IN_LIST FEATURES)
include("${CMAKE_CURRENT_LIST_DIR}/test-z_vcpkg_make_determine_arch.cmake")
endif()
if("z-vcpkg-make-determine-host-arch" IN_LIST FEATURES)
include("${CMAKE_CURRENT_LIST_DIR}/test-z_vcpkg_make_determine_host_arch.cmake")
endif()
if("z-vcpkg-make-determine-target-arch" IN_LIST FEATURES)
include("${CMAKE_CURRENT_LIST_DIR}/test-z_vcpkg_make_determine_target_arch.cmake")
endif()
if("z-vcpkg-make-z-adapt-lib-link-names" IN_LIST FEATURES)
include("${CMAKE_CURRENT_LIST_DIR}/test-z_adapt_lib_link_names.cmake")
endif()

View File

@ -0,0 +1,51 @@
# Test 1: Basic Transformation
set(all_libs_list "libexample.dll;libutil.a;libutil2.lib;libutil3.so")
set(expected "-llibexample.dll;-llibutil;-llibutil2;-llibutil3")
set(VCPKG_TARGET_IS_WINDOWS FALSE)
set(VCPKG_TARGET_IS_MINGW FALSE)
set(VCPKG_LIBRARY_LINKAGE "static")
unit_test_check_variable_equal(
[[ z_vcpkg_make_prepare_link_flags(IN_OUT_VAR all_libs_list VCPKG_TRANSFORM_LIBS) ]]
all_libs_list
"${expected}"
)
# Test 2: Remove uuid on Windows
set(all_libs_list "libexample.dll;uuid.lib")
set(expected "-llibexample.dll")
set(VCPKG_TARGET_IS_WINDOWS TRUE)
set(VCPKG_TARGET_IS_MINGW FALSE)
set(VCPKG_LIBRARY_LINKAGE "static")
unit_test_check_variable_equal(
[[ z_vcpkg_make_prepare_link_flags(IN_OUT_VAR all_libs_list VCPKG_TRANSFORM_LIBS) ]]
all_libs_list
"${expected}"
)
# Test 3: MinGW Dynamic Linkage Handling
set(all_libs_list "libexample.so;uuid.a")
set(expected "-llibexample;-Wl,-Bstatic,-luuid,-Bdynamic")
set(VCPKG_TARGET_IS_WINDOWS FALSE)
set(VCPKG_TARGET_IS_MINGW TRUE)
set(VCPKG_LIBRARY_LINKAGE "dynamic")
unit_test_check_variable_equal(
[[ z_vcpkg_make_prepare_link_flags(IN_OUT_VAR all_libs_list VCPKG_TRANSFORM_LIBS) ]]
all_libs_list
"${expected}"
)
# Test 4: No Transformation Flag
set(all_libs_list "libexample.dll;uuid.lib")
set(expected "libexample.dll;uuid.lib")
set(VCPKG_TARGET_IS_WINDOWS FALSE)
set(VCPKG_TARGET_IS_MINGW FALSE)
set(VCPKG_LIBRARY_LINKAGE "static")
unit_test_check_variable_equal(
[[ z_vcpkg_make_prepare_link_flags(IN_OUT_VAR all_libs_list) ]]
all_libs_list
"${expected}"
)

View File

@ -0,0 +1,28 @@
set(test_cases
"amd64" "x86_64"
"AMD64" "x86_64"
"x64" "x86_64"
"x86" "i686"
"X86" "i686"
"ARM64" "aarch64"
"arm64" "aarch64"
"ARM" "arm"
"arm" "arm"
"x86_64" "x86_64"
"i686" "i686"
"aarch64" "aarch64"
)
list(LENGTH test_cases num_items)
math(EXPR num_tests "${num_items} / 2 - 1")
foreach(idx RANGE 0 ${num_tests})
math(EXPR input_idx "${idx} * 2")
math(EXPR output_idx "${idx} * 2 + 1")
list(GET test_cases ${input_idx} input)
list(GET test_cases ${output_idx} expected)
set(result_arch)
z_vcpkg_make_determine_arch(result_arch ${input})
unit_test_check_variable_equal([[]] result_arch "${expected}")
endforeach()

View File

@ -0,0 +1,14 @@
# Test Case 1: x86_64 Architecture (Windows)
set(ENV{PROCESSOR_ARCHITECTURE} "AMD64")
set(result_arch)
z_vcpkg_make_determine_host_arch(result_arch)
unit_test_check_variable_equal([[]] result_arch "x86_64")
# Test Case 2: i686 Architecture (Windows)
set(ENV{PROCESSOR_ARCHITEW6432} "x86")
set(result_arch)
z_vcpkg_make_determine_host_arch(result_arch)
unit_test_check_variable_equal([[]] result_arch "i686")
unset(ENV{PROCESSOR_ARCHITECTURE})
unset(ENV{PROCESSOR_ARCHITEW6432})

View File

@ -0,0 +1,15 @@
# Test Case 1: Single Target Architecture
set(VCPKG_TARGET_ARCHITECTURE "x86_64")
set(VCPKG_OSX_ARCHITECTURES "x86_64") # Empty for non-OSX
set(result_arch)
z_vcpkg_make_determine_target_arch(result_arch)
unit_test_check_variable_equal([[]] result_arch "x86_64")
# Test Case 2: Universal Architecture (OSX)
if (VCPKG_HOST_IS_OSX)
set(VCPKG_TARGET_ARCHITECTURE "x86_64")
set(VCPKG_OSX_ARCHITECTURES "x86_64;arm64")
set(result_arch)
z_vcpkg_make_determine_target_arch(result_arch)
unit_test_check_variable_equal([[]] result_arch "universal")
endif()

View File

@ -0,0 +1,99 @@
set(VCPKG_COMBINED_C_FLAGS_Release "-O2 -DNDEBUG")
set(VCPKG_COMBINED_CXX_FLAGS_Release "-O2 -DNDEBUG")
set(VCPKG_COMBINED_C_FLAGS_Debug "-g -O0 -DDEBUG")
set(VCPKG_COMBINED_CXX_FLAGS_Debug "-g -O0 -DDEBUG")
set(VCPKG_COMBINED_SHARED_LINKER_FLAGS_Release "-L/mylibpath")
set(VCPKG_COMBINED_SHARED_LINKER_FLAGS_Debug "-L/debuglibpath")
set(CURRENT_INSTALLED_DIR "C:/vcpkg_installed/x64-windows")
# Test Case: Release Flag Generation
set(flags_out)
z_vcpkg_make_prepare_compile_flags(
COMPILER_FRONTEND "MSVC"
CONFIG "Release"
FLAGS_OUT flags_out
LANGUAGES "C" "CXX"
)
set(expected_cflags "-Xcompiler -O2 -Xcompiler -DNDEBUG")
set(expected_cxxflags "-Xcompiler -O2 -Xcompiler -DNDEBUG")
set(expected_ldflags "-Xlinker -Xlinker -Xlinker -L/mylibpath")
unit_test_check_variable_equal([[]] CFLAGS_Release "${expected_cflags}")
unit_test_check_variable_equal([[]] CXXFLAGS_Release "${expected_cxxflags}")
unit_test_check_variable_equal([[]] LDFLAGS_Release "${expected_ldflags}")
# Test Case: Debug flag generation
set(flags_out)
z_vcpkg_make_prepare_compile_flags(
COMPILER_FRONTEND "MSVC"
CONFIG "Debug"
FLAGS_OUT flags_out
LANGUAGES "C" "CXX"
)
# Expected Debug flags
set(expected_cflags "-Xcompiler -g -Xcompiler -O0 -Xcompiler -DDEBUG")
set(expected_cxxflags "-Xcompiler -g -Xcompiler -O0 -Xcompiler -DDEBUG")
set(expected_ldflags "-Xlinker -Xlinker -Xlinker -L/debuglibpath")
# Check the values of the Debug flags
unit_test_check_variable_equal([[]] CFLAGS_Debug "${expected_cflags}")
unit_test_check_variable_equal([[]] CXXFLAGS_Debug "${expected_cxxflags}")
unit_test_check_variable_equal([[]] LDFLAGS_Debug "${expected_ldflags}")
# Test Case: NO_FLAG_ESCAPING (MSVC, Debug)
set(flags_out)
unset(CFLAGS_Debug)
unset(CXXFLAGS_Debug)
unset(LDFLAGS_Debug)
z_vcpkg_make_prepare_compile_flags(
NO_FLAG_ESCAPING
COMPILER_FRONTEND "MSVC"
CONFIG "Debug"
FLAGS_OUT flags_out
LANGUAGES "C" "CXX"
)
set(expected_cflags "-g -O0 -DDEBUG")
set(expected_cxxflags "-g -O0 -DDEBUG")
set(expected_ldflags "-L/debuglibpath")
unit_test_check_variable_equal([[]] CFLAGS_Debug "${expected_cflags}")
unit_test_check_variable_equal([[]] CXXFLAGS_Debug "${expected_cxxflags}")
unit_test_check_variable_equal([[]] LDFLAGS_Debug "${expected_ldflags}")
# Test Case: Different Languages and Compiler Frontend (GCC)
set(flags_out)
z_vcpkg_make_prepare_compile_flags(
COMPILER_FRONTEND "GCC"
CONFIG "Release"
FLAGS_OUT flags_out
LANGUAGES "C" "CXX" "ASM"
)
unit_test_check_variable_unset([[]] "${ASMFLAGS_Release}")
set(expected_gcc_cflags "-O2 -DNDEBUG")
unit_test_check_variable_equal([[]] expected_gcc_cflags "${CFLAGS_Release}")
# Test Case: No Languages Defined (Should Default to C;CXX)
set(flags_out)
unset(CFLAGS_Release)
unset(CXXFLAGS_Release)
unset(LDFLAGS_Release)
unset(ASMFLAGS_Release)
z_vcpkg_make_prepare_compile_flags(
COMPILER_FRONTEND "MSVC"
CONFIG "Release"
FLAGS_OUT flags_out
)
# Verify that both CFLAGS and CXXFLAGS are set since they should default to C and C++
if(NOT CFLAGS_Release)
message(FATAL_ERROR "CFLAGS_Release not set")
endif()
if(NOT CXXFLAGS_Release)
message(FATAL_ERROR "CXXFLAGS_Release not set")
endif()

View File

@ -0,0 +1,37 @@
{
"name": "vcpkg-make-tests",
"version-string": "0",
"description": "Ensures that the vcpkg-make port functions are unit tested.",
"license": "MIT",
"dependencies": [
{
"name": "vcpkg-make",
"host": true
}
],
"default-features": [
"z-vcpkg-make-prepare-compile-flags",
"z-vcpkg-make-determine-arch",
"z-vcpkg-make-determine-host-arch",
"z-vcpkg-make-determine-target-arch",
"z-vcpkg-make-z-adapt-lib-link-names"
],
"features": {
"z-vcpkg-make-prepare-compile-flags": {
"description": "Test the z_vcpkg_make_prepare_compile_flags function"
},
"z-vcpkg-make-determine-arch":{
"description": "Test the z_vcpkg_make_determine_arch function"
},
"z-vcpkg-make-determine-host-arch":{
"description": "Test the z_vcpkg_make_determine_host_arch function"
},
"z-vcpkg-make-determine-target-arch":{
"description": "Test the z_vcpkg_make_determine_target_arch function"
},
"z-vcpkg-make-z-adapt-lib-link-names":{
"description": "Test the z_vcpkg_make_z_adapt_lib_link_names function"
}
}
}

View File

@ -1778,7 +1778,7 @@
},
"coin-or-cbc": {
"baseline": "2024-06-04",
"port-version": 0
"port-version": 1
},
"coin-or-cgl": {
"baseline": "2023-02-01",
@ -3834,7 +3834,7 @@
},
"jemalloc": {
"baseline": "5.3.0",
"port-version": 1
"port-version": 2
},
"jhasse-poly2tri": {
"baseline": "2023-12-27",
@ -4698,7 +4698,7 @@
},
"libidn2": {
"baseline": "2.3.7",
"port-version": 1
"port-version": 2
},
"libigl": {
"baseline": "2.5.0",
@ -9388,6 +9388,10 @@
"baseline": "2024-02-22",
"port-version": 0
},
"vcpkg-make": {
"baseline": "2023-05-15",
"port-version": 0
},
"vcpkg-msbuild": {
"baseline": "2023-08-08",
"port-version": 0
@ -9758,7 +9762,7 @@
},
"x264": {
"baseline": "0.164.3108",
"port-version": 0
"port-version": 1
},
"x265": {
"baseline": "3.6",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "b0c13a7eef211d2564992a9c2f50f2b7ba0b5659",
"version-date": "2024-06-04",
"port-version": 1
},
{
"git-tree": "090a59c4e81596de0b292188298fc5bbc3d75f84",
"version-date": "2024-06-04",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "c89a63053caf864aff15f36cf9fa0e6b2ded6bfc",
"version": "5.3.0",
"port-version": 2
},
{
"git-tree": "96ec9736a357ac7af9b108bcc8e9d237cfb18a43",
"version": "5.3.0",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "328e0431111dc594862afb21b8a160f982794e9b",
"version": "2.3.7",
"port-version": 2
},
{
"git-tree": "a890ad8c5cfa0e4400e7227e85e7ee4e514f7e2b",
"version": "2.3.7",

View File

@ -0,0 +1,9 @@
{
"versions": [
{
"git-tree": "50a2b6aaf3c272b1eff8ce757e14091c374d9855",
"version-date": "2023-05-15",
"port-version": 0
}
]
}

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "0b3254a0abf3a2a2748b7353594b401893f74da9",
"version": "0.164.3108",
"port-version": 1
},
{
"git-tree": "1e1d8374cc8a7fe139d82433d27e64e972365517",
"version": "0.164.3108",