Skip to content

Commit

Permalink
[vcpkg] sync upstream scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkvdb committed Jan 7, 2025
1 parent 508b83b commit 535b0bc
Show file tree
Hide file tree
Showing 123 changed files with 4,521 additions and 2,221 deletions.
2 changes: 1 addition & 1 deletion bootstrap.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
find_package(Git)

set(VCPKG_TAG "2024-02-07")
set(VCPKG_TAG "2024-12-09")
set(BUILD_DIR ${CMAKE_CURRENT_LIST_DIR}/buildtrees)
set(BIN_DIR ${CMAKE_CURRENT_LIST_DIR})
set(VCPKG_BUILD_DIR ${BUILD_DIR}/vcpkg-tool)
Expand Down
2 changes: 1 addition & 1 deletion ports/gdal/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ endif()

set(WITH_ICONV ON)

if(MINGW)
if(VCPKG_TARGET_IS_MINGW)
set(WITH_ICONV OFF)
endif()

Expand Down
97 changes: 97 additions & 0 deletions ports/vcpkg-boost/boost-install.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
include_guard(GLOBAL)

function(boost_configure_and_install)
cmake_parse_arguments(PARSE_ARGV 0 "arg" "" "SOURCE_PATH" "OPTIONS")

string(REPLACE "-" "_" boost_lib_name "${PORT}")
string(REPLACE "boost_" "" boost_lib_name "${boost_lib_name}")
set(boost_lib_name_config "${boost_lib_name}")

set(headers_only OFF)
if(NOT EXISTS "${arg_SOURCE_PATH}/src" OR Z_VCPKG_BOOST_FORCE_HEADER_ONLY) # regex|system|math are header only and only install libs due to compat
set(headers_only ON)
set(VCPKG_BUILD_TYPE release)
endif()

set(boost_lib_path "libs/${boost_lib_name}")
if(boost_lib_name MATCHES "numeric")
string(REPLACE "numeric_" "numeric/" boost_lib_path "${boost_lib_path}")
string(REPLACE "numeric_" "numeric/" boost_lib_name "${boost_lib_name}")
elseif(PORT MATCHES "boost-(ublas|odeint|interval)")
set(boost_lib_name_config "numeric_${boost_lib_name}")
set(boost_lib_path "libs/numeric/${boost_lib_name}")
set(boost_lib_name "numeric/${boost_lib_name}")
endif()

if(NOT EXISTS "${arg_SOURCE_PATH}/libs") # Check for --editable workflow
set(target_path "${arg_SOURCE_PATH}/${boost_lib_path}")
cmake_path(GET target_path PARENT_PATH parent_path)
file(RENAME "${arg_SOURCE_PATH}/" "${arg_SOURCE_PATH}.tmp/")
file(MAKE_DIRECTORY "${parent_path}")
file(RENAME "${arg_SOURCE_PATH}.tmp/" "${target_path}")
endif()

file(WRITE "${arg_SOURCE_PATH}/CMakeLists.txt" " \
cmake_minimum_required(VERSION 3.25) \n\
\n\
project(Boost VERSION ${VERSION} LANGUAGES CXX) \n\
\n\
set(BOOST_SUPERPROJECT_VERSION \${PROJECT_VERSION}) \n\
set(BOOST_SUPERPROJECT_SOURCE_DIR \"\${PROJECT_SOURCE_DIR}\") \n\
\n\
list(APPEND CMAKE_MODULE_PATH \"${CURRENT_INSTALLED_DIR}/share/boost/cmake-build\") \n\
\n\
include(BoostRoot) \n\
")

if("${PORT}" MATCHES "boost-(mpi|graph-parallel|property-map-parallel)")
list(APPEND arg_OPTIONS -DBOOST_ENABLE_MPI=ON)
endif()

if("${PORT}" MATCHES "boost-(python|parameter-python)")
list(APPEND arg_OPTIONS -DBOOST_ENABLE_PYTHON=ON)
endif()

vcpkg_cmake_configure(
SOURCE_PATH "${arg_SOURCE_PATH}"
OPTIONS
-DBOOST_INCLUDE_LIBRARIES=${boost_lib_name}
-DBOOST_RUNTIME_LINK=${VCPKG_CRT_LINKAGE}
"-DBOOST_INSTALL_INCLUDE_SUBDIR="
"-DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT="
${arg_OPTIONS}
)

vcpkg_cmake_install()

