From 3f3413fce97e4b897808523e5367a9210ca738b3 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sun, 20 Feb 2022 23:43:05 +0100 Subject: [PATCH 01/16] [vcpkg.cmake] guard against inf recursion. --- ports/zlib/vcpkg-cmake-wrapper.cmake | 6 +- ports/zlib/vcpkg.json | 2 +- scripts/buildsystems/vcpkg.cmake | 111 ++++++++++++++++-- .../inf-recursion-test/portfile.cmake | 3 + .../inf-recursion-test/project/CMakeLists.txt | 20 ++++ .../inf-recursion-test/project/lib.cpp | 1 + .../inf-recursion-test/project/main.cpp | 5 + .../test_ports/inf-recursion-test/vcpkg.json | 12 ++ 8 files changed, 145 insertions(+), 15 deletions(-) create mode 100644 scripts/test_ports/inf-recursion-test/portfile.cmake create mode 100644 scripts/test_ports/inf-recursion-test/project/CMakeLists.txt create mode 100644 scripts/test_ports/inf-recursion-test/project/lib.cpp create mode 100644 scripts/test_ports/inf-recursion-test/project/main.cpp create mode 100644 scripts/test_ports/inf-recursion-test/vcpkg.json diff --git a/ports/zlib/vcpkg-cmake-wrapper.cmake b/ports/zlib/vcpkg-cmake-wrapper.cmake index 8624b70867e9c8..f183800cbfd08e 100644 --- a/ports/zlib/vcpkg-cmake-wrapper.cmake +++ b/ports/zlib/vcpkg-cmake-wrapper.cmake @@ -9,4 +9,8 @@ if(CMAKE_VERSION VERSION_LESS 3.4) select_library_configurations(ZLIB) unset(ZLIB_FOUND) endif() -_find_package(${ARGS}) +if(Z_VCPKG_CHAIN_COMMANDS) + cmake_language(CALL _${Z_VCPKG_FIND_PACKAGE} ${ARGS}) +else() + _find_package(${ARGS}) +endif() diff --git a/ports/zlib/vcpkg.json b/ports/zlib/vcpkg.json index 4308e45a4b8273..809902470846a2 100644 --- a/ports/zlib/vcpkg.json +++ b/ports/zlib/vcpkg.json @@ -1,7 +1,7 @@ { "name": "zlib", "version": "1.2.11", - "port-version": 13, + "port-version": 14, "description": "A compression library", "homepage": "https://www.zlib.net/" } diff --git a/scripts/buildsystems/vcpkg.cmake b/scripts/buildsystems/vcpkg.cmake index 5a475b00f9f017..26b8828b969907 100644 --- a/scripts/buildsystems/vcpkg.cmake +++ b/scripts/buildsystems/vcpkg.cmake @@ -30,6 +30,34 @@ function(z_vcpkg_add_fatal_error ERROR) endif() endfunction() +#[===[.md: +# z_vcpkg_get_command_underscores +Get the number of underscores/overrides the given `command` has. +If a `function|command` is overwritten it will be available as `_command`. +To chain these overrides it is required for the next override to override +`_command` instead `command` and so on for further overrides. This function +finds the last of the defined commands and returns the number of `_` needed +to savely chain commands + +```cmake +z_vcpkg_get_command_underscores( ) +``` + +#]===] +function(z_vcpkg_get_command_underscores command_in underscores_out) + set(_under "") + if(COMMAND _${command_in}) + z_vcpkg_get_command_underscores(_under _${command_in}) + set(_under "_${_under}") + endif() + set(${underscores_out} "${_under}" PARENT_SCOPE) +endfunction() +set(Z_VCPKG_CHAIN_COMMANDS FALSE) +if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.18") + set(Z_VCPKG_CHAIN_COMMANDS TRUE) +endif() + + set(Z_VCPKG_CMAKE_REQUIRED_MINIMUM_VERSION "3.7.2") if(CMAKE_VERSION VERSION_LESS Z_VCPKG_CMAKE_REQUIRED_MINIMUM_VERSION) message(FATAL_ERROR "vcpkg.cmake requires at least CMake ${Z_VCPKG_CMAKE_REQUIRED_MINIMUM_VERSION}.") @@ -528,10 +556,19 @@ endforeach() cmake_policy(POP) # Any policies applied to the below macros and functions appear to leak into consumers +set(Z_VCPKG_ADD_EXECUTABLE_US "") +if(Z_VCPKG_CHAIN_COMMANDS) + z_vcpkg_get_command_underscores("add_executable" Z_VCPKG_ADD_EXECUTABLE_US) +endif() +set(Z_VCPKG_ADD_EXECUTABLE "${Z_VCPKG_ADD_EXECUTABLE_US}add_executable" CACHE INTERNAL "") -function(add_executable) +function(${Z_VCPKG_ADD_EXECUTABLE}) z_vcpkg_function_arguments(ARGS) - _add_executable(${ARGS}) + if(Z_VCPKG_CHAIN_COMMANDS) + cmake_language(CALL _${Z_VCPKG_ADD_EXECUTABLE} ${ARGS}) + else() + _add_executable(${ARGS}) + endif() set(target_name "${ARGV0}") list(FIND ARGV "IMPORTED" IMPORTED_IDX) @@ -567,9 +604,19 @@ function(add_executable) endif() endfunction() -function(add_library) +set(Z_VCPKG_ADD_LIBRARY_US "") +if(Z_VCPKG_CHAIN_COMMANDS) + z_vcpkg_get_command_underscores("add_library" Z_VCPKG_ADD_LIBRARY_US) +endif() +set(Z_VCPKG_ADD_LIBRARY "${Z_VCPKG_ADD_LIBRARY_US}add_library" CACHE INTERNAL "") + +function(${Z_VCPKG_ADD_LIBRARY}) z_vcpkg_function_arguments(ARGS) - _add_library(${ARGS}) + if(Z_VCPKG_CHAIN_COMMANDS) + cmake_language(CALL _${Z_VCPKG_ADD_LIBRARY} ${ARGS}) + else() + _add_library(${ARGS}) + endif() set(target_name "${ARGV0}") list(FIND ARGS "IMPORTED" IMPORTED_IDX) @@ -647,9 +694,18 @@ function(x_vcpkg_install_local_dependencies) endfunction() if(X_VCPKG_APPLOCAL_DEPS_INSTALL) - function(install) + set(Z_VCPKG_INSTALL_US "") + if(Z_VCPKG_CHAIN_COMMANDS) + z_vcpkg_get_command_underscores("install" Z_VCPKG_INSTALL_US) + endif() + set(Z_VCPKG_INSTALL "${Z_VCPKG_INSTALL_US}install" CACHE INTERNAL "") + function(${Z_VCPKG_INSTALL}) z_vcpkg_function_arguments(ARGS) - _install(${ARGS}) + if(Z_VCPKG_CHAIN_COMMANDS) + cmake_language(CALL _${Z_VCPKG_INSTALL} ${ARGS}) + else() + _install(${ARGS}) + endif() if(ARGV0 STREQUAL "TARGETS") # Will contain the list of targets @@ -697,10 +753,15 @@ endif() if(NOT DEFINED VCPKG_OVERRIDE_FIND_PACKAGE_NAME) set(VCPKG_OVERRIDE_FIND_PACKAGE_NAME find_package) endif() +set(Z_VCPKG_FIND_PACKAGE_US "") +if(Z_VCPKG_CHAIN_COMMANDS) + z_vcpkg_get_command_underscores("${VCPKG_OVERRIDE_FIND_PACKAGE_NAME}" Z_VCPKG_FIND_PACKAGE_US) +endif() +set(Z_VCPKG_FIND_PACKAGE "${Z_VCPKG_FIND_PACKAGE_US}${VCPKG_OVERRIDE_FIND_PACKAGE_NAME}" CACHE INTERNAL "") # NOTE: this is not a function, which means that arguments _are not_ perfectly forwarded # this is fine for `find_package`, since there are no usecases for `;` in arguments, # so perfect forwarding is not important -macro("${VCPKG_OVERRIDE_FIND_PACKAGE_NAME}" z_vcpkg_find_package_package_name) +macro("${Z_VCPKG_FIND_PACKAGE}" z_vcpkg_find_package_package_name) set(z_vcpkg_find_package_package_name "${z_vcpkg_find_package_package_name}") set(z_vcpkg_find_package_ARGN "${ARGN}") set(z_vcpkg_find_package_backup_vars) @@ -747,16 +808,32 @@ macro("${VCPKG_OVERRIDE_FIND_PACKAGE_NAME}" z_vcpkg_find_package_package_name) else() set(Boost_COMPILER "-vc140") endif() - _find_package("${z_vcpkg_find_package_package_name}" ${z_vcpkg_find_package_ARGN}) + if(Z_VCPKG_CHAIN_COMMANDS) + cmake_language(CALL _${Z_VCPKG_FIND_PACKAGE} "${z_vcpkg_find_package_package_name}" ${z_vcpkg_find_package_ARGN}) + else() + _find_package("${z_vcpkg_find_package_package_name}" ${z_vcpkg_find_package_ARGN}) + endif() elseif(z_vcpkg_find_package_package_name STREQUAL "ICU" AND EXISTS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include/unicode/utf.h") list(FIND z_vcpkg_find_package_ARGN "COMPONENTS" z_vcpkg_find_package_COMPONENTS_IDX) if(NOT z_vcpkg_find_package_COMPONENTS_IDX EQUAL -1) - _find_package("${z_vcpkg_find_package_package_name}" ${z_vcpkg_find_package_ARGN} COMPONENTS data) + if(Z_VCPKG_CHAIN_COMMANDS) + cmake_language(CALL _${Z_VCPKG_FIND_PACKAGE} "${z_vcpkg_find_package_package_name}" ${z_vcpkg_find_package_ARGN} COMPONENTS data) + else() + _find_package("${z_vcpkg_find_package_package_name}" ${z_vcpkg_find_package_ARGN} COMPONENTS data) + endif() else() - _find_package("${z_vcpkg_find_package_package_name}" ${z_vcpkg_find_package_ARGN}) + if(Z_VCPKG_CHAIN_COMMANDS) + cmake_language(CALL _${Z_VCPKG_FIND_PACKAGE} "${z_vcpkg_find_package_package_name}" ${z_vcpkg_find_package_ARGN}) + else() + _find_package("${z_vcpkg_find_package_package_name}" ${z_vcpkg_find_package_ARGN}) + endif() endif() elseif(z_vcpkg_find_package_package_name STREQUAL "GSL" AND EXISTS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include/gsl") - _find_package("${z_vcpkg_find_package_package_name}" ${z_vcpkg_find_package_ARGN}) + if(Z_VCPKG_CHAIN_COMMANDS) + cmake_language(CALL _${Z_VCPKG_FIND_PACKAGE} "${z_vcpkg_find_package_package_name}" ${z_vcpkg_find_package_ARGN}) + else() + _find_package("${z_vcpkg_find_package_package_name}" ${z_vcpkg_find_package_ARGN}) + endif() if(GSL_FOUND AND TARGET GSL::gsl) set_property( TARGET GSL::gslcblas APPEND PROPERTY IMPORTED_CONFIGURATIONS Release ) set_property( TARGET GSL::gsl APPEND PROPERTY IMPORTED_CONFIGURATIONS Release ) @@ -777,9 +854,17 @@ macro("${VCPKG_OVERRIDE_FIND_PACKAGE_NAME}" z_vcpkg_find_package_package_name) endif() endif() elseif("${z_vcpkg_find_package_lowercase_package_name}" STREQUAL "grpc" AND EXISTS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/share/grpc") - _find_package(gRPC ${z_vcpkg_find_package_ARGN}) + if(Z_VCPKG_CHAIN_COMMANDS) + cmake_language(CALL _${Z_VCPKG_FIND_PACKAGE} gRPC ${z_vcpkg_find_package_ARGN}) + else() + _find_package(gRPC ${z_vcpkg_find_package_ARGN}) + endif() else() - _find_package("${z_vcpkg_find_package_package_name}" ${z_vcpkg_find_package_ARGN}) + if(Z_VCPKG_CHAIN_COMMANDS) + cmake_language(CALL _${Z_VCPKG_FIND_PACKAGE} "${z_vcpkg_find_package_package_name}" ${z_vcpkg_find_package_ARGN}) + else() + _find_package("${z_vcpkg_find_package_package_name}" ${z_vcpkg_find_package_ARGN}) + endif() endif() foreach(z_vcpkg_find_package_backup_var IN LISTS z_vcpkg_find_package_backup_vars) diff --git a/scripts/test_ports/inf-recursion-test/portfile.cmake b/scripts/test_ports/inf-recursion-test/portfile.cmake new file mode 100644 index 00000000000000..85f23307f70cb9 --- /dev/null +++ b/scripts/test_ports/inf-recursion-test/portfile.cmake @@ -0,0 +1,3 @@ +set(VCPKG_POLICY_EMPTY_PACKAGE enabled) + +vcpkg_cmake_configure(SOURCE_PATH "${CURRENT_PORT_DIR}/project") diff --git a/scripts/test_ports/inf-recursion-test/project/CMakeLists.txt b/scripts/test_ports/inf-recursion-test/project/CMakeLists.txt new file mode 100644 index 00000000000000..cc506a0ff6d4ce --- /dev/null +++ b/scripts/test_ports/inf-recursion-test/project/CMakeLists.txt @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 3.18) + +# vcpkg can only guard against overrides before the first project() call! +macro(find_package) + _find_package(${ARGV}) +endmacro() + +function(add_library) + _add_library(${ARGV}) +endfunction() + +function(add_executable) + _add_executable(${ARGV}) +endfunction() + +project(inf-recursion-test) + +find_package(ZLIB REQUIRED) +add_library(mylib lib.cpp) +add_executable(myexe main.cpp) \ No newline at end of file diff --git a/scripts/test_ports/inf-recursion-test/project/lib.cpp b/scripts/test_ports/inf-recursion-test/project/lib.cpp new file mode 100644 index 00000000000000..612bb08df6149e --- /dev/null +++ b/scripts/test_ports/inf-recursion-test/project/lib.cpp @@ -0,0 +1 @@ +struct MyClass {}; diff --git a/scripts/test_ports/inf-recursion-test/project/main.cpp b/scripts/test_ports/inf-recursion-test/project/main.cpp new file mode 100644 index 00000000000000..790037a88d2efb --- /dev/null +++ b/scripts/test_ports/inf-recursion-test/project/main.cpp @@ -0,0 +1,5 @@ +#include +int main() { + std::puts("Hello World!"); + return 0; +} \ No newline at end of file diff --git a/scripts/test_ports/inf-recursion-test/vcpkg.json b/scripts/test_ports/inf-recursion-test/vcpkg.json new file mode 100644 index 00000000000000..87ab11c570c28a --- /dev/null +++ b/scripts/test_ports/inf-recursion-test/vcpkg.json @@ -0,0 +1,12 @@ +{ + "name": "inf-recursion-test", + "version-date": "2022-02-20", + "description": "Test port to verify if vcpkg.cmake is robust against command recursions", + "dependencies" : [ + { + "name": "vcpkg-cmake", + "host": true + }, + "zlib" + ] +} From 46b670fa386b1bec988df3f592fa75f102701f07 Mon Sep 17 00:00:00 2001 From: Alexander Neumann <30894796+Neumann-A@users.noreply.github.com> Date: Mon, 21 Feb 2022 07:49:19 +0100 Subject: [PATCH 02/16] Add license Co-authored-by: autoantwort <41973254+autoantwort@users.noreply.github.com> --- ports/zlib/vcpkg.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ports/zlib/vcpkg.json b/ports/zlib/vcpkg.json index 809902470846a2..28c9fdb5b17793 100644 --- a/ports/zlib/vcpkg.json +++ b/ports/zlib/vcpkg.json @@ -3,5 +3,6 @@ "version": "1.2.11", "port-version": 14, "description": "A compression library", - "homepage": "https://www.zlib.net/" + "homepage": "https://www.zlib.net/", + "license": "Zlib" } From 8c29e00bb15f2cc8cf3eb7e9e969d23251283ba2 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Mon, 21 Feb 2022 21:47:37 +0100 Subject: [PATCH 03/16] version update --- versions/baseline.json | 2 +- versions/z-/zlib.json | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/versions/baseline.json b/versions/baseline.json index 6b3147e52ca18c..165fa5e9fc3459 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -7542,7 +7542,7 @@ }, "zlib": { "baseline": "1.2.11", - "port-version": 13 + "port-version": 14 }, "zlib-ng": { "baseline": "2.0.5", diff --git a/versions/z-/zlib.json b/versions/z-/zlib.json index 7c0d68f33de55e..f0f409f8b8fbf6 100644 --- a/versions/z-/zlib.json +++ b/versions/z-/zlib.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "27564e1e248f9c40b856871f6b112eb4c4971dc1", + "version": "1.2.11", + "port-version": 14 + }, { "git-tree": "92cfe30c807d343c6359d272242f0765ad906740", "version": "1.2.11", From 9a96d8daaf9a876efa0bed6e656d45adebae7161 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Mon, 21 Feb 2022 22:09:06 +0100 Subject: [PATCH 04/16] add license --- scripts/test_ports/inf-recursion-test/vcpkg.json | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/test_ports/inf-recursion-test/vcpkg.json b/scripts/test_ports/inf-recursion-test/vcpkg.json index 87ab11c570c28a..06f5021bb67b68 100644 --- a/scripts/test_ports/inf-recursion-test/vcpkg.json +++ b/scripts/test_ports/inf-recursion-test/vcpkg.json @@ -2,6 +2,7 @@ "name": "inf-recursion-test", "version-date": "2022-02-20", "description": "Test port to verify if vcpkg.cmake is robust against command recursions", + "license" : "MIT", "dependencies" : [ { "name": "vcpkg-cmake", From 8592b5674a4b9eb953cbb7598750897fc8289871 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Wed, 30 Mar 2022 21:19:37 +0200 Subject: [PATCH 05/16] apply cr --- scripts/buildsystems/vcpkg.cmake | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/scripts/buildsystems/vcpkg.cmake b/scripts/buildsystems/vcpkg.cmake index 9c219cc6ff11a8..da410b76cd22bd 100644 --- a/scripts/buildsystems/vcpkg.cmake +++ b/scripts/buildsystems/vcpkg.cmake @@ -46,13 +46,12 @@ z_vcpkg_get_command_underscores( ) ``` #]===] -function(z_vcpkg_get_command_underscores command_in underscores_out) - set(_under "") - if(COMMAND _${command_in}) - z_vcpkg_get_command_underscores(_under _${command_in}) - set(_under "_${_under}") - endif() - set(${underscores_out} "${_under}" PARENT_SCOPE) +function(z_vcpkg_get_command_underscores command underscores_out) + set(underscores "") + while(COMMAND "_${underscores}${command}") + set(underscores "_${underscores}") + endwhile() + set("${underscores_out}" "${underscores}" PARENT_SCOPE) endfunction() set(Z_VCPKG_CHAIN_COMMANDS FALSE) if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.18") From 3a8cc5d0434a97354ddc1cc8d62a6dbbb1044a26 Mon Sep 17 00:00:00 2001 From: Alexander Neumann <30894796+Neumann-A@users.noreply.github.com> Date: Thu, 31 Mar 2022 21:23:43 +0200 Subject: [PATCH 06/16] ON/OFF instead of TRUE/FALSE Co-authored-by: nicole mazzuca <83086508+strega-nil-ms@users.noreply.github.com> --- scripts/buildsystems/vcpkg.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/buildsystems/vcpkg.cmake b/scripts/buildsystems/vcpkg.cmake index da410b76cd22bd..bb352e5e5f7cd2 100644 --- a/scripts/buildsystems/vcpkg.cmake +++ b/scripts/buildsystems/vcpkg.cmake @@ -53,9 +53,9 @@ function(z_vcpkg_get_command_underscores command underscores_out) endwhile() set("${underscores_out}" "${underscores}" PARENT_SCOPE) endfunction() -set(Z_VCPKG_CHAIN_COMMANDS FALSE) +set(Z_VCPKG_CHAIN_COMMANDS OFF) if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.18") - set(Z_VCPKG_CHAIN_COMMANDS TRUE) + set(Z_VCPKG_CHAIN_COMMANDS ON) endif() From 0307935cab521048a5a34c17b6b84e9b383a4ae6 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Thu, 31 Mar 2022 21:31:52 +0200 Subject: [PATCH 07/16] Apply CR suggestion. --- ports/zlib/vcpkg-cmake-wrapper.cmake | 7 ++----- ports/zlib/vcpkg.json | 4 +++- scripts/buildsystems/vcpkg.cmake | 10 ++++++++++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/ports/zlib/vcpkg-cmake-wrapper.cmake b/ports/zlib/vcpkg-cmake-wrapper.cmake index f183800cbfd08e..87fd81b1d4f463 100644 --- a/ports/zlib/vcpkg-cmake-wrapper.cmake +++ b/ports/zlib/vcpkg-cmake-wrapper.cmake @@ -9,8 +9,5 @@ if(CMAKE_VERSION VERSION_LESS 3.4) select_library_configurations(ZLIB) unset(ZLIB_FOUND) endif() -if(Z_VCPKG_CHAIN_COMMANDS) - cmake_language(CALL _${Z_VCPKG_FIND_PACKAGE} ${ARGS}) -else() - _find_package(${ARGS}) -endif() + +z_vcpkg_underlying_find_package(${ARGS}) diff --git a/ports/zlib/vcpkg.json b/ports/zlib/vcpkg.json index d147fad30bfc28..e5a1574ed0b973 100644 --- a/ports/zlib/vcpkg.json +++ b/ports/zlib/vcpkg.json @@ -1,6 +1,8 @@ { "name": "zlib", "version": "1.2.12", + "port-version": 1, "description": "A compression library", - "homepage": "https://www.zlib.net/" + "homepage": "https://www.zlib.net/", + "license" : "Zlib" } diff --git a/scripts/buildsystems/vcpkg.cmake b/scripts/buildsystems/vcpkg.cmake index bb352e5e5f7cd2..37c621fac6f76a 100644 --- a/scripts/buildsystems/vcpkg.cmake +++ b/scripts/buildsystems/vcpkg.cmake @@ -791,6 +791,16 @@ if(Z_VCPKG_CHAIN_COMMANDS) z_vcpkg_get_command_underscores("${VCPKG_OVERRIDE_FIND_PACKAGE_NAME}" Z_VCPKG_FIND_PACKAGE_US) endif() set(Z_VCPKG_FIND_PACKAGE "${Z_VCPKG_FIND_PACKAGE_US}${VCPKG_OVERRIDE_FIND_PACKAGE_NAME}" CACHE INTERNAL "") + +# Helper to be used in vcpkg-cmake-wrapper.cmake instead of _find_package +# needs to be a macro for the same reasons as below +macro(z_vcpkg_underlying_find_package) + if(Z_VCPKG_CHAIN_COMMANDS) + cmake_language(CALL _${Z_VCPKG_FIND_PACKAGE} ${ARGS}) + else() + _find_package(${ARGS}) + endif() +endmacro() # NOTE: this is not a function, which means that arguments _are not_ perfectly forwarded # this is fine for `find_package`, since there are no usecases for `;` in arguments, # so perfect forwarding is not important From 37f95bfcd9a2b8a80291c311a97742d57970d828 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Thu, 31 Mar 2022 21:38:53 +0200 Subject: [PATCH 08/16] actually use the macro in vcpkg.cmake --- scripts/buildsystems/vcpkg.cmake | 40 +++++++------------------------- 1 file changed, 8 insertions(+), 32 deletions(-) diff --git a/scripts/buildsystems/vcpkg.cmake b/scripts/buildsystems/vcpkg.cmake index 37c621fac6f76a..61c56a3c450bd0 100644 --- a/scripts/buildsystems/vcpkg.cmake +++ b/scripts/buildsystems/vcpkg.cmake @@ -793,7 +793,6 @@ endif() set(Z_VCPKG_FIND_PACKAGE "${Z_VCPKG_FIND_PACKAGE_US}${VCPKG_OVERRIDE_FIND_PACKAGE_NAME}" CACHE INTERNAL "") # Helper to be used in vcpkg-cmake-wrapper.cmake instead of _find_package -# needs to be a macro for the same reasons as below macro(z_vcpkg_underlying_find_package) if(Z_VCPKG_CHAIN_COMMANDS) cmake_language(CALL _${Z_VCPKG_FIND_PACKAGE} ${ARGS}) @@ -801,6 +800,7 @@ macro(z_vcpkg_underlying_find_package) _find_package(${ARGS}) endif() endmacro() + # NOTE: this is not a function, which means that arguments _are not_ perfectly forwarded # this is fine for `find_package`, since there are no usecases for `;` in arguments, # so perfect forwarding is not important @@ -851,32 +851,16 @@ macro("${Z_VCPKG_FIND_PACKAGE}" z_vcpkg_find_package_package_name) else() set(Boost_COMPILER "-vc140") endif() - if(Z_VCPKG_CHAIN_COMMANDS) - cmake_language(CALL _${Z_VCPKG_FIND_PACKAGE} "${z_vcpkg_find_package_package_name}" ${z_vcpkg_find_package_ARGN}) - else() - _find_package("${z_vcpkg_find_package_package_name}" ${z_vcpkg_find_package_ARGN}) - endif() + z_vcpkg_underlying_find_package("${z_vcpkg_find_package_package_name}" ${z_vcpkg_find_package_ARGN}) elseif(z_vcpkg_find_package_package_name STREQUAL "ICU" AND EXISTS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include/unicode/utf.h") list(FIND z_vcpkg_find_package_ARGN "COMPONENTS" z_vcpkg_find_package_COMPONENTS_IDX) if(NOT z_vcpkg_find_package_COMPONENTS_IDX EQUAL -1) - if(Z_VCPKG_CHAIN_COMMANDS) - cmake_language(CALL _${Z_VCPKG_FIND_PACKAGE} "${z_vcpkg_find_package_package_name}" ${z_vcpkg_find_package_ARGN} COMPONENTS data) - else() - _find_package("${z_vcpkg_find_package_package_name}" ${z_vcpkg_find_package_ARGN} COMPONENTS data) - endif() + z_vcpkg_underlying_find_package("${z_vcpkg_find_package_package_name}" ${z_vcpkg_find_package_ARGN} COMPONENTS data) else() - if(Z_VCPKG_CHAIN_COMMANDS) - cmake_language(CALL _${Z_VCPKG_FIND_PACKAGE} "${z_vcpkg_find_package_package_name}" ${z_vcpkg_find_package_ARGN}) - else() - _find_package("${z_vcpkg_find_package_package_name}" ${z_vcpkg_find_package_ARGN}) - endif() + z_vcpkg_underlying_find_package("${z_vcpkg_find_package_package_name}" ${z_vcpkg_find_package_ARGN}) endif() elseif(z_vcpkg_find_package_package_name STREQUAL "GSL" AND EXISTS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include/gsl") - if(Z_VCPKG_CHAIN_COMMANDS) - cmake_language(CALL _${Z_VCPKG_FIND_PACKAGE} "${z_vcpkg_find_package_package_name}" ${z_vcpkg_find_package_ARGN}) - else() - _find_package("${z_vcpkg_find_package_package_name}" ${z_vcpkg_find_package_ARGN}) - endif() + z_vcpkg_underlying_find_package("${z_vcpkg_find_package_package_name}" ${z_vcpkg_find_package_ARGN}) if(GSL_FOUND AND TARGET GSL::gsl) set_property( TARGET GSL::gslcblas APPEND PROPERTY IMPORTED_CONFIGURATIONS Release ) set_property( TARGET GSL::gsl APPEND PROPERTY IMPORTED_CONFIGURATIONS Release ) @@ -888,7 +872,7 @@ macro("${Z_VCPKG_FIND_PACKAGE}" z_vcpkg_find_package_package_name) endif() endif() elseif("${z_vcpkg_find_package_package_name}" STREQUAL "CURL" AND EXISTS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include/curl") - _find_package("${z_vcpkg_find_package_package_name}" ${z_vcpkg_find_package_ARGN}) + z_vcpkg_underlying_find_package("${z_vcpkg_find_package_package_name}" ${z_vcpkg_find_package_ARGN}) if(CURL_FOUND) if(EXISTS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/nghttp2.lib") list(APPEND CURL_LIBRARIES @@ -897,17 +881,9 @@ macro("${Z_VCPKG_FIND_PACKAGE}" z_vcpkg_find_package_package_name) endif() endif() elseif("${z_vcpkg_find_package_lowercase_package_name}" STREQUAL "grpc" AND EXISTS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/share/grpc") - if(Z_VCPKG_CHAIN_COMMANDS) - cmake_language(CALL _${Z_VCPKG_FIND_PACKAGE} gRPC ${z_vcpkg_find_package_ARGN}) - else() - _find_package(gRPC ${z_vcpkg_find_package_ARGN}) - endif() + z_vcpkg_underlying_find_package(gRPC ${z_vcpkg_find_package_ARGN}) else() - if(Z_VCPKG_CHAIN_COMMANDS) - cmake_language(CALL _${Z_VCPKG_FIND_PACKAGE} "${z_vcpkg_find_package_package_name}" ${z_vcpkg_find_package_ARGN}) - else() - _find_package("${z_vcpkg_find_package_package_name}" ${z_vcpkg_find_package_ARGN}) - endif() + z_vcpkg_underlying_find_package("${z_vcpkg_find_package_package_name}" ${z_vcpkg_find_package_ARGN}) endif() foreach(z_vcpkg_find_package_backup_var IN LISTS z_vcpkg_find_package_backup_vars) From ffb76527652829c7f7c90be851d12d9b59b6fb07 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Thu, 31 Mar 2022 21:56:52 +0200 Subject: [PATCH 09/16] format manifest --- ports/zlib/vcpkg.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/zlib/vcpkg.json b/ports/zlib/vcpkg.json index e5a1574ed0b973..bee43d26a19e6b 100644 --- a/ports/zlib/vcpkg.json +++ b/ports/zlib/vcpkg.json @@ -4,5 +4,5 @@ "port-version": 1, "description": "A compression library", "homepage": "https://www.zlib.net/", - "license" : "Zlib" + "license": "Zlib" } From ca9671cbb85a11d99bb41c7942d88b0a2ad78bd1 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Thu, 31 Mar 2022 21:57:21 +0200 Subject: [PATCH 10/16] version stuff --- versions/baseline.json | 2 +- versions/z-/zlib.json | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/versions/baseline.json b/versions/baseline.json index a095414ad645f7..f01111a72b25d5 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -7630,7 +7630,7 @@ }, "zlib": { "baseline": "1.2.12", - "port-version": 0 + "port-version": 1 }, "zlib-ng": { "baseline": "2.0.5", diff --git a/versions/z-/zlib.json b/versions/z-/zlib.json index b7830cc6d249e0..e884bc55e7fd59 100644 --- a/versions/z-/zlib.json +++ b/versions/z-/zlib.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "8ae60d9b19188369614811dbd5a19d6994055e0f", + "version": "1.2.12", + "port-version": 1 + }, { "git-tree": "9c4edb1fabbd87dd236a200ba55eaf241cd8c8d0", "version": "1.2.12", From 6c744efac083a1819cd222ad8ad46faf77b4488b Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Thu, 31 Mar 2022 23:31:23 +0200 Subject: [PATCH 11/16] use ARGN instead of ARGS since it is in the macro and not in the wrapper --- scripts/buildsystems/vcpkg.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/buildsystems/vcpkg.cmake b/scripts/buildsystems/vcpkg.cmake index 61c56a3c450bd0..ed97f1f8fd86dc 100644 --- a/scripts/buildsystems/vcpkg.cmake +++ b/scripts/buildsystems/vcpkg.cmake @@ -795,9 +795,9 @@ set(Z_VCPKG_FIND_PACKAGE "${Z_VCPKG_FIND_PACKAGE_US}${VCPKG_OVERRIDE_FIND_PACKAG # Helper to be used in vcpkg-cmake-wrapper.cmake instead of _find_package macro(z_vcpkg_underlying_find_package) if(Z_VCPKG_CHAIN_COMMANDS) - cmake_language(CALL _${Z_VCPKG_FIND_PACKAGE} ${ARGS}) + cmake_language(CALL _${Z_VCPKG_FIND_PACKAGE} "${ARGN}") else() - _find_package(${ARGS}) + _find_package("${ARGN}") endif() endmacro() From 3aa35476fbdf673f279b0a4b08f8215a805e31ee Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Thu, 31 Mar 2022 23:56:28 +0200 Subject: [PATCH 12/16] use the same ARGN approach as the find_package override --- scripts/buildsystems/vcpkg.cmake | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/buildsystems/vcpkg.cmake b/scripts/buildsystems/vcpkg.cmake index ed97f1f8fd86dc..c38b5c9d56d887 100644 --- a/scripts/buildsystems/vcpkg.cmake +++ b/scripts/buildsystems/vcpkg.cmake @@ -793,11 +793,12 @@ endif() set(Z_VCPKG_FIND_PACKAGE "${Z_VCPKG_FIND_PACKAGE_US}${VCPKG_OVERRIDE_FIND_PACKAGE_NAME}" CACHE INTERNAL "") # Helper to be used in vcpkg-cmake-wrapper.cmake instead of _find_package -macro(z_vcpkg_underlying_find_package) +macro(z_vcpkg_underlying_find_package z_vcpkg_underlying_find_package_name) + set(z_vcpkg_underlying_find_package_name_ARGN "${ARGN}") if(Z_VCPKG_CHAIN_COMMANDS) - cmake_language(CALL _${Z_VCPKG_FIND_PACKAGE} "${ARGN}") + cmake_language(CALL _${Z_VCPKG_FIND_PACKAGE} "${z_vcpkg_underlying_find_package_name}" ${z_vcpkg_underlying_find_package_name_ARGN}) else() - _find_package("${ARGN}") + _find_package("${z_vcpkg_underlying_find_package_name}" ${z_vcpkg_underlying_find_package_name_ARGN}) endif() endmacro() From 86baf12be10f8f3f87122c5e7cc1e15e707044d9 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Wed, 4 May 2022 16:47:10 +0200 Subject: [PATCH 13/16] get error from protoc on linux --- ports/protobuf/portfile.cmake | 1 + ports/protobuf/protoc.patch | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 ports/protobuf/protoc.patch diff --git a/ports/protobuf/portfile.cmake b/ports/protobuf/portfile.cmake index 205cf7cd74353f..f8e5cdba9b2ae3 100644 --- a/ports/protobuf/portfile.cmake +++ b/ports/protobuf/portfile.cmake @@ -7,6 +7,7 @@ vcpkg_from_github( PATCHES fix-static-build.patch fix-default-proto-file-path.patch + protoc.patch ) string(COMPARE EQUAL "${TARGET_TRIPLET}" "${HOST_TRIPLET}" protobuf_BUILD_PROTOC_BINARIES) diff --git a/ports/protobuf/protoc.patch b/ports/protobuf/protoc.patch new file mode 100644 index 00000000000000..eed0a2b9d1108b --- /dev/null +++ b/ports/protobuf/protoc.patch @@ -0,0 +1,20 @@ +diff --git a/src/google/protobuf/compiler/main.cc b/src/google/protobuf/compiler/main.cc +index 7cb7a6375..e2716fd18 100644 +--- a/src/google/protobuf/compiler/main.cc ++++ b/src/google/protobuf/compiler/main.cc +@@ -108,6 +108,14 @@ int ProtobufMain(int argc, char* argv[]) { + } // namespace protobuf + } // namespace google + ++#include ++ + int main(int argc, char* argv[]) { +- return PROTOBUF_NAMESPACE_ID::compiler::ProtobufMain(argc, argv); ++ try { ++ return PROTOBUF_NAMESPACE_ID::compiler::ProtobufMain(argc, argv); ++ } catch (std::exception &e ) ++ { ++ std::puts(e.what()); ++ return -1; ++ } + } From 70b01d45459c50b9e261308f2d182ff03135650f Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Wed, 4 May 2022 17:49:36 +0200 Subject: [PATCH 14/16] fix build error in protobuf with patch --- ports/protobuf/protoc.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/protobuf/protoc.patch b/ports/protobuf/protoc.patch index eed0a2b9d1108b..02a436bc909daf 100644 --- a/ports/protobuf/protoc.patch +++ b/ports/protobuf/protoc.patch @@ -6,7 +6,7 @@ index 7cb7a6375..e2716fd18 100644 } // namespace protobuf } // namespace google -+#include ++#include + int main(int argc, char* argv[]) { - return PROTOBUF_NAMESPACE_ID::compiler::ProtobufMain(argc, argv); From d53fc73adae413443c7203445623bd81b202b27f Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Wed, 4 May 2022 23:43:22 +0200 Subject: [PATCH 15/16] revert protoc.patch --- ports/protobuf/portfile.cmake | 1 - ports/protobuf/protoc.patch | 20 -------------------- 2 files changed, 21 deletions(-) delete mode 100644 ports/protobuf/protoc.patch diff --git a/ports/protobuf/portfile.cmake b/ports/protobuf/portfile.cmake index f8e5cdba9b2ae3..205cf7cd74353f 100644 --- a/ports/protobuf/portfile.cmake +++ b/ports/protobuf/portfile.cmake @@ -7,7 +7,6 @@ vcpkg_from_github( PATCHES fix-static-build.patch fix-default-proto-file-path.patch - protoc.patch ) string(COMPARE EQUAL "${TARGET_TRIPLET}" "${HOST_TRIPLET}" protobuf_BUILD_PROTOC_BINARIES) diff --git a/ports/protobuf/protoc.patch b/ports/protobuf/protoc.patch deleted file mode 100644 index 02a436bc909daf..00000000000000 --- a/ports/protobuf/protoc.patch +++ /dev/null @@ -1,20 +0,0 @@ -diff --git a/src/google/protobuf/compiler/main.cc b/src/google/protobuf/compiler/main.cc -index 7cb7a6375..e2716fd18 100644 ---- a/src/google/protobuf/compiler/main.cc -+++ b/src/google/protobuf/compiler/main.cc -@@ -108,6 +108,14 @@ int ProtobufMain(int argc, char* argv[]) { - } // namespace protobuf - } // namespace google - -+#include -+ - int main(int argc, char* argv[]) { -- return PROTOBUF_NAMESPACE_ID::compiler::ProtobufMain(argc, argv); -+ try { -+ return PROTOBUF_NAMESPACE_ID::compiler::ProtobufMain(argc, argv); -+ } catch (std::exception &e ) -+ { -+ std::puts(e.what()); -+ return -1; -+ } - } From 3ed937b8933c4a847a72acc2a330f3b31f616bfe Mon Sep 17 00:00:00 2001 From: Neumann-A <30894796+Neumann-A@users.noreply.github.com> Date: Thu, 12 May 2022 10:30:12 +0200 Subject: [PATCH 16/16] version stuff --- versions/baseline.json | 2 +- versions/z-/zlib.json | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/versions/baseline.json b/versions/baseline.json index 37dfe4cff9c2fc..36b1685290a104 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -7722,7 +7722,7 @@ }, "zlib": { "baseline": "1.2.12", - "port-version": 1 + "port-version": 2 }, "zlib-ng": { "baseline": "2.0.6", diff --git a/versions/z-/zlib.json b/versions/z-/zlib.json index 523f7374adddea..45cd6b8bbc4484 100644 --- a/versions/z-/zlib.json +++ b/versions/z-/zlib.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "7630389396c4879c5ba48fde6b4844d6d2725279", + "version": "1.2.12", + "port-version": 2 + }, { "git-tree": "ecc4c064d4911faf12d8bf5fd6bcd5c556d89774", "version": "1.2.12",