@@ -166,112 +166,6 @@ macro(z_vcpkg_function_arguments OUT_VAR)
166166 endif ()
167167endmacro ()
168168
169- #[===[ .md:
170- # z_vcpkg_*_parent_scope_export
171- If you need to re-export variables to a parent scope from a call,
172- you can put these around the call to re-export those variables that have changed locally
173- to parent scope.
174-
175- ## Usage:
176- ```cmake
177- z_vcpkg_start_parent_scope_export(
178- [PREFIX <PREFIX>]
179- )
180- z_vcpkg_complete_parent_scope_export(
181- [PREFIX <PREFIX>]
182- [IGNORE_REGEX <REGEX>]
183- )
184- ```
185-
186- ## Parameters
187- ### PREFIX
188- The prefix to use to store the old variable values; defaults to `Z_VCPKG_PARENT_SCOPE_EXPORT`.
189- The value of each variable `<VAR>` will be stored in `${PREFIX}_<VAR>` by `start`,
190- and then every variable which is different from `${PREFIX}_VAR` will be re-exported by `complete`.
191-
192- ### IGNORE_REGEX
193- Variables with names matching this regex will not be exported even if their value has changed.
194-
195- ## Example:
196- ```cmake
197- z_vcpkg_start_parent_scope_export()
198- _find_package(blah)
199- z_vcpkg_complete_parent_scope_export()
200- ```
201- #]===]
202- # Notes: these do not use `cmake_parse_arguments` in order to support older versions of cmake,
203- # pre-3.7 and PARSE_ARGV
204- macro (z_vcpkg_start_parent_scope_export )
205- if ("${ARGC} " EQUAL "0" )
206- set (z_vcpkg_parent_scope_export_PREFIX "Z_VCPKG_PARENT_SCOPE_EXPORT" )
207- elseif ("${ARGC} " EQUAL "2" AND "${ARGV0} " STREQUAL "PREFIX" )
208- set (z_vcpkg_parent_scope_export_PREFIX "${ARGV1} " )
209- else ()
210- message (FATAL_ERROR "Invalid parameters to z_vcpkg_start_parent_scope_export: (${ARGV} )" )
211- endif ()
212- get_property (z_vcpkg_parent_scope_export_VARIABLE_LIST
213- DIRECTORY PROPERTY "VARIABLES" )
214- foreach (z_vcpkg_parent_scope_export_VARIABLE IN LISTS z_vcpkg_parent_scope_export_VARIABLE_LIST)
215- set ("${z_vcpkg_parent_scope_export_PREFIX} _${z_vcpkg_parent_scope_export_VARIABLE} " "${${z_vcpkg_parent_scope_export_VARIABLE} }" )
216- endforeach ()
217- endmacro ()
218-
219- macro (z_vcpkg_complete_parent_scope_export )
220- set (z_vcpkg_parent_scope_export_PREFIX_FILLED OFF )
221- if ("${ARGC} " EQUAL "0" )
222- # do nothing, replace with default values
223- elseif ("${ARGC} " EQUAL "2" )
224- if ("${ARGV0} " STREQUAL "PREFIX" )
225- set (z_vcpkg_parent_scope_export_PREFIX_FILLED ON )
226- set (z_vcpkg_parent_scope_export_PREFIX "${ARGV1} " )
227- elseif ("${ARGV0} " STREQUAL "IGNORE_REGEX" )
228- set (z_vcpkg_parent_scope_export_IGNORE_REGEX "${ARGV1} " )
229- else ()
230- message (FATAL_ERROR "Invalid arguments to z_vcpkg_complete_parent_scope_export: (${ARGV} )" )
231- endif ()
232- elseif ("${ARGC} " EQUAL "4" )
233- if ("${ARGV0} " STREQUAL "PREFIX" AND "${ARGV2} " STREQUAL "IGNORE_REGEX" )
234- set (z_vcpkg_parent_scope_export_PREFIX_FILLED ON )
235- set (z_vcpkg_parent_scope_export_PREFIX "${ARGV1} " )
236- set (z_vcpkg_parent_scope_export_IGNORE_REGEX "${ARGV3} " )
237- elseif ("${ARGV0} " STREQUAL "IGNORE_REGEX" AND "${ARGV2} " STREQUAL "PREFIX" )
238- set (z_vcpkg_parent_scope_export_IGNORE_REGEX "${ARGV1} " )
239- set (z_vcpkg_parent_scope_export_PREFIX_FILLED ON )
240- set (z_vcpkg_parent_scope_export_PREFIX "${ARGV3} " )
241- else ()
242- message (FATAL_ERROR "Invalid arguments to z_vcpkg_start_parent_scope_export: (${ARGV} )" )
243- endif ()
244- else ()
245- message (FATAL_ERROR "Invalid arguments to z_vcpkg_complete_parent_scope_export: (${ARGV} )" )
246- endif ()
247-
248- if (NOT z_vcpkg_parent_scope_export_PREFIX)
249- set (z_vcpkg_parent_scope_export_PREFIX "Z_VCPKG_PARENT_SCOPE_EXPORT" )
250- endif ()
251-
252- get_property (z_vcpkg_parent_scope_export_VARIABLE_LIST
253- DIRECTORY PROPERTY "VARIABLES" )
254- foreach (z_vcpkg_parent_scope_export_VARIABLE IN LISTS z_vcpkg_parent_scope_export_VARIABLE_LIST)
255- if ("${z_vcpkg_parent_scope_export_VARIABLE} " MATCHES "^${z_vcpkg_parent_scope_export_PREFIX} _" )
256- # skip the backup variables
257- continue ()
258- endif ()
259- if ("${z_vcpkg_parent_scope_export_VARIABLE} " MATCHES "^${z_vcpkg_parent_scope_export_PREFIX} _" )
260- # skip the backup variables
261- continue ()
262- endif ()
263-
264- if (DEFINED "${z_vcpkg_parent_scope_export_IGNORE_REGEX} " AND "${z_vcpkg_parent_scope_export_VARIABLE} " MATCHES "${z_vcpkg_parent_scope_export_IGNORE_REGEX} " )
265- # skip those variables which should be ignored
266- continue ()
267- endif ()
268-
269- if (NOT "${${z_vcpkg_parent_scope_export_PREFIX} _${z_vcpkg_parent_scope_export_VARIABLE} }" STREQUAL "${${z_vcpkg_parent_scope_export_VARIABLE} }" )
270- set ("${z_vcpkg_parent_scope_export_VARIABLE} " "${${z_vcpkg_parent_scope_export_VARIABLE} }" PARENT_SCOPE )
271- endif ()
272- endforeach ()
273- endmacro ()
274-
275169#[===[ .md:
276170# z_vcpkg_set_powershell_path
277171
@@ -419,7 +313,7 @@ else()
419313 set (Z_VCPKG_TARGET_TRIPLET_ARCH ppc64le)
420314 elseif (CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "armv7l" )
421315 set (Z_VCPKG_TARGET_TRIPLET_ARCH arm)
422- elseif (CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL " aarch64" )
316+ elseif (CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "^( aarch64|arm64)$ " )
423317 set (Z_VCPKG_TARGET_TRIPLET_ARCH arm64)
424318 else ()
425319 if (Z_VCPKG_CMAKE_IN_TRY_COMPILE)
@@ -793,48 +687,49 @@ endif()
793687if (NOT DEFINED VCPKG_OVERRIDE_FIND_PACKAGE_NAME)
794688 set (VCPKG_OVERRIDE_FIND_PACKAGE_NAME find_package)
795689endif ()
796- function ("${VCPKG_OVERRIDE_FIND_PACKAGE_NAME} " )
690+ function ("${VCPKG_OVERRIDE_FIND_PACKAGE_NAME} " z_vcpkg_fp_package_name )
691+ # these variables, as well as any variables matching `z_vcpkg_fp_*`,
692+ # are not reexported to parent scope
693+ set (z_vcpkg_fp_ignored_variables
694+ "^(ARGS|z_vcpkg_fp_.*|CMAKE_FIND_ROOT_PATH|Boost_USE_STATIC_LIBS|Boost_USE_MULTITHREADED|Boost_USE_STATIC_RUNTIME|Boost_NO_BOOST_CMAKE|Boost_COMPILER)$" )
695+
797696 # Workaround to set the ROOT_PATH until upstream CMake stops overriding
798697 # the ROOT_PATH at apple OS initialization phase.
799698 # See https://gitlab.kitware.com/cmake/cmake/merge_requests/3273
699+ # Fixed in CMake 3.15
800700 if (CMAKE_SYSTEM_NAME STREQUAL iOS )
801- # this is not a mutating operation,
802- # this just creates a new variable named CMAKE_FIND_ROOT_PATH with value
803- # "${CMAKE_FIND_ROOT_PATH};${VCPKG_CMAKE_FIND_ROOT_PATH}"
804- # therefore, we don't have to worry about restoring its old value
805701 list (APPEND CMAKE_FIND_ROOT_PATH "${VCPKG_CMAKE_FIND_ROOT_PATH} " )
806702 endif ()
807- z_vcpkg_function_arguments (ARGS )
808- set (PACKAGE_NAME "${ARGV0} " )
809- string (TOLOWER "${PACKAGE_NAME} " LOWERCASE_PACKAGE_NAME)
703+ z_vcpkg_function_arguments (z_vcpkg_fp_ARGS 1 )
704+ string (TOLOWER "${z_vcpkg_fp_package_name} " z_vcpkg_fp_lowercase_package_name)
810705
811- set (VCPKG_CMAKE_WRAPPER_PATH "${_VCPKG_INSTALLED_DIR} /${VCPKG_TARGET_TRIPLET} /share/${LOWERCASE_PACKAGE_NAME } /vcpkg-cmake-wrapper.cmake" )
706+ set (z_vcpkg_fp_vcpkg_cmake_wrapper_path "${_VCPKG_INSTALLED_DIR} /${VCPKG_TARGET_TRIPLET} /share/${z_vcpkg_fp_lowercase_package_name } /vcpkg-cmake-wrapper.cmake" )
812707
813- z_vcpkg_start_parent_scope_export ( )
814- if ( EXISTS "${VCPKG_CMAKE_WRAPPER_PATH } " )
815- include ("${VCPKG_CMAKE_WRAPPER_PATH } " )
816- elseif (" ${PACKAGE_NAME} " STREQUAL "Boost" AND EXISTS "${_VCPKG_INSTALLED_DIR} /${VCPKG_TARGET_TRIPLET} /include/boost" )
708+ if ( EXISTS " ${z_vcpkg_fp_vcpkg_cmake_wrapper_path} " )
709+ set (ARGS "${z_vcpkg_fp_package_name} ; ${z_vcpkg_fp_ARGS } " )
710+ include ("${z_vcpkg_fp_vcpkg_cmake_wrapper_path } " )
711+ elseif (z_vcpkg_fp_package_name STREQUAL "Boost" AND EXISTS "${_VCPKG_INSTALLED_DIR} /${VCPKG_TARGET_TRIPLET} /include/boost" )
817712 # Checking for the boost headers disables this wrapper unless the user has installed at least one boost library
818713 set (Boost_USE_STATIC_LIBS OFF )
819714 set (Boost_USE_MULTITHREADED ON )
820715 unset (Boost_USE_STATIC_RUNTIME)
821716 set (Boost_NO_BOOST_CMAKE ON )
822717 unset (Boost_USE_STATIC_RUNTIME CACHE )
823- if (" ${ CMAKE_VS_PLATFORM_TOOLSET} " STREQUAL "v120" )
718+ if (CMAKE_VS_PLATFORM_TOOLSET STREQUAL "v120" )
824719 set (Boost_COMPILER "-vc120" )
825720 else ()
826721 set (Boost_COMPILER "-vc140" )
827722 endif ()
828- _find_package (${ARGS } )
829- elseif (" ${PACKAGE_NAME} " STREQUAL "ICU" AND EXISTS "${_VCPKG_INSTALLED_DIR} /${VCPKG_TARGET_TRIPLET} /include/unicode/utf.h" )
830- list (FIND ARGS "COMPONENTS" COMPONENTS_IDX )
831- if (NOT COMPONENTS_IDX EQUAL -1)
832- _find_package (${ARGS } COMPONENTS data )
723+ _find_package (" ${z_vcpkg_fp_package_name} " ${z_vcpkg_fp_ARGS } )
724+ elseif (z_vcpkg_fp_package_name STREQUAL "ICU" AND EXISTS "${_VCPKG_INSTALLED_DIR} /${VCPKG_TARGET_TRIPLET} /include/unicode/utf.h" )
725+ list (FIND z_vcpkg_fp_ARGS "COMPONENTS" z_vcpkg_fp_COMPONENTS_IDX )
726+ if (NOT z_vcpkg_fp_COMPONENTS_IDX EQUAL -1)
727+ _find_package (" ${z_vcpkg_fp_package_name} " ${z_vcpkg_fp_ARGS } COMPONENTS data )
833728 else ()
834- _find_package (${ARGS } )
729+ _find_package (" ${z_vcpkg_fp_package_name} " ${z_vcpkg_fp_ARGS } )
835730 endif ()
836- elseif (" ${PACKAGE_NAME} " STREQUAL "GSL" AND EXISTS "${_VCPKG_INSTALLED_DIR} /${VCPKG_TARGET_TRIPLET} /include/gsl" )
837- _find_package (${ARGS } )
731+ elseif (z_vcpkg_fp_package_name STREQUAL "GSL" AND EXISTS "${_VCPKG_INSTALLED_DIR} /${VCPKG_TARGET_TRIPLET} /include/gsl" )
732+ _find_package (" ${z_vcpkg_fp_package_name} " ${z_vcpkg_fp_ARGS } )
838733 if (GSL_FOUND AND TARGET GSL::gsl)
839734 set_property ( TARGET GSL::gslcblas APPEND PROPERTY IMPORTED_CONFIGURATIONS Release )
840735 set_property ( TARGET GSL::gsl APPEND PROPERTY IMPORTED_CONFIGURATIONS Release )
@@ -845,23 +740,39 @@ function("${VCPKG_OVERRIDE_FIND_PACKAGE_NAME}")
845740 set_target_properties ( GSL::gslcblas PROPERTIES IMPORTED_LOCATION_DEBUG "${GSL_CBLAS_LIBRARY_DEBUG} " )
846741 endif ()
847742 endif ()
848- elseif ("${PACKAGE_NAME } " STREQUAL "CURL" AND EXISTS "${_VCPKG_INSTALLED_DIR} /${VCPKG_TARGET_TRIPLET} /include/curl" )
849- _find_package (${ARGS } )
743+ elseif ("${z_vcpkg_fp_package_name } " STREQUAL "CURL" AND EXISTS "${_VCPKG_INSTALLED_DIR} /${VCPKG_TARGET_TRIPLET} /include/curl" )
744+ _find_package (" ${z_vcpkg_fp_package_name} " ${z_vcpkg_fp_ARGS } )
850745 if (CURL_FOUND)
851746 if (EXISTS "${_VCPKG_INSTALLED_DIR} /${VCPKG_TARGET_TRIPLET} /lib/nghttp2.lib" )
852747 list (APPEND CURL_LIBRARIES
853748 "debug" "${_VCPKG_INSTALLED_DIR} /${VCPKG_TARGET_TRIPLET} /debug/lib/nghttp2.lib"
854749 "optimized" "${_VCPKG_INSTALLED_DIR} /${VCPKG_TARGET_TRIPLET} /lib/nghttp2.lib" )
855750 endif ()
856751 endif ()
857- elseif ("${LOWERCASE_PACKAGE_NAME} " STREQUAL "grpc" AND EXISTS "${_VCPKG_INSTALLED_DIR} /${VCPKG_TARGET_TRIPLET} /share/grpc" )
858- list (REMOVE_AT ARGS 0)
859- _find_package (gRPC ${ARGS} )
752+ elseif ("${z_vcpkg_fp_lowercase_package_name} " STREQUAL "grpc" AND EXISTS "${_VCPKG_INSTALLED_DIR} /${VCPKG_TARGET_TRIPLET} /share/grpc" )
753+ _find_package (gRPC ${z_vcpkg_fp_ARGS} )
860754 else ()
861- _find_package (${ARGS } )
755+ _find_package (" ${z_vcpkg_fp_package_name} " ${z_vcpkg_fp_ARGS } )
862756 endif ()
863757
864- z_vcpkg_complete_parent_scope_export (IGNORE_REGEX "(^Z_VCPKG_)|(^ARGS$)|(^COMPONENTS_IDX$)" )
758+ get_property (z_vcpkg_fp_variable_list
759+ DIRECTORY PROPERTY "VARIABLES" )
760+ # this backfills to CMake 3.1, and past CMake 3.9 you'll get a trace that is about halved.
761+ if (CMAKE_MAJOR_VERSION LESS "3.9" )
762+ foreach (z_vcpkg_fp_variable IN LISTS z_vcpkg_fp_variable_list)
763+ # IN_LIST added in CMake 3.3
764+ # list(FILTER) added in CMake 3.9
765+ if (z_vcpkg_fp_variable MATCHES "${z_vcpkg_fp_ignored_variables} " )
766+ continue ()
767+ endif ()
768+ set ("${z_vcpkg_fp_variable} " "${${z_vcpkg_fp_variable} }" PARENT_SCOPE )
769+ endforeach ()
770+ else ()
771+ list (FILTER z_vcpkg_fp_variable_list EXCLUDE "${z_vcpkg_fp_ignored_variables} " )
772+ foreach (z_vcpkg_fp_variable IN LISTS z_vcpkg_fp_variable_list)
773+ set ("${z_vcpkg_fp_variable} " "${${z_vcpkg_fp_variable} }" PARENT_SCOPE )
774+ endforeach ()
775+ endif ()
865776endfunction ()
866777
867778set (VCPKG_TOOLCHAIN ON )
0 commit comments