file(GLOB cmake_paths "${CURRENT_PACKAGES_DIR}/lib/cmake/*" LIST_DIRECTORIES true)
file(GLOB cmake_files "${CURRENT_PACKAGES_DIR}/lib/cmake/*" LIST_DIRECTORIES false)
list(REMOVE_ITEM cmake_paths "${cmake_files}" "${CURRENT_PACKAGES_DIR}/lib/cmake/boost_${boost_lib_name_config}-${VERSION}")
foreach(config_path IN LISTS cmake_paths)
string(REPLACE "-${VERSION}" "" config_path "${config_path}")
string(REPLACE "${CURRENT_PACKAGES_DIR}/lib/cmake/" "" config_name "${config_path}")
vcpkg_cmake_config_fixup(PACKAGE_NAME ${config_name} CONFIG_PATH lib/cmake/${config_name}-${VERSION} DO_NOT_DELETE_PARENT_CONFIG_PATH)
endforeach()
if(NOT PORT MATCHES "boost-(stacktrace|test)")
vcpkg_cmake_config_fixup(PACKAGE_NAME boost_${boost_lib_name_config} CONFIG_PATH lib/cmake/boost_${boost_lib_name_config}-${VERSION})
else()
# These ports have no cmake config agreeing with the port name
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/lib/cmake" "${CURRENT_PACKAGES_DIR}/debug/lib/cmake")
endif()

if(headers_only)
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/lib" "${CURRENT_PACKAGES_DIR}/debug/lib")
endif()
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share"
"${CURRENT_PACKAGES_DIR}/debug/include"
)
vcpkg_install_copyright(FILE_LIST "${CURRENT_INSTALLED_DIR}/share/boost-cmake/copyright")

# Install port specific usage
string(REPLACE "-" "_" PORT_UNDERSCORE "${PORT}")
string(REPLACE "boost_" "" BOOST_PORT_NAME "${PORT_UNDERSCORE}")
if(PORT MATCHES "boost-(ublas|odeint|interval)")
string(PREPEND BOOST_PORT_NAME "numeric_")
endif()
configure_file("${CURRENT_HOST_INSTALLED_DIR}/share/vcpkg-boost/usage.in" "${CURRENT_INSTALLED_DIR}/share/${PORT}/usage")
endfunction()
8 changes: 8 additions & 0 deletions ports/vcpkg-boost/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
file(INSTALL
"${CMAKE_CURRENT_LIST_DIR}/usage.in"
"${CMAKE_CURRENT_LIST_DIR}/boost-install.cmake"
"${CMAKE_CURRENT_LIST_DIR}/vcpkg-port-config.cmake"
DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")

vcpkg_install_copyright(FILE_LIST "${VCPKG_ROOT_DIR}/LICENSE.txt")
set(VCPKG_POLICY_CMAKE_HELPER_PORT enabled)
9 changes: 9 additions & 0 deletions ports/vcpkg-boost/usage.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
The package @PORT@ is compatible with built-in CMake targets of FindBoost.cmake:

find_package(Boost REQUIRED COMPONENTS @BOOST_PORT_NAME@)
target_link_libraries(main PRIVATE Boost::@BOOST_PORT_NAME@)

or the generated cmake configs via:

find_package(@PORT_UNDERSCORE@ REQUIRED CONFIG)
target_link_libraries(main PRIVATE Boost::@BOOST_PORT_NAME@)
5 changes: 5 additions & 0 deletions ports/vcpkg-boost/vcpkg-port-config.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include_guard(GLOBAL)

include("${CURRENT_HOST_INSTALLED_DIR}/share/vcpkg-cmake/vcpkg-port-config.cmake")
include("${CURRENT_HOST_INSTALLED_DIR}/share/vcpkg-cmake-config/vcpkg-port-config.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/boost-install.cmake")
5 changes: 5 additions & 0 deletions ports/vcpkg-boost/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "vcpkg-boost",
"version-date": "2024-05-15",
"license": "MIT"
}
5 changes: 2 additions & 3 deletions ports/vcpkg-cmake-config/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "vcpkg-cmake-config",
"version-date": "2022-02-06",
"port-version": 1,
"documentation": "https://vcpkg.io/en/docs/README.html",
"version-date": "2024-05-23",
"documentation": "https://learn.microsoft.com/vcpkg/maintainers/functions/vcpkg_cmake_config_fixup",
"license": "MIT"
}
42 changes: 31 additions & 11 deletions ports/vcpkg-cmake-config/vcpkg_cmake_config_fixup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -164,23 +164,24 @@ get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)]]
message(SEND_ERROR "Did not find a debug import file matching '${main_cmake}'")
else()
file(READ "${debug_cmake}" debug_contents)
while(contents MATCHES "set_target_properties\\(([^ \$]*) PROPERTIES[^)]*\\)")
set(matched_command "${CMAKE_MATCH_0}")
string(REPLACE "+" "\\+" target "${CMAKE_MATCH_1}")
if(NOT debug_contents MATCHES "set_target_properties\\(${target} PROPERTIES[^)]*\\)")
set(remainder "${contents}")
while(remainder)
z_vcpkg_cmake_config_fixup_match_command("${remainder}" "set_target_properties(" matched_command remainder)
if(NOT matched_command MATCHES "set_target_properties[(]([^ \$]*) PROPERTIES.* INTERFACE_LINK_LIBRARIES \"([^\"]*)\"")
continue()
endif()
set(target "${CMAKE_MATCH_1}")
set(release_libs "${CMAKE_MATCH_2}")
z_vcpkg_cmake_config_fixup_match_command("${debug_contents}" "set_target_properties(${target} " debug_command unused)
if(NOT debug_command MATCHES " INTERFACE_LINK_LIBRARIES \"([^\"]*)\"")
message(SEND_ERROR "Did not find a debug configuration for target '${target}'.")
continue()
endif()
set(debug_command "${CMAKE_MATCH_0}")
string(REGEX MATCH " INTERFACE_LINK_LIBRARIES \"([^\"]*)\"" release_line "${matched_command}")
set(release_libs "${CMAKE_MATCH_1}")
string(REGEX MATCH " INTERFACE_LINK_LIBRARIES \"([^\"]*)\"" debug_line "${debug_command}")
set(debug_libs "${CMAKE_MATCH_1}")
z_vcpkg_cmake_config_fixup_merge(merged_libs release_libs debug_libs)
string(REPLACE "${release_line}" " INTERFACE_LINK_LIBRARIES \"${merged_libs}\"" updated_command "${matched_command}")
string(REPLACE "set_target_properties" "set_target_properties::done" updated_command "${updated_command}") # Prevend 2nd match
string(REPLACE " INTERFACE_LINK_LIBRARIES \"${release_libs}\"" " INTERFACE_LINK_LIBRARIES \"${merged_libs}\"" updated_command "${matched_command}")
string(REPLACE "${matched_command}" "${updated_command}" contents "${contents}")
endwhile()
string(REPLACE "set_target_properties::done" "set_target_properties" contents "${contents}") # Restore original command
endif()

#Fix absolute paths to installed dir with ones relative to ${CMAKE_CURRENT_LIST_DIR}
Expand Down Expand Up @@ -224,6 +225,25 @@ get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)]]
endif()
endfunction()

# Match a command from "<needle>" to ")\n". On match, returns the command and
# the remainder from haystack. Otherwise, returns empty values.
function(z_vcpkg_cmake_config_fixup_match_command haystack needle out_match out_remainder)
set(match "")
set(remainder "")
string(FIND "${haystack}" "${needle}" first)
if(NOT first EQUAL "-1")
string(SUBSTRING "${haystack}" ${first} -1 tmp)
string(FIND "${tmp}" ")\n" bound)
if(NOT bound EQUAL "-1")
math(EXPR bound "${bound} + 2")
string(SUBSTRING "${tmp}" 0 ${bound} match)
string(SUBSTRING "${tmp}" "${bound}" -1 remainder)
endif()
endif()
set("${out_match}" "${match}" PARENT_SCOPE)
set("${out_remainder}" "${remainder}" PARENT_SCOPE)
endfunction()

# Merges link interface library lists for release and debug
# into a single expression which use generator expression as necessary.
function(z_vcpkg_cmake_config_fixup_merge out_var release_var debug_var)
Expand Down
33 changes: 30 additions & 3 deletions ports/vcpkg-cmake-get-vars/cmake_get_vars/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ set(COMPILERS ${VCPKG_LANGUAGES} RC)
foreach(prog IN LISTS COMPILERS)
list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${prog}_COMPILER)
list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${prog}_COMPILER_ID)
list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${prog}_COMPILER_VERSION)
list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${prog}_COMPILER_FRONTEND_VARIANT)
endforeach()
# Variables to check
Expand Down Expand Up @@ -158,12 +159,37 @@ if(CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN)
string(APPEND EXTRA_FLAGS " ${CMAKE_CXX_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN} \"${CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN}\"")
endif()
endif()
if(CMAKE_SYSROOT AND CMAKE_CXX_COMPILE_OPTIONS_SYSROOT)
string(APPEND EXTRA_FLAGS " \"${CMAKE_CXX_COMPILE_OPTIONS_SYSROOT}${CMAKE_SYSROOT}\"")

set(extra_flags_compile "")
set(extra_flags_link "")
if(CMAKE_CXX_COMPILE_OPTIONS_SYSROOT)
if(CMAKE_SYSROOT_COMPILE)
string(APPEND extra_flags_compile " \"${CMAKE_CXX_COMPILE_OPTIONS_SYSROOT}${CMAKE_SYSROOT_COMPILE}\"")
elseif(CMAKE_SYSROOT)
string(APPEND extra_flags_compile " \"${CMAKE_CXX_COMPILE_OPTIONS_SYSROOT}${CMAKE_SYSROOT}\"")
endif()

if(CMAKE_SYSROOT_LINK)
string(APPEND extra_flags_link " \"${CMAKE_CXX_COMPILE_OPTIONS_SYSROOT}${CMAKE_SYSROOT_LINK}\"")
elseif(CMAKE_SYSROOT)
string(APPEND extra_flags_link " \"${CMAKE_CXX_COMPILE_OPTIONS_SYSROOT}${CMAKE_SYSROOT}\"")
endif()
endif()

foreach(flags ${VCPKG_LANGUAGES} SHARED_LINKER EXE_LINKER STATIC_LINKER MODULE_LINKER)
set(flags_to_add_target_compile "${VCPKG_LANGUAGES}")
set(flags_to_add_target_link SHARED_LINKER EXE_LINKER STATIC_LINKER MODULE_LINKER)

foreach(flags IN LISTS flags_to_add_target_compile flags_to_add_target_link)
set(${flags}_FLAGS "${target_param} ${CMAKE_${flags}_FLAGS} ${CMAKE_${flags}_FLAGS_${VCPKG_CONFIGS}} ${EXTRA_FLAGS}")
endforeach()

foreach(flags IN LISTS flags_to_add_target_compile)
string(APPEND ${flags}_FLAGS " ${extra_flags_compile}")
string(STRIP ${flags}_FLAGS "${${flags}_FLAGS}")
endforeach()

foreach(flags IN LISTS flags_to_add_target_link)
string(APPEND ${flags}_FLAGS " ${extra_flags_link}")
string(STRIP ${flags}_FLAGS "${${flags}_FLAGS}")
endforeach()

Expand Down Expand Up @@ -217,6 +243,7 @@ file(WRITE "${VCPKG_OUTPUT_FILE}" "${OUTPUT_STRING}")

# Program details:
# CMAKE_<LANG>_COMPILER_ID
# CMAKE_<LANG>_COMPILER_VERSION
# MSVC
# MSVC_VERSION

Expand Down
2 changes: 1 addition & 1 deletion ports/vcpkg-cmake-get-vars/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vcpkg-cmake-get-vars",
"version-date": "2023-03-02",
"version-date": "2024-09-22",
"documentation": "https://vcpkg.io/en/docs/README.html",
"license": "MIT",
"dependencies": [
Expand Down
4 changes: 2 additions & 2 deletions ports/vcpkg-cmake/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vcpkg-cmake",
"version-date": "2023-05-04",
"documentation": "https://vcpkg.io/en/docs/maintainers/ports/vcpkg-cmake.html",
"version-date": "2024-04-23",
"documentation": "https://learn.microsoft.com/vcpkg/maintainers/functions/vcpkg_cmake_configure",
"license": "MIT"
}
31 changes: 28 additions & 3 deletions ports/vcpkg-cmake/vcpkg_cmake_configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ function(vcpkg_cmake_configure)
set(arg_LOGFILE_BASE "config-${TARGET_TRIPLET}")
endif()

set(invalid_maybe_unused_vars "${arg_MAYBE_UNUSED_VARIABLES}")
list(FILTER invalid_maybe_unused_vars INCLUDE REGEX "^-D")
if(NOT invalid_maybe_unused_vars STREQUAL "")
list(JOIN invalid_maybe_unused_vars " " bad_items)
message(${Z_VCPKG_BACKCOMPAT_MESSAGE_LEVEL}
"Option MAYBE_UNUSED_VARIABLES must be used with variables names. "
"The following items are invalid: ${bad_items}")
endif()

set(manually_specified_variables "")

if(arg_Z_CMAKE_GET_VARS_USAGE)
Expand Down Expand Up @@ -100,13 +109,21 @@ function(vcpkg_cmake_configure)
"${VCPKG_CMAKE_SYSTEM_NAME}-${VCPKG_TARGET_ARCHITECTURE}-${VCPKG_PLATFORM_TOOLSET}")
endif()

set(parallel_log_args "")
set(log_args "")

if(generator STREQUAL "Ninja")
vcpkg_find_acquire_program(NINJA)
vcpkg_list(APPEND arg_OPTIONS "-DCMAKE_MAKE_PROGRAM=${NINJA}")
# If we use Ninja, it must be on PATH for CMake's ExternalProject,
# cf. https://gitlab.kitware.com/cmake/cmake/-/issues/23355.
get_filename_component(ninja_path "${NINJA}" DIRECTORY)
vcpkg_add_to_path("${ninja_path}")
set(parallel_log_args
"../build.ninja" ALIAS "rel-ninja.log"
"../../${TARGET_TRIPLET}-dbg/build.ninja" ALIAS "dbg-ninja.log"
)
set(log_args "build.ninja")
endif()

set(build_dir_release "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel")
Expand Down Expand Up @@ -190,7 +207,6 @@ function(vcpkg_cmake_configure)
"-D_VCPKG_INSTALLED_DIR=${_VCPKG_INSTALLED_DIR}"
"-DVCPKG_MANIFEST_INSTALL=OFF"
"-DCMAKE_DEBUG_POSTFIX=d"
"-DCMAKE_POLICY_DEFAULT_CMP0056=NEW" # Honor link flags in try_compile() source-file signature (otherwise onapi toolchain fails)
)

# Sets configuration variables for macOS builds
Expand Down Expand Up @@ -258,6 +274,9 @@ function(vcpkg_cmake_configure)
SAVE_LOG_FILES
"../../${TARGET_TRIPLET}-dbg/CMakeCache.txt" ALIAS "dbg-CMakeCache.txt.log"
"../CMakeCache.txt" ALIAS "rel-CMakeCache.txt.log"
"../../${TARGET_TRIPLET}-dbg/CMakeFiles/CMakeConfigureLog.yaml" ALIAS "dbg-CMakeConfigureLog.yaml.log"
"../CMakeFiles/CMakeConfigureLog.yaml" ALIAS "rel-CMakeConfigureLog.yaml.log"
${parallel_log_args}
)

vcpkg_list(APPEND config_logs
Expand All @@ -270,7 +289,10 @@ function(vcpkg_cmake_configure)
COMMAND ${dbg_command}
WORKING_DIRECTORY "${build_dir_debug}"
LOGNAME "${arg_LOGFILE_BASE}-dbg"
SAVE_LOG_FILES CMakeCache.txt
SAVE_LOG_FILES
"CMakeCache.txt"
"CMakeFiles/CMakeConfigureLog.yaml"
${log_args}
)
vcpkg_list(APPEND config_logs
"${CURRENT_BUILDTREES_DIR}/${arg_LOGFILE_BASE}-dbg-out.log"
Expand All @@ -283,7 +305,10 @@ function(vcpkg_cmake_configure)
COMMAND ${rel_command}
WORKING_DIRECTORY "${build_dir_release}"
LOGNAME "${arg_LOGFILE_BASE}-rel"
SAVE_LOG_FILES CMakeCache.txt
SAVE_LOG_FILES
"CMakeCache.txt"
"CMakeFiles/CMakeConfigureLog.yaml"
${log_args}
)
vcpkg_list(APPEND config_logs
"${CURRENT_BUILDTREES_DIR}/${arg_LOGFILE_BASE}-rel-out.log"
Expand Down
2 changes: 1 addition & 1 deletion ports/vcpkg-get-python-packages/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vcpkg-get-python-packages",
"version-date": "2024-01-24",
"version-date": "2024-09-29",
"documentation": "https://learn.microsoft.com/en-us/vcpkg/maintainers/functions/vcpkg_get_python_packages",
"license": "MIT",
"supports": "native"
Expand Down
Loading

0 comments on commit 535b0bc

Please sign in to comment.