diff --git a/docs/maintainers/cmake-guidelines.md b/docs/maintainers/cmake-guidelines.md index 77cdf73720..c0bd5b6a08 100644 --- a/docs/maintainers/cmake-guidelines.md +++ b/docs/maintainers/cmake-guidelines.md @@ -35,7 +35,7 @@ We hope that they will make both forwards and backwards compatibility easier. Always check for `ARGN` or `arg_UNPARSED_ARGUMENTS`. `FATAL_ERROR` when possible, `WARNING` if necessary for backwards compatibility. - All `cmake_parse_arguments` must use `PARSE_ARGV`. -- All `foreach` loops must use `IN LISTS` and `IN ITEMS`. +- All `foreach` loops must use `IN LISTS`, `IN ITEMS`, or `RANGE`. - The variables `${ARGV}` and `${ARGN}` are unreferenced, except in helpful messages to the user. - (i.e., `message(FATAL_ERROR "blah was passed extra arguments: ${ARGN}")`) @@ -45,27 +45,68 @@ We hope that they will make both forwards and backwards compatibility easier. - Exception: `vcpkg.cmake`'s `find_package`. - Scripts in the scripts tree should not be expected to need observable changes as part of normal operation. - - Example violation: `vcpkg_acquire_msys()` has hard-coded packages and versions that need updating over time due to the MSYS project dropping old packages. - - Example exception: `vcpkg_from_sourceforge()` has a list of mirrors which needs maintenance but does not have an observable behavior impact on the callers. -- All variable expansions are in quotes `""`, - except those which are intended to be passed as multiple arguments. - - Example: - ```cmake - set(working_directory "") - if(DEFINED arg_WORKING_DIRECTORY) - set(working_directory "WORKING_DIRECTORY" "${arg_WORKING_DIRECTORY}") - endif() - # calls do_the_thing() if NOT DEFINED arg_WORKING_DIRECTORY, - # else calls do_the_thing(WORKING_DIRECTORY "${arg_WORKING_DIRECTORY}") - do_the_thing(${working_directory}) - ``` + - Example violation: `vcpkg_acquire_msys()` has hard-coded packages and versions + that need updating over time due to the MSYS project dropping old packages. + - Example exception: `vcpkg_from_sourceforge()` has a list of mirrors which + needs maintenance, but does not have an observable behavior impact on the callers. +- Rules for quoting: there are three kinds of arguments in CMake - + unquoted (`foo(BAR)`), quoted (`foo("BAR")`), and bracketed (`foo([[BAR]])`). + Follow these rules to quote correctly: + - If an argument contains a variable expansion `${...}`, + it must be quoted. + - Exception: a "splat" variable expansion, when one variable will be + passed to a function as multiple arguments. In this case, the argument + should simply be `${foo}`: + ```cmake + vcpkg_list(SET working_directory) + if(DEFINED "arg_WORKING_DIRECTORY") + vcpkg_list(SET working_directory WORKING_DIRECTORY "${arg_WORKING_DIRECTORY}") + endif() + # calls do_the_thing() if NOT DEFINED arg_WORKING_DIRECTORY, + # else calls do_the_thing(WORKING_DIRECTORY "${arg_WORKING_DIRECTORY}") + do_the_thing(${working_directory}) + ``` + - Otherwise, if the argument contains any escape sequences that are not + `\\`, `\"`, or `\$`, that argument must be a quoted argument. + - For example: `"foo\nbar"` must be quoted. + - Otherwise, if the argument contains a `\`, a `"`, or a `$`, + that argument should be bracketed. + - Example: + ```cmake + set(x [[foo\bar]]) + set(y [=[foo([[bar\baz]])]=]) + ``` + - Otherwise, if the argument contains characters that are + not alphanumeric or `_`, that argument should be quoted. + - Otherwise, the argument should be unquoted. + - Exception: arguments to `if()` of type `` should always be quoted: + - Both arguments to the comparison operators - + `EQUAL`, `STREQUAL`, `VERSION_LESS`, etc. + - The first argument to `MATCHES` and `IN_LIST` + - Example: + ```cmake + if("${FOO}" STREQUAL "BAR") # ... + if("${BAZ}" EQUAL "0") # ... + if("FOO" IN_LIST list_variable) # ... + if("${bar}" MATCHES [[a[bcd]+\.[bcd]+]]) # ... + ``` + - For single expressions and for other types of predicates that do not + take ``, use the normal rules. - There are no "pointer" or "in-out" parameters (where a user passes a variable name rather than the contents), except for simple out-parameters. - Variables are not assumed to be empty. If the variable is intended to be used locally, - it must be explicitly initialized to empty with `set(foo "")`. -- All variables expected to be inherited from the parent scope across an API boundary (i.e. not a file-local function) should be documented. Note that all variables mentioned in triplets.md are considered documented. + it must be explicitly initialized to empty with `set(foo "")` if it is a string variable, + and `vcpkg_list(SET foo)` if it is a list variable. +- `set(var)` should not be used. Use `unset(var)` to unset a variable, + `set(var "")` to set it to the empty string, + and `vcpkg_list(SET var)` to set it to the empty list. + _Note: the empty string and the empty list are the same value;_ + _this is a notational difference rather than a difference in result_ +- All variables expected to be inherited from the parent scope across an API boundary + (i.e. not a file-local function) should be documented. + Note that all variables mentioned in triplets.md are considered documented. - Out parameters are only set in `PARENT_SCOPE` and are never read. See also the helper `z_vcpkg_forward_output_variable()` to forward out parameters through a function scope. - `CACHE` variables are used only for global variables which are shared internally among strongly coupled @@ -80,16 +121,14 @@ We hope that they will make both forwards and backwards compatibility easier. and `` _must always be_ less than or equal to ``. - This must be checked by something like: ```cmake - if(start LESS_EQUAL end) - foreach(RANGE start end) + if("${start}" LESS_EQUAL "${end}") + foreach(RANGE "${start}" "${end}") ... endforeach() endif() ``` - All port-based scripts must use `include_guard(GLOBAL)` to avoid being included multiple times. -- `set(var)` should not be used. Use `unset(var)` to unset a variable, - and `set(var "")` to set it to the empty value. _Note: this works for use as a list and as a string_ ### CMake Versions to Require diff --git a/docs/maintainers/internal/vcpkg_internal_get_cmake_vars.md b/docs/maintainers/internal/vcpkg_internal_get_cmake_vars.md deleted file mode 100644 index 63218102f7..0000000000 --- a/docs/maintainers/internal/vcpkg_internal_get_cmake_vars.md +++ /dev/null @@ -1,31 +0,0 @@ -# vcpkg_internal_get_cmake_vars - -The latest version of this document lives in the [vcpkg repo](https://github.com/Microsoft/vcpkg/blob/master/docs/). - -**Only for internal use in vcpkg helpers. Behavior and arguments will change without notice.** -Runs a cmake configure with a dummy project to extract certain cmake variables - -## Usage -```cmake -vcpkg_internal_get_cmake_vars( - [OUTPUT_FILE ] - [OPTIONS <-DUSE_THIS_IN_ALL_BUILDS=1>...] -) -``` - -## Parameters -### OPTIONS -Additional options to pass to the test configure call - -### OUTPUT_FILE -Variable to return the path to the generated cmake file with the detected `CMAKE_` variables set as `VCKPG_DETECTED_` - -## Notes -If possible avoid usage in portfiles. - -## Examples - -* [vcpkg_configure_make](https://github.com/Microsoft/vcpkg/blob/master/scripts/cmake/vcpkg_configure_make.cmake) - -## Source -[scripts/cmake/vcpkg\_internal\_get\_cmake\_vars.cmake](https://github.com/Microsoft/vcpkg/blob/master/scripts/cmake/vcpkg_internal_get_cmake_vars.cmake) diff --git a/docs/maintainers/internal/z_vcpkg_get_cmake_vars.md b/docs/maintainers/internal/z_vcpkg_get_cmake_vars.md new file mode 100644 index 0000000000..2dcf2a8e7e --- /dev/null +++ b/docs/maintainers/internal/z_vcpkg_get_cmake_vars.md @@ -0,0 +1,36 @@ +# z_vcpkg_get_cmake_vars + +The latest version of this document lives in the [vcpkg repo](https://github.com/Microsoft/vcpkg/blob/master/docs/). + +**Only for internal use in vcpkg helpers. Behavior and arguments will change without notice.** +Runs a cmake configure with a dummy project to extract certain cmake variables + +## Usage +```cmake +z_vcpkg_get_cmake_vars() +``` + +`z_vcpkg_get_cmake_vars(cmake_vars_file)` sets `` to +a path to a generated CMake file, with the detected `CMAKE_*` variables +re-exported as `VCPKG_DETECTED_*`. + +## Notes +Avoid usage in portfiles. + +All calls to `z_vcpkg_get_cmake_vars` will result in the same output file; +the output file is not generated multiple times. + +## Examples + +* [vcpkg_configure_make](https://github.com/Microsoft/vcpkg/blob/master/scripts/cmake/vcpkg_configure_make.cmake) + +### Basic Usage + +```cmake +z_vcpkg_get_cmake_vars(cmake_vars_file) +include("${cmake_vars_file}") +message(STATUS "detected CXX flags: ${VCPKG_DETECTED_CXX_FLAGS}") +``` + +## Source +[scripts/cmake/z\_vcpkg\_get\_cmake\_vars.cmake](https://github.com/Microsoft/vcpkg/blob/master/scripts/cmake/z_vcpkg_get_cmake_vars.cmake) diff --git a/docs/maintainers/portfile-functions.md b/docs/maintainers/portfile-functions.md index 0ba3533e2c..45aa4589bc 100644 --- a/docs/maintainers/portfile-functions.md +++ b/docs/maintainers/portfile-functions.md @@ -57,10 +57,10 @@ ## Internal Functions -- [vcpkg\_internal\_get\_cmake\_vars](internal/vcpkg_internal_get_cmake_vars.md) - [z\_vcpkg\_apply\_patches](internal/z_vcpkg_apply_patches.md) - [z\_vcpkg\_forward\_output\_variable](internal/z_vcpkg_forward_output_variable.md) - [z\_vcpkg\_function\_arguments](internal/z_vcpkg_function_arguments.md) +- [z\_vcpkg\_get\_cmake\_vars](internal/z_vcpkg_get_cmake_vars.md) - [z\_vcpkg\_prettify\_command\_line](internal/z_vcpkg_prettify_command_line.md) ## Scripts from Ports @@ -69,6 +69,7 @@ - [vcpkg\_cmake\_build](ports/vcpkg-cmake/vcpkg_cmake_build.md) - [vcpkg\_cmake\_configure](ports/vcpkg-cmake/vcpkg_cmake_configure.md) +- [vcpkg\_cmake\_get\_vars](ports/vcpkg-cmake/vcpkg_cmake_get_vars.md) - [vcpkg\_cmake\_install](ports/vcpkg-cmake/vcpkg_cmake_install.md) ### [vcpkg-cmake-config](ports/vcpkg-cmake-config.md) diff --git a/docs/maintainers/ports/vcpkg-cmake/vcpkg_cmake_get_vars.md b/docs/maintainers/ports/vcpkg-cmake/vcpkg_cmake_get_vars.md new file mode 100644 index 0000000000..68e51333c4 --- /dev/null +++ b/docs/maintainers/ports/vcpkg-cmake/vcpkg_cmake_get_vars.md @@ -0,0 +1,31 @@ +# vcpkg_cmake_get_vars + +The latest version of this document lives in the [vcpkg repo](https://github.com/Microsoft/vcpkg/blob/master/docs/maintainers/ports/vcpkg-cmake/vcpkg_cmake_get_vars.md). + +Runs a cmake configure with a dummy project to extract certain cmake variables + +## Usage +```cmake +vcpkg_cmake_get_vars() +``` + +`vcpkg_cmake_get_vars()` sets `` to +a path to a generated CMake file, with the detected `CMAKE_*` variables +re-exported as `VCPKG_DETECTED_CMAKE_*`. + +## Notes +Avoid usage in portfiles. + +All calls to `vcpkg_cmake_get_vars` will result in the same output file; +the output file is not generated multiple times. + +### Basic Usage + +```cmake +vcpkg_cmake_get_vars(cmake_vars_file) +include("${cmake_vars_file}") +message(STATUS "detected CXX flags: ${VCPKG_DETECTED_CMAKE_CXX_FLAGS}") +``` + +## Source +[ports/vcpkg-cmake/vcpkg\_cmake\_get\_vars.cmake](https://github.com/Microsoft/vcpkg/blob/master/ports/vcpkg-cmake/vcpkg_cmake_get_vars.cmake) diff --git a/docs/regenerate.ps1 b/docs/regenerate.ps1 index 7844055efe..f2f888a770 100755 --- a/docs/regenerate.ps1 +++ b/docs/regenerate.ps1 @@ -222,7 +222,7 @@ function ParseCmakeDocComment Get-ChildItem "$VcpkgRoot/scripts/cmake" -Filter '*.cmake' | ForEach-Object { $docs = ParseCmakeDocComment $_ - [Bool]$isInternalFunction = $_.Name.StartsWith("vcpkg_internal") -or $_.Name.StartsWith("z_vcpkg") + [Bool]$isInternalFunction = $_.Name.StartsWith("z_vcpkg") if ($docs.IsDeprecated -and $null -eq $docs.ActualDocumentation) { diff --git a/ports/ffmpeg/portfile.cmake b/ports/ffmpeg/portfile.cmake index 0ec2789d0e..d4451b4029 100644 --- a/ports/ffmpeg/portfile.cmake +++ b/ports/ffmpeg/portfile.cmake @@ -544,9 +544,8 @@ else() set(OPTIONS "${OPTIONS} --disable-zlib") endif() -set(CMAKE_VARS_FILE "${CURRENT_BUILDTREES_DIR}/vars.cmake") -vcpkg_internal_get_cmake_vars(OUTPUT_FILE CMAKE_VARS_FILE) -include("${CMAKE_VARS_FILE}") +vcpkg_cmake_get_vars(cmake_vars_file) +include("${cmake_vars_file}") if (VCPKG_TARGET_IS_OSX) # if the sysroot isn't set in the triplet we fall back to whatever CMake detected for us diff --git a/ports/ffmpeg/vcpkg.json b/ports/ffmpeg/vcpkg.json index 5a001e0696..854bcaf1ab 100644 --- a/ports/ffmpeg/vcpkg.json +++ b/ports/ffmpeg/vcpkg.json @@ -1,13 +1,17 @@ { "name": "ffmpeg", "version": "4.4", - "port-version": 11, + "port-version": 12, "description": [ "a library to decode, encode, transcode, mux, demux, stream, filter and play pretty much anything that humans and machines have created.", "FFmpeg is the leading multimedia framework, able to decode, encode, transcode, mux, demux, stream, filter and play pretty much anything that humans and machines have created. It supports the most obscure ancient formats up to the cutting edge. No matter if they were designed by some standards committee, the community or a corporation. It is also highly portable: FFmpeg compiles, runs, and passes our testing infrastructure FATE across Linux, Mac OS X, Microsoft Windows, the BSDs, Solaris, etc. under a wide variety of build environments, machine architectures, and configurations." ], "homepage": "https://ffmpeg.org", "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + }, { "name": "vcpkg-pkgconfig-get-modules", "host": true diff --git a/ports/vcpkg-cmake/cmake_get_vars/CMakeLists.txt b/ports/vcpkg-cmake/cmake_get_vars/CMakeLists.txt new file mode 100644 index 0000000000..084042fb11 --- /dev/null +++ b/ports/vcpkg-cmake/cmake_get_vars/CMakeLists.txt @@ -0,0 +1,148 @@ +cmake_minimum_required(VERSION 3.20) + +set(VCPKG_LANGUAGES "C;CXX" CACHE STRING "Languages to enables for this project") + +set(OUTPUT_STRING) +# Build default checklists +list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_CROSSCOMPILING + CMAKE_SYSTEM_NAME + CMAKE_HOST_SYSTEM_NAME + CMAKE_SYSTEM_PROCESSOR + CMAKE_HOST_SYSTEM_PROCESSOR) +if(CMAKE_SYSTEM_NAME MATCHES "Darwin") + list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_OSX_DEPLOYMENT_TARGET + CMAKE_OSX_SYSROOT) +endif() +# Programs to check +set(PROGLIST AR RANLIB STRIP NM OBJDUMP DLLTOOL MT LINKER) +foreach(prog IN LISTS PROGLIST) + list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${prog}) +endforeach() +set(COMPILERS ${VCPKG_LANGUAGES} RC) +foreach(prog IN LISTS COMPILERS) + list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${prog}_COMPILER) +endforeach() +# Variables to check +foreach(_lang IN LISTS VCPKG_LANGUAGES) + list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${_lang}_STANDARD_INCLUDE_DIRECTORIES) + list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${_lang}_STANDARD_LIBRARIES) + list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${_lang}_STANDARD) + list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${_lang}_COMPILE_FEATURES) + list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${_lang}_EXTENSION) + # Probably never required since implicit. + #list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${_lang}_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES) + #list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${_lang}_IMPLICIT_INCLUDE_DIRECTORIES) + #list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${_lang}_IMPLICIT_LINK_DIRECTORIES) + #list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_${_lang}_IMPLICIT_LINK_LIBRARIES) +endforeach() +list(REMOVE_DUPLICATES VCPKG_DEFAULT_VARS_TO_CHECK) + +# Environment variables to check. +list(APPEND VCPKG_DEFAULT_ENV_VARS_TO_CHECK PATH INCLUDE C_INCLUDE_PATH CPLUS_INCLUDE_PATH LIB LIBPATH LIBRARY_PATH LD_LIBRARY_PATH) +list(REMOVE_DUPLICATES VCPKG_DEFAULT_ENV_VARS_TO_CHECK) + +#Flags to check. Flags are a bit special since they are configuration aware. +set(FLAGS ${VCPKG_LANGUAGES} RC SHARED_LINKER STATIC_LINKER EXE_LINKER) +foreach(flag IN LISTS FLAGS) + list(APPEND VCPKG_DEFAULT_FLAGS_TO_CHECK CMAKE_${flag}_FLAGS) +endforeach() +list(REMOVE_DUPLICATES VCPKG_DEFAULT_FLAGS_TO_CHECK) + +#Language-specific flags. +foreach(_lang IN LISTS VCPKG_LANGUAGES) + list(APPEND VCPKG_LANG_FLAGS CMAKE_${_lang}_FLAGS) +endforeach() +list(REMOVE_DUPLICATES VCPKG_LANG_FLAGS) + +# TODO if ever necessary: Properties to check + +set(VCPKG_VAR_PREFIX "VCPKG_DETECTED" CACHE STRING "Variable prefix to use for detected flags") +set(VCPKG_VARS_TO_CHECK "${VCPKG_DEFAULT_VARS_TO_CHECK}" CACHE STRING "Variables to check. If not given there is a list of defaults") +set(VCPKG_FLAGS_TO_CHECK "${VCPKG_DEFAULT_FLAGS_TO_CHECK}" CACHE STRING "Variables to check. If not given there is a list of defaults") +set(VCPKG_ENV_VARS_TO_CHECK "${VCPKG_DEFAULT_ENV_VARS_TO_CHECK}" CACHE STRING "Variables to check. If not given there is a list of defaults") + +if(NOT VCPKG_OUTPUT_FILE) + message(FATAL_ERROR "VCPKG_OUTPUT_FILE is required to be defined") +endif() + +if(NOT CMAKE_BUILD_TYPE) + message(FATAL_ERROR "CMAKE_BUILD_TYPE is required to be defined") +else() + string(TOUPPER "${CMAKE_BUILD_TYPE}" VCPKG_CONFIGS) +endif() + + +project(get_cmake_vars LANGUAGES ${VCPKG_LANGUAGES}) + +foreach(VAR IN LISTS VCPKG_VARS_TO_CHECK) + string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_${VAR} \"${${VAR}}\")\n") +endforeach() + +foreach(_env IN LISTS VCPKG_ENV_VARS_TO_CHECK) + if(CMAKE_HOST_WIN32) + string(REPLACE "\\" "/" ENV_${_env} "$ENV{${_env}}") + string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_ENV_${_env} \"${ENV_${_env}}\")\n") + else() + string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_ENV_${_env} \"$ENV{${_env}}\")\n") + endif() +endforeach() + +macro(_vcpkg_adjust_flags flag_var) + if(MSVC) # Transform MSVC /flags to -flags due to bash scripts intepreting /flag as a path. + string(REGEX REPLACE "(^| )/" "\\1-" ${flag_var} "${${flag_var}}") + endif() + if(CMAKE_SYSTEM_NAME MATCHES "Darwin") + if("${flag_var}" IN_LIST VCPKG_LANG_FLAGS) + # macOS - append arch and isysroot if cross-compiling + if(NOT "${CMAKE_OSX_ARCHITECTURES}" STREQUAL "${CMAKE_HOST_SYSTEM_PROCESSOR}") + + foreach(arch IN LISTS CMAKE_OSX_ARCHITECTURES) + string(APPEND ${flag_var} " -arch ${arch}") + endforeach() + string(APPEND ${flag_var} " -isysroot ${CMAKE_OSX_SYSROOT}") + endif() + endif() + endif() +endmacro() + +foreach(flag IN LISTS VCPKG_FLAGS_TO_CHECK) + string(STRIP "${${flag}}" ${flag}) # Strip leading and trailing whitespaces + _vcpkg_adjust_flags(${flag}) + string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_RAW_${flag} \" ${${flag}}\")\n") + foreach(config IN LISTS VCPKG_CONFIGS) + string(STRIP "${${flag}_${config}}" ${flag}_${config}) + _vcpkg_adjust_flags(${flag}_${config}) + string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_RAW_${flag}_${config} \"${CMAKE_${flag}_FLAGS_${config}}\")\n") + set(COMBINED_${flag}_${config} "${${flag}} ${${flag}_${config}}") + string(STRIP "${COMBINED_${flag}_${config}}" COMBINED_${flag}_${config}) + string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_${flag}_${config} \"${COMBINED_${flag}_${config}}\")\n") + endforeach() +endforeach() + + +file(WRITE "${VCPKG_OUTPUT_FILE}" "${OUTPUT_STRING}") + +# Programs: +# CMAKE_AR +# CMAKE__COMPILER_AR (Wrapper) +# CMAKE_RANLIB +# CMAKE__COMPILER_RANLIB +# CMAKE_STRIP +# CMAKE_NM +# CMAKE_OBJDUMP +# CMAKE_DLLTOOL +# CMAKE_MT +# CMAKE_LINKER +# CMAKE_C_COMPILER +# CMAKE_CXX_COMPILER +# CMAKE_RC_COMPILER + +# Flags: +# CMAKE__FLAGS +# CMAKE__FLAGS_ +# CMAKE_RC_FLAGS +# CMAKE_SHARED_LINKER_FLAGS +# CMAKE_STATIC_LINKER_FLAGS +# CMAKE_STATIC_LINKER_FLAGS_ +# CMAKE_EXE_LINKER_FLAGS +# CMAKE_EXE_LINKER_FLAGS_ diff --git a/ports/vcpkg-cmake/portfile.cmake b/ports/vcpkg-cmake/portfile.cmake index 70b1ed128c..afc1ffbb47 100644 --- a/ports/vcpkg-cmake/portfile.cmake +++ b/ports/vcpkg-cmake/portfile.cmake @@ -7,6 +7,8 @@ file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/vcpkg_cmake_configure.cmake" "${CMAKE_CURRENT_LIST_DIR}/vcpkg_cmake_build.cmake" "${CMAKE_CURRENT_LIST_DIR}/vcpkg_cmake_install.cmake" + "${CMAKE_CURRENT_LIST_DIR}/vcpkg_cmake_get_vars.cmake" + "${CMAKE_CURRENT_LIST_DIR}/cmake_get_vars" "${CMAKE_CURRENT_LIST_DIR}/vcpkg-port-config.cmake" "${CMAKE_CURRENT_LIST_DIR}/copyright" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") diff --git a/ports/vcpkg-cmake/vcpkg-port-config.cmake b/ports/vcpkg-cmake/vcpkg-port-config.cmake index f2a973d4eb..2eb9f37233 100644 --- a/ports/vcpkg-cmake/vcpkg-port-config.cmake +++ b/ports/vcpkg-cmake/vcpkg-port-config.cmake @@ -1,3 +1,4 @@ include("${CMAKE_CURRENT_LIST_DIR}/vcpkg_cmake_configure.cmake") include("${CMAKE_CURRENT_LIST_DIR}/vcpkg_cmake_build.cmake") include("${CMAKE_CURRENT_LIST_DIR}/vcpkg_cmake_install.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/vcpkg_cmake_get_vars.cmake") diff --git a/ports/vcpkg-cmake/vcpkg.json b/ports/vcpkg-cmake/vcpkg.json index 88ee459ff3..f7d28a5665 100644 --- a/ports/vcpkg-cmake/vcpkg.json +++ b/ports/vcpkg-cmake/vcpkg.json @@ -1,5 +1,4 @@ { "name": "vcpkg-cmake", - "version-date": "2021-06-25", - "port-version": 5 + "version-date": "2021-07-26" } diff --git a/ports/vcpkg-cmake/vcpkg_cmake_configure.cmake b/ports/vcpkg-cmake/vcpkg_cmake_configure.cmake index aa99a81ce2..889fa8c096 100644 --- a/ports/vcpkg-cmake/vcpkg_cmake_configure.cmake +++ b/ports/vcpkg-cmake/vcpkg_cmake_configure.cmake @@ -93,12 +93,12 @@ endmacro() function(vcpkg_cmake_configure) cmake_parse_arguments(PARSE_ARGV 0 "arg" - "PREFER_NINJA;DISABLE_PARALLEL_CONFIGURE;WINDOWS_USE_MSBUILD;NO_CHARSET_FLAG" + "PREFER_NINJA;DISABLE_PARALLEL_CONFIGURE;WINDOWS_USE_MSBUILD;NO_CHARSET_FLAG;Z_CMAKE_GET_VARS_USAGE" "SOURCE_PATH;GENERATOR;LOGFILE_BASE" "OPTIONS;OPTIONS_DEBUG;OPTIONS_RELEASE;MAYBE_UNUSED_VARIABLES" ) - if(DEFINED CACHE{Z_VCPKG_CMAKE_GENERATOR}) + if(NOT arg_Z_CMAKE_GET_VARS_USAGE AND DEFINED CACHE{Z_VCPKG_CMAKE_GENERATOR}) message(WARNING "vcpkg_cmake_configure already called; this function should only be called once.") endif() @@ -113,14 +113,21 @@ function(vcpkg_cmake_configure) endif() set(manually_specified_variables "") - foreach(option IN LISTS arg_OPTIONS arg_OPTIONS_RELEASE arg_OPTIONS_DEBUG) - if(option MATCHES "^-D([^:=]*)[:=]") - list(APPEND manually_specified_variables "${CMAKE_MATCH_1}") - endif() - endforeach() - list(REMOVE_DUPLICATES manually_specified_variables) - list(REMOVE_ITEM manually_specified_variables ${arg_MAYBE_UNUSED_VARIABLES}) - debug_message("manually specified variables: ${manually_specified_variables}") + + if(arg_Z_CMAKE_GET_VARS_USAGE) + set(configuring_message "Getting CMake variables for ${TARGET_TRIPLET}") + else() + set(configuring_message "Configuring ${TARGET_TRIPLET}") + + foreach(option IN LISTS arg_OPTIONS arg_OPTIONS_RELEASE arg_OPTIONS_DEBUG) + if(option MATCHES "^-D([^:=]*)[:=]") + list(APPEND manually_specified_variables "${CMAKE_MATCH_1}") + endif() + endforeach() + list(REMOVE_DUPLICATES manually_specified_variables) + list(REMOVE_ITEM manually_specified_variables ${arg_MAYBE_UNUSED_VARIABLES}) + debug_message("manually specified variables: ${manually_specified_variables}") + endif() if(CMAKE_HOST_WIN32) if(DEFINED ENV{PROCESSOR_ARCHITEW6432}) @@ -377,7 +384,7 @@ function(vcpkg_cmake_configure) file(MAKE_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/vcpkg-parallel-configure") file(WRITE "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/vcpkg-parallel-configure/build.ninja" "${parallel_configure_contents}") - message(STATUS "Configuring ${TARGET_TRIPLET}") + message(STATUS "${configuring_message}") vcpkg_execute_required_process( COMMAND ninja -v WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/vcpkg-parallel-configure" @@ -388,7 +395,7 @@ function(vcpkg_cmake_configure) "${CURRENT_BUILDTREES_DIR}/${arg_LOGFILE_BASE}-err.log") else() if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") - message(STATUS "Configuring ${TARGET_TRIPLET}-dbg") + message(STATUS "${configuring_message}-dbg") file(MAKE_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg") vcpkg_execute_required_process( COMMAND @@ -407,7 +414,7 @@ function(vcpkg_cmake_configure) endif() if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") - message(STATUS "Configuring ${TARGET_TRIPLET}-rel") + message(STATUS "${configuring_message}-rel") file(MAKE_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel") vcpkg_execute_required_process( COMMAND @@ -458,5 +465,7 @@ Please recheck them and remove the unnecessary options from the `vcpkg_cmake_con If these options should still be passed for whatever reason, please use the `MAYBE_UNUSED_VARIABLES` argument.") endif() - set(Z_VCPKG_CMAKE_GENERATOR "${generator}" CACHE INTERNAL "The generator which was used to configure CMake.") + if(NOT arg_Z_CMAKE_GET_VARS_USAGE) + set(Z_VCPKG_CMAKE_GENERATOR "${generator}" CACHE INTERNAL "The generator which was used to configure CMake.") + endif() endfunction() diff --git a/ports/vcpkg-cmake/vcpkg_cmake_get_vars.cmake b/ports/vcpkg-cmake/vcpkg_cmake_get_vars.cmake new file mode 100644 index 0000000000..ec1a998090 --- /dev/null +++ b/ports/vcpkg-cmake/vcpkg_cmake_get_vars.cmake @@ -0,0 +1,61 @@ +#[===[.md: +# vcpkg_cmake_get_vars + +Runs a cmake configure with a dummy project to extract certain cmake variables + +## Usage +```cmake +vcpkg_cmake_get_vars() +``` + +`vcpkg_cmake_get_vars()` sets `` to +a path to a generated CMake file, with the detected `CMAKE_*` variables +re-exported as `VCPKG_DETECTED_CMAKE_*`. + +## Notes +Avoid usage in portfiles. + +All calls to `vcpkg_cmake_get_vars` will result in the same output file; +the output file is not generated multiple times. + +### Basic Usage + +```cmake +vcpkg_cmake_get_vars(cmake_vars_file) +include("${cmake_vars_file}") +message(STATUS "detected CXX flags: ${VCPKG_DETECTED_CMAKE_CXX_FLAGS}") +``` +#]===] + +set(Z_VCPKG_CMAKE_GET_VARS_CURRENT_LIST_DIR "${CMAKE_CURRENT_LIST_DIR}") + +function(vcpkg_cmake_get_vars out_file) + cmake_parse_arguments(PARSE_ARGV 1 arg "" "" "") + + if(DEFINED arg_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}") + endif() + + if(NOT DEFINED CACHE{Z_VCPKG_CMAKE_GET_VARS_FILE}) + set(Z_VCPKG_CMAKE_GET_VARS_FILE "${CURRENT_BUILDTREES_DIR}/cmake-get-vars-${TARGET_TRIPLET}.cmake.log" + CACHE PATH "The file to include to access the CMake variables from a generated project.") + vcpkg_cmake_configure( + SOURCE_PATH "${Z_VCPKG_CMAKE_GET_VARS_CURRENT_LIST_DIR}/cmake_get_vars" + OPTIONS_DEBUG "-DVCPKG_OUTPUT_FILE:PATH=${CURRENT_BUILDTREES_DIR}/cmake-get-vars-${TARGET_TRIPLET}-dbg.cmake.log" + OPTIONS_RELEASE "-DVCPKG_OUTPUT_FILE:PATH=${CURRENT_BUILDTREES_DIR}/cmake-get-vars-${TARGET_TRIPLET}-rel.cmake.log" + LOGFILE_BASE cmake-get-vars-${TARGET_TRIPLET} + Z_CMAKE_GET_VARS_USAGE # be quiet, don't set variables... + ) + + set(include_string "") + if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") + string(APPEND include_string "include(\"\${CMAKE_CURRENT_LIST_DIR}/cmake-get-vars-${TARGET_TRIPLET}-rel.cmake.log\")\n") + endif() + if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") + string(APPEND include_string "include(\"\${CMAKE_CURRENT_LIST_DIR}/cmake-get-vars-${TARGET_TRIPLET}-dbg.cmake.log\")\n") + endif() + file(WRITE "${Z_VCPKG_CMAKE_GET_VARS_FILE}" "${include_string}") + endif() + + set("${out_file}" "${Z_VCPKG_CMAKE_GET_VARS_FILE}" PARENT_SCOPE) +endfunction() diff --git a/scripts/buildsystems/vcpkg.cmake b/scripts/buildsystems/vcpkg.cmake index ff0873457e..e59779e4ed 100644 --- a/scripts/buildsystems/vcpkg.cmake +++ b/scripts/buildsystems/vcpkg.cmake @@ -385,39 +385,24 @@ set(_VCPKG_INSTALLED_DIR "${VCPKG_INSTALLED_DIR}" CACHE PATH "The directory which contains the installed libraries for each triplet" FORCE) -if(VCPKG_PREFER_SYSTEM_LIBS) - set(Z_VCPKG_PATH_LIST_OP APPEND) -else() - set(Z_VCPKG_PATH_LIST_OP PREPEND) -endif() - -if(CMAKE_BUILD_TYPE MATCHES "^[Dd][Ee][Bb][Uu][Gg]$" OR NOT DEFINED CMAKE_BUILD_TYPE) #Debug build: Put Debug paths before Release paths. - list(${Z_VCPKG_PATH_LIST_OP} CMAKE_PREFIX_PATH - "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug" - "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}" +function(z_vcpkg_add_vcpkg_to_cmake_path list suffix) + set(vcpkg_paths + "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}${suffix}" + "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug${suffix}" ) - list(${Z_VCPKG_PATH_LIST_OP} CMAKE_LIBRARY_PATH - "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/lib/manual-link" - "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/manual-link" - ) - list(${Z_VCPKG_PATH_LIST_OP} CMAKE_FIND_ROOT_PATH - "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug" - "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}" - ) -else() #Release build: Put Release paths before Debug paths. Debug Paths are required so that CMake generates correct info in autogenerated target files. - list(${Z_VCPKG_PATH_LIST_OP} CMAKE_PREFIX_PATH - "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}" - "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug" - ) - list(${Z_VCPKG_PATH_LIST_OP} CMAKE_LIBRARY_PATH - "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/manual-link" - "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/lib/manual-link" - ) - list(${Z_VCPKG_PATH_LIST_OP} CMAKE_FIND_ROOT_PATH - "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}" - "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug" - ) -endif() + if(NOT DEFINED CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE MATCHES "^[Dd][Ee][Bb][Uu][Gg]$") + list(REVERSE vcpkg_paths) # Debug build: Put Debug paths before Release paths. + endif() + if(VCPKG_PREFER_SYSTEM_LIBS) + list(APPEND "${list}" "${vcpkg_paths}") + else() + list(INSERT "${list}" 0 "${vcpkg_paths}") # CMake 3.15 is required for list(PREPEND ...). + endif() + set("${list}" "${${list}}" PARENT_SCOPE) +endfunction() +z_vcpkg_add_vcpkg_to_cmake_path(CMAKE_PREFIX_PATH "") +z_vcpkg_add_vcpkg_to_cmake_path(CMAKE_LIBRARY_PATH "/lib/manual-link") +z_vcpkg_add_vcpkg_to_cmake_path(CMAKE_FIND_ROOT_PATH "") # If one CMAKE_FIND_ROOT_PATH_MODE_* variables is set to ONLY, to make sure that ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET} # and ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug are searched, it is not sufficient to just add them to CMAKE_FIND_ROOT_PATH, @@ -692,7 +677,7 @@ if(X_VCPKG_APPLOCAL_DEPS_INSTALL) list(APPEND parsed_targets "${arg}") endif() - if(last_command STREQUAL "DESTINATION" AND (MODIFIER STREQUAL "" OR MODIFIER STREQUAL "RUNTIME")) + if(last_command STREQUAL "DESTINATION" AND (modifier STREQUAL "" OR modifier STREQUAL "RUNTIME")) set(destination "${arg}") endif() if(last_command STREQUAL "COMPONENT") diff --git a/scripts/cmake/vcpkg_build_make.cmake b/scripts/cmake/vcpkg_build_make.cmake index dd845bde45..6bd84c5ad1 100755 --- a/scripts/cmake/vcpkg_build_make.cmake +++ b/scripts/cmake/vcpkg_build_make.cmake @@ -51,11 +51,8 @@ You can use the alias [`vcpkg_install_make()`](vcpkg_install_make.md) function i #]===] function(vcpkg_build_make) - if(NOT _VCPKG_CMAKE_VARS_FILE) - # vcpkg_build_make called without using vcpkg_configure_make before - vcpkg_internal_get_cmake_vars(OUTPUT_FILE _VCPKG_CMAKE_VARS_FILE) - endif() - include("${_VCPKG_CMAKE_VARS_FILE}") + z_vcpkg_get_cmake_vars(cmake_vars_file) + include("${cmake_vars_file}") # parse parameters such that semicolons in options arguments to COMMAND don't get erased cmake_parse_arguments(PARSE_ARGV 0 _bc "ADD_BIN_TO_PATH;ENABLE_INSTALL;DISABLE_PARALLEL" "LOGFILE_ROOT;BUILD_TARGET;SUBPATH;MAKEFILE;INSTALL_TARGET" "") diff --git a/scripts/cmake/vcpkg_check_linkage.cmake b/scripts/cmake/vcpkg_check_linkage.cmake index 97e29bad7f..f2e9fe10aa 100644 --- a/scripts/cmake/vcpkg_check_linkage.cmake +++ b/scripts/cmake/vcpkg_check_linkage.cmake @@ -35,24 +35,38 @@ This command will either alter the settings for `VCPKG_LIBRARY_LINKAGE` or fail, #]===] function(vcpkg_check_linkage) - cmake_parse_arguments(_csc "ONLY_STATIC_LIBRARY;ONLY_DYNAMIC_LIBRARY;ONLY_DYNAMIC_CRT;ONLY_STATIC_CRT" "" "" ${ARGN}) + cmake_parse_arguments(PARSE_ARGV 0 arg + "ONLY_STATIC_LIBRARY;ONLY_DYNAMIC_LIBRARY;ONLY_DYNAMIC_CRT;ONLY_STATIC_CRT" + "" + "" + ) - if(_csc_ONLY_STATIC_LIBRARY AND VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic") + if(DEFINED arg_UNPARSED_ARGUMENTS) + message(WARNING "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}") + endif() + + if(arg_ONLY_STATIC_LIBRARY AND arg_ONLY_DYNAMIC_LIBRARY) + message(FATAL_ERROR "Requesting both ONLY_STATIC_LIBRARY and ONLY_DYNAMIC_LIBRARY; this is an error.") + endif() + if(arg_ONLY_STATIC_CRT AND arg_ONLY_DYNAMIC_CRT) + message(FATAL_ERROR "Requesting both ONLY_STATIC_CRT and ONLY_DYNAMIC_CRT; this is an error.") + endif() + + if(arg_ONLY_STATIC_LIBRARY AND "${VCPKG_LIBRARY_LINKAGE}" STREQUAL "dynamic") message(STATUS "Note: ${PORT} only supports static library linkage. Building static library.") set(VCPKG_LIBRARY_LINKAGE static PARENT_SCOPE) - endif() - if(_csc_ONLY_DYNAMIC_LIBRARY AND VCPKG_LIBRARY_LINKAGE STREQUAL "static") + elseif(arg_ONLY_DYNAMIC_LIBRARY AND "${VCPKG_LIBRARY_LINKAGE}" STREQUAL "static") message(STATUS "Note: ${PORT} only supports dynamic library linkage. Building dynamic library.") - if(VCPKG_CRT_LINKAGE STREQUAL "static") - message(FATAL_ERROR "Refusing to build unexpected dynamic library against the static CRT. If this is desired, please configure your triplet to directly request this configuration.") + if("${VCPKG_CRT_LINKAGE}" STREQUAL "static") + message(FATAL_ERROR "Refusing to build unexpected dynamic library against the static CRT. + If this is desired, please configure your triplet to directly request this configuration.") endif() set(VCPKG_LIBRARY_LINKAGE dynamic PARENT_SCOPE) endif() - if(_csc_ONLY_DYNAMIC_CRT AND VCPKG_CRT_LINKAGE STREQUAL "static") + if(arg_ONLY_DYNAMIC_CRT AND "${VCPKG_CRT_LINKAGE}" STREQUAL "static") message(FATAL_ERROR "${PORT} only supports dynamic crt linkage") - endif() - if(_csc_ONLY_STATIC_CRT AND VCPKG_CRT_LINKAGE STREQUAL "dynamic") + elseif(arg_ONLY_STATIC_CRT AND "${VCPKG_CRT_LINKAGE}" STREQUAL "dynamic") message(FATAL_ERROR "${PORT} only supports static crt linkage") endif() endfunction() diff --git a/scripts/cmake/vcpkg_clean_executables_in_bin.cmake b/scripts/cmake/vcpkg_clean_executables_in_bin.cmake index 077e23cc3f..e1cea3a958 100644 --- a/scripts/cmake/vcpkg_clean_executables_in_bin.cmake +++ b/scripts/cmake/vcpkg_clean_executables_in_bin.cmake @@ -21,15 +21,35 @@ Generally, there is no need to call this function manually. Instead, pass an ext * [czmq](https://github.com/microsoft/vcpkg/blob/master/ports/czmq/portfile.cmake) #]===] -function(vcpkg_clean_executables_in_bin) - # parse parameters such that semicolons in options arguments to COMMAND don't get erased - cmake_parse_arguments(PARSE_ARGV 0 _vct "" "" "FILE_NAMES") +function(z_vcpkg_clean_executables_in_bin_remove_directory_if_empty directory) + if(NOT EXISTS "${directory}") + return() + endif() - if(NOT DEFINED _vct_FILE_NAMES) + if(NOT IS_DIRECTORY "${directory}") + message(FATAL_ERROR "${directory} must be a directory") + endif() + + file(GLOB items "${directory}/*") + if("${items}" STREQUAL "") + file(REMOVE_RECURSE "${directory}") + endif() +endfunction() + + +function(vcpkg_clean_executables_in_bin) + cmake_parse_arguments(PARSE_ARGV 0 arg "" "" "FILE_NAMES") + + if(NOT DEFINED arg_FILE_NAMES) message(FATAL_ERROR "FILE_NAMES must be specified.") endif() - foreach(file_name IN LISTS _vct_FILE_NAMES) + if(DEFINED arg_UNPARSED_ARGUMENTS) + message(WARNING "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}") + endif() + + + foreach(file_name IN LISTS arg_FILE_NAMES) file(REMOVE "${CURRENT_PACKAGES_DIR}/bin/${file_name}${VCPKG_TARGET_EXECUTABLE_SUFFIX}" "${CURRENT_PACKAGES_DIR}/debug/bin/${file_name}${VCPKG_TARGET_EXECUTABLE_SUFFIX}" @@ -38,27 +58,6 @@ function(vcpkg_clean_executables_in_bin) ) endforeach() - function(try_remove_empty_directory directory) - if(NOT EXISTS "${directory}") - return() - endif() - - if(NOT IS_DIRECTORY "${directory}") - message(FATAL_ERROR "${directory} is supposed to be an existing directory.") - endif() - - # TODO: - # For an empty directory, - # file(GLOB items "${directory}" "${directory}/*") - # will return a list with one item. - file(GLOB items "${directory}/" "${directory}/*") - list(LENGTH items items_count) - - if(${items_count} EQUAL 0) - file(REMOVE_RECURSE "${directory}") - endif() - endfunction() - - try_remove_empty_directory("${CURRENT_PACKAGES_DIR}/bin") - try_remove_empty_directory("${CURRENT_PACKAGES_DIR}/debug/bin") + z_vcpkg_clean_executables_in_bin_remove_directory_if_empty("${CURRENT_PACKAGES_DIR}/bin") + z_vcpkg_clean_executables_in_bin_remove_directory_if_empty("${CURRENT_PACKAGES_DIR}/debug/bin") endfunction() diff --git a/scripts/cmake/vcpkg_configure_cmake.cmake b/scripts/cmake/vcpkg_configure_cmake.cmake index bce3f6af58..56bf9bd576 100644 --- a/scripts/cmake/vcpkg_configure_cmake.cmake +++ b/scripts/cmake/vcpkg_configure_cmake.cmake @@ -72,16 +72,16 @@ This command supplies many common arguments to CMake. To see the full list, exam #]===] function(vcpkg_configure_cmake) - if(Z_VCPKG_CMAKE_CONFIGURE_GUARD) - message(FATAL_ERROR "The ${PORT} port already depends on vcpkg-cmake; using both vcpkg-cmake and vcpkg_configure_cmake in the same port is unsupported.") - endif() - cmake_parse_arguments(PARSE_ARGV 0 arg - "PREFER_NINJA;DISABLE_PARALLEL_CONFIGURE;NO_CHARSET_FLAG;Z_VCPKG_IGNORE_UNUSED_VARIABLES" + "PREFER_NINJA;DISABLE_PARALLEL_CONFIGURE;NO_CHARSET_FLAG;Z_GET_CMAKE_VARS_USAGE" "SOURCE_PATH;GENERATOR;LOGNAME" "OPTIONS;OPTIONS_DEBUG;OPTIONS_RELEASE;MAYBE_UNUSED_VARIABLES" ) + if(NOT arg_Z_GET_CMAKE_VARS_USAGE AND Z_VCPKG_CMAKE_CONFIGURE_GUARD) + message(FATAL_ERROR "The ${PORT} port already depends on vcpkg-cmake; using both vcpkg-cmake and vcpkg_configure_cmake in the same port is unsupported.") + endif() + if(NOT VCPKG_PLATFORM_TOOLSET) message(FATAL_ERROR "Vcpkg has been updated with VS2017 support; " "however, vcpkg.exe must be rebuilt by re-running bootstrap-vcpkg.bat\n") @@ -92,7 +92,12 @@ function(vcpkg_configure_cmake) endif() set(manually_specified_variables "") - if(NOT arg_Z_VCPKG_IGNORE_UNUSED_VARIABLES) + + if(arg_Z_GET_CMAKE_VARS_USAGE) + set(configuring_message "Getting CMake variables for ${TARGET_TRIPLET}") + else() + set(configuring_message "Configuring ${TARGET_TRIPLET}") + foreach(option IN LISTS arg_OPTIONS arg_OPTIONS_RELEASE arg_OPTIONS_DEBUG) if(option MATCHES "^-D([^:=]*)[:=]") list(APPEND manually_specified_variables "${CMAKE_MATCH_1}") @@ -336,7 +341,7 @@ function(vcpkg_configure_cmake) file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/vcpkg-parallel-configure) file(WRITE ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/vcpkg-parallel-configure/build.ninja "${_contents}") - message(STATUS "Configuring ${TARGET_TRIPLET}") + message(STATUS "${configuring_message}") vcpkg_execute_required_process( COMMAND ninja -v WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/vcpkg-parallel-configure @@ -348,7 +353,7 @@ function(vcpkg_configure_cmake) "${CURRENT_BUILDTREES_DIR}/${arg_LOGNAME}-err.log") else() if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") - message(STATUS "Configuring ${TARGET_TRIPLET}-dbg") + message(STATUS "${configuring_message}-dbg") file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg) vcpkg_execute_required_process( COMMAND ${dbg_command} @@ -361,7 +366,7 @@ function(vcpkg_configure_cmake) endif() if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") - message(STATUS "Configuring ${TARGET_TRIPLET}-rel") + message(STATUS "${configuring_message}-rel") file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel) vcpkg_execute_required_process( COMMAND ${rel_command} @@ -408,5 +413,7 @@ Please recheck them and remove the unnecessary options from the `vcpkg_configure If these options should still be passed for whatever reason, please use the `MAYBE_UNUSED_VARIABLES` argument.") endif() - set(Z_VCPKG_CMAKE_GENERATOR "${GENERATOR}" PARENT_SCOPE) + if(NOT arg_Z_GET_CMAKE_VARS_USAGE) + set(Z_VCPKG_CMAKE_GENERATOR "${GENERATOR}" PARENT_SCOPE) + endif() endfunction() diff --git a/scripts/cmake/vcpkg_configure_make.cmake b/scripts/cmake/vcpkg_configure_make.cmake index 65d66daac9..f9a0426609 100644 --- a/scripts/cmake/vcpkg_configure_make.cmake +++ b/scripts/cmake/vcpkg_configure_make.cmake @@ -236,10 +236,9 @@ function(vcpkg_configure_make) "SOURCE_PATH;PROJECT_SUBPATH;PRERUN_SHELL;BUILD_TRIPLET" "OPTIONS;OPTIONS_DEBUG;OPTIONS_RELEASE;CONFIGURE_ENVIRONMENT_VARIABLES;CONFIG_DEPENDENT_ENVIRONMENT;ADDITIONAL_MSYS_PACKAGES" ) - vcpkg_internal_get_cmake_vars(OUTPUT_FILE _VCPKG_CMAKE_VARS_FILE) - set(_VCPKG_CMAKE_VARS_FILE "${_VCPKG_CMAKE_VARS_FILE}" PARENT_SCOPE) - debug_message("Including cmake vars from: ${_VCPKG_CMAKE_VARS_FILE}") - include("${_VCPKG_CMAKE_VARS_FILE}") + z_vcpkg_get_cmake_vars(cmake_vars_file) + debug_message("Including cmake vars from: ${cmake_vars_file}") + include("${cmake_vars_file}") if(DEFINED VCPKG_MAKE_BUILD_TRIPLET) set(_csc_BUILD_TRIPLET ${VCPKG_MAKE_BUILD_TRIPLET}) # Triplet overwrite for crosscompiling endif() diff --git a/scripts/cmake/vcpkg_configure_meson.cmake b/scripts/cmake/vcpkg_configure_meson.cmake index 2ee8266b9b..5bb34089c1 100644 --- a/scripts/cmake/vcpkg_configure_meson.cmake +++ b/scripts/cmake/vcpkg_configure_meson.cmake @@ -356,10 +356,9 @@ function(vcpkg_configure_meson) file(REMOVE_RECURSE "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel") file(REMOVE_RECURSE "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg") - vcpkg_internal_get_cmake_vars(OUTPUT_FILE _VCPKG_CMAKE_VARS_FILE) - set(_VCPKG_CMAKE_VARS_FILE "${_VCPKG_CMAKE_VARS_FILE}" PARENT_SCOPE) - debug_message("Including cmake vars from: ${_VCPKG_CMAKE_VARS_FILE}") - include("${_VCPKG_CMAKE_VARS_FILE}") + z_vcpkg_get_cmake_vars(cmake_vars_file) + debug_message("Including cmake vars from: ${cmake_vars_file}") + include("${cmake_vars_file}") vcpkg_find_acquire_program(PYTHON3) get_filename_component(PYTHON3_DIR "${PYTHON3}" DIRECTORY) diff --git a/scripts/cmake/vcpkg_copy_pdbs.cmake b/scripts/cmake/vcpkg_copy_pdbs.cmake index dd489db021..60335255a1 100644 --- a/scripts/cmake/vcpkg_copy_pdbs.cmake +++ b/scripts/cmake/vcpkg_copy_pdbs.cmake @@ -27,15 +27,18 @@ This command should always be called by portfiles after they have finished rearr function(vcpkg_copy_pdbs) cmake_parse_arguments(PARSE_ARGV 0 "arg" "" "" "BUILD_PATHS") + if(DEFINED arg_UNPARSED_ARGUMENTS) + message(WARNING "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}") + endif() + if(NOT DEFINED arg_BUILD_PATHS) - set( - arg_BUILD_PATHS + set(arg_BUILD_PATHS "${CURRENT_PACKAGES_DIR}/bin/*.dll" "${CURRENT_PACKAGES_DIR}/debug/bin/*.dll" ) endif() - set(dlls_without_matching_pdbs) + set(dlls_without_matching_pdbs "") if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic" AND VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW) file(GLOB_RECURSE dlls ${arg_BUILD_PATHS}) @@ -44,17 +47,16 @@ function(vcpkg_copy_pdbs) set(ENV{VSLANG} 1033) foreach(dll IN LISTS dlls) - execute_process(COMMAND dumpbin /PDBPATH ${dll} + execute_process(COMMAND dumpbin /PDBPATH "${dll}" COMMAND findstr PDB OUTPUT_VARIABLE pdb_line ERROR_QUIET RESULT_VARIABLE error_code ) - if(NOT error_code AND pdb_line MATCHES "PDB file found at") - string(REGEX MATCH [['.*']] pdb_path "${pdb_line}") # Extract the path which is in single quotes - string(REPLACE "'" "" pdb_path "${pdb_path}") # Remove single quotes - get_filename_component(dll_dir "${dll}" DIRECTORY) + if(error_code EQUAL "0" AND pdb_line MATCHES "PDB file found at.*'(.*)'") + set(pdb_path "${CMAKE_MATCH_1}") + cmake_path(GET dll PARENT_PATH dll_dir) file(COPY "${pdb_path}" DESTINATION "${dll_dir}") else() list(APPEND dlls_without_matching_pdbs "${dll}") @@ -63,10 +65,10 @@ function(vcpkg_copy_pdbs) set(ENV{VSLANG} "${vslang_backup}") - list(LENGTH dlls_without_matching_pdbs unmatched_dlls_length) - if(unmatched_dlls_length GREATER 0) + if(NOT unmatched_dlls_length STREQUAL "") list(JOIN dlls_without_matching_pdbs "\n " message) - message(WARNING "Could not find a matching pdb file for:${message}\n") + message(WARNING "Could not find a matching pdb file for: + ${message}\n") endif() endif() diff --git a/scripts/cmake/vcpkg_copy_tool_dependencies.cmake b/scripts/cmake/vcpkg_copy_tool_dependencies.cmake index 0cb0bbcefb..856a2d7fe2 100644 --- a/scripts/cmake/vcpkg_copy_tool_dependencies.cmake +++ b/scripts/cmake/vcpkg_copy_tool_dependencies.cmake @@ -19,29 +19,31 @@ This command should always be called by portfiles after they have finished rearr * [fltk](https://github.com/Microsoft/vcpkg/blob/master/ports/fltk/portfile.cmake) #]===] -function(vcpkg_copy_tool_dependencies TOOL_DIR) - if (VCPKG_TARGET_IS_WINDOWS) - find_program(PWSH_EXE pwsh) - if (NOT PWSH_EXE) - if(UNIX AND NOT CYGWIN) - message(FATAL_ERROR "Could not find PowerShell Core; install PowerShell Core as described here: https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-core-on-linux") - endif() +function(z_vcpkg_copy_tool_dependencies_search tool_dir path_to_search) + file(GLOB tools "${tool_dir}/*.exe" "${tool_dir}/*.dll" "${tool_dir}/*.pyd") + foreach(tool IN LISTS tools) + vcpkg_execute_required_process( + COMMAND "${Z_VCPKG_POWERSHELL_CORE}" -noprofile -executionpolicy Bypass -nologo + -file "${SCRIPTS}/buildsystems/msbuild/applocal.ps1" + -targetBinary "${tool}" + -installedDir "${path_to_search}" + WORKING_DIRECTORY "${VCPKG_ROOT_DIR}" + LOGNAME copy-tool-dependencies + ) + endforeach() +endfunction() + +function(vcpkg_copy_tool_dependencies tool_dir) + if(ARGC GREATER 1) + message(WARNING "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${ARGN}") + endif() + + if(VCPKG_TARGET_IS_WINDOWS) + find_program(Z_VCPKG_POWERSHELL_CORE pwsh) + if (NOT Z_VCPKG_POWERSHELL_CORE) message(FATAL_ERROR "Could not find PowerShell Core; please open an issue to report this.") endif() - macro(search_for_dependencies PATH_TO_SEARCH) - file(GLOB TOOLS "${TOOL_DIR}/*.exe" "${TOOL_DIR}/*.dll" "${TOOL_DIR}/*.pyd") - foreach(TOOL IN LISTS TOOLS) - vcpkg_execute_required_process( - COMMAND "${PWSH_EXE}" -noprofile -executionpolicy Bypass -nologo - -file "${SCRIPTS}/buildsystems/msbuild/applocal.ps1" - -targetBinary "${TOOL}" - -installedDir "${PATH_TO_SEARCH}" - WORKING_DIRECTORY "${VCPKG_ROOT_DIR}" - LOGNAME copy-tool-dependencies - ) - endforeach() - endmacro() - search_for_dependencies("${CURRENT_PACKAGES_DIR}/bin") - search_for_dependencies("${CURRENT_INSTALLED_DIR}/bin") + z_vcpkg_copy_tool_dependencies_search("${tool_dir}" "${CURRENT_PACKAGES_DIR}/bin") + z_vcpkg_copy_tool_dependencies_search("${tool_dir}" "${CURRENT_INSTALLED_DIR}/bin") endif() endfunction() diff --git a/scripts/cmake/vcpkg_copy_tools.cmake b/scripts/cmake/vcpkg_copy_tools.cmake index 18ddc3715d..ef3259840c 100644 --- a/scripts/cmake/vcpkg_copy_tools.cmake +++ b/scripts/cmake/vcpkg_copy_tools.cmake @@ -33,39 +33,43 @@ Auto clean executables in `${CURRENT_PACKAGES_DIR}/bin` and `${CURRENT_PACKAGES_ #]===] function(vcpkg_copy_tools) - # parse parameters such that semicolons in options arguments to COMMAND don't get erased - cmake_parse_arguments(PARSE_ARGV 0 _vct "AUTO_CLEAN" "SEARCH_DIR;DESTINATION" "TOOL_NAMES") + cmake_parse_arguments(PARSE_ARGV 0 arg "AUTO_CLEAN" "SEARCH_DIR;DESTINATION" "TOOL_NAMES") - if(NOT DEFINED _vct_TOOL_NAMES) + if(DEFINED arg_UNPARSED_ARGUMENTS) + message(WARNING "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}") + endif() + + if(NOT DEFINED arg_TOOL_NAMES) message(FATAL_ERROR "TOOL_NAMES must be specified.") endif() - if(NOT DEFINED _vct_DESTINATION) - set(_vct_DESTINATION "${CURRENT_PACKAGES_DIR}/tools/${PORT}") + if(NOT DEFINED arg_DESTINATION) + set(arg_DESTINATION "${CURRENT_PACKAGES_DIR}/tools/${PORT}") endif() - if(NOT DEFINED _vct_SEARCH_DIR) - set(_vct_SEARCH_DIR "${CURRENT_PACKAGES_DIR}/bin") - elseif(NOT IS_DIRECTORY ${_vct_SEARCH_DIR}) - message(FATAL_ERROR "SEARCH_DIR ${_vct_SEARCH_DIR} is supposed to be a directory.") + if(NOT DEFINED arg_SEARCH_DIR) + set(arg_SEARCH_DIR "${CURRENT_PACKAGES_DIR}/bin") + elseif(NOT IS_DIRECTORY "${arg_SEARCH_DIR}") + message(FATAL_ERROR "SEARCH_DIR (${arg_SEARCH_DIR}) must be a directory") endif() - foreach(tool_name IN LISTS _vct_TOOL_NAMES) - set(tool_path "${_vct_SEARCH_DIR}/${tool_name}${VCPKG_TARGET_EXECUTABLE_SUFFIX}") - set(tool_pdb "${_vct_SEARCH_DIR}/${tool_name}.pdb") + foreach(tool_name IN LISTS arg_TOOL_NAMES) + set(tool_path "${arg_SEARCH_DIR}/${tool_name}${VCPKG_TARGET_EXECUTABLE_SUFFIX}") + set(tool_pdb "${arg_SEARCH_DIR}/${tool_name}.pdb") if(EXISTS "${tool_path}") - file(COPY "${tool_path}" DESTINATION "${_vct_DESTINATION}") + file(COPY "${tool_path}" DESTINATION "${arg_DESTINATION}") else() - message(FATAL_ERROR "Couldn't find this tool: ${tool_path}.") + message(FATAL_ERROR "Couldn't find tool \"${tool_name}\": + \"${tool_path}\" does not exist") endif() if(EXISTS "${tool_pdb}") - file(COPY "${tool_pdb}" DESTINATION "${_vct_DESTINATION}") + file(COPY "${tool_pdb}" DESTINATION "${arg_DESTINATION}") endif() endforeach() - if(_vct_AUTO_CLEAN) - vcpkg_clean_executables_in_bin(FILE_NAMES ${_vct_TOOL_NAMES}) + if(arg_AUTO_CLEAN) + vcpkg_clean_executables_in_bin(FILE_NAMES ${arg_TOOL_NAMES}) endif() - vcpkg_copy_tool_dependencies("${_vct_DESTINATION}") + vcpkg_copy_tool_dependencies("${arg_DESTINATION}") endfunction() diff --git a/scripts/cmake/vcpkg_internal_get_cmake_vars.cmake b/scripts/cmake/vcpkg_internal_get_cmake_vars.cmake deleted file mode 100644 index 030d74120d..0000000000 --- a/scripts/cmake/vcpkg_internal_get_cmake_vars.cmake +++ /dev/null @@ -1,68 +0,0 @@ -#[===[.md: -# vcpkg_internal_get_cmake_vars - -**Only for internal use in vcpkg helpers. Behavior and arguments will change without notice.** -Runs a cmake configure with a dummy project to extract certain cmake variables - -## Usage -```cmake -vcpkg_internal_get_cmake_vars( - [OUTPUT_FILE ] - [OPTIONS <-DUSE_THIS_IN_ALL_BUILDS=1>...] -) -``` - -## Parameters -### OPTIONS -Additional options to pass to the test configure call - -### OUTPUT_FILE -Variable to return the path to the generated cmake file with the detected `CMAKE_` variables set as `VCKPG_DETECTED_` - -## Notes -If possible avoid usage in portfiles. - -## Examples - -* [vcpkg_configure_make](https://github.com/Microsoft/vcpkg/blob/master/scripts/cmake/vcpkg_configure_make.cmake) -#]===] - -function(vcpkg_internal_get_cmake_vars) - cmake_parse_arguments(PARSE_ARGV 0 _gcv "" "OUTPUT_FILE" "OPTIONS") - - if(_gcv_UNPARSED_ARGUMENTS) - message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} was passed unparsed arguments: '${_gcv_UNPARSED_ARGUMENTS}'") - endif() - - if(NOT _gcv_OUTPUT_FILE) - message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} requires parameter OUTPUT_FILE!") - endif() - - if(${_gcv_OUTPUT_FILE}) - debug_message("OUTPUT_FILE ${${_gcv_OUTPUT_FILE}}") - else() - set(DEFAULT_OUT "${CURRENT_BUILDTREES_DIR}/cmake-vars-${TARGET_TRIPLET}.cmake.log") # So that the file gets included in CI artifacts. - set(${_gcv_OUTPUT_FILE} "${DEFAULT_OUT}" PARENT_SCOPE) - set(${_gcv_OUTPUT_FILE} "${DEFAULT_OUT}") - endif() - - vcpkg_configure_cmake( - SOURCE_PATH "${SCRIPTS}/get_cmake_vars" - OPTIONS ${_gcv_OPTIONS} "-DVCPKG_BUILD_TYPE=${VCPKG_BUILD_TYPE}" - OPTIONS_DEBUG "-DVCPKG_OUTPUT_FILE:PATH=${CURRENT_BUILDTREES_DIR}/cmake-vars-${TARGET_TRIPLET}-dbg.cmake.log" - OPTIONS_RELEASE "-DVCPKG_OUTPUT_FILE:PATH=${CURRENT_BUILDTREES_DIR}/cmake-vars-${TARGET_TRIPLET}-rel.cmake.log" - PREFER_NINJA - LOGNAME get-cmake-vars-${TARGET_TRIPLET} - Z_VCPKG_IGNORE_UNUSED_VARIABLES - ) - - set(_include_string) - if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") - string(APPEND _include_string "include(\"${CURRENT_BUILDTREES_DIR}/cmake-vars-${TARGET_TRIPLET}-rel.cmake.log\")\n") - endif() - if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") - string(APPEND _include_string "include(\"${CURRENT_BUILDTREES_DIR}/cmake-vars-${TARGET_TRIPLET}-dbg.cmake.log\")\n") - endif() - file(WRITE "${${_gcv_OUTPUT_FILE}}" "${_include_string}") - -endfunction() diff --git a/scripts/cmake/z_vcpkg_get_cmake_vars.cmake b/scripts/cmake/z_vcpkg_get_cmake_vars.cmake new file mode 100644 index 0000000000..f50b1db26f --- /dev/null +++ b/scripts/cmake/z_vcpkg_get_cmake_vars.cmake @@ -0,0 +1,65 @@ +#[===[.md: +# z_vcpkg_get_cmake_vars + +**Only for internal use in vcpkg helpers. Behavior and arguments will change without notice.** +Runs a cmake configure with a dummy project to extract certain cmake variables + +## Usage +```cmake +z_vcpkg_get_cmake_vars() +``` + +`z_vcpkg_get_cmake_vars(cmake_vars_file)` sets `` to +a path to a generated CMake file, with the detected `CMAKE_*` variables +re-exported as `VCPKG_DETECTED_*`. + +## Notes +Avoid usage in portfiles. + +All calls to `z_vcpkg_get_cmake_vars` will result in the same output file; +the output file is not generated multiple times. + +## Examples + +* [vcpkg_configure_make](https://github.com/Microsoft/vcpkg/blob/master/scripts/cmake/vcpkg_configure_make.cmake) + +### Basic Usage + +```cmake +z_vcpkg_get_cmake_vars(cmake_vars_file) +include("${cmake_vars_file}") +message(STATUS "detected CXX flags: ${VCPKG_DETECTED_CXX_FLAGS}") +``` +#]===] + +function(z_vcpkg_get_cmake_vars out_file) + cmake_parse_arguments(PARSE_ARGV 1 arg "" "" "") + + if(DEFINED arg_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}") + endif() + + if(NOT DEFINED CACHE{Z_VCPKG_GET_CMAKE_VARS_FILE}) + set(Z_VCPKG_GET_CMAKE_VARS_FILE "${CURRENT_BUILDTREES_DIR}/cmake-vars-${TARGET_TRIPLET}.cmake.log" + CACHE PATH "The file to include to access the CMake variables from a generated project.") + vcpkg_configure_cmake( + SOURCE_PATH "${SCRIPTS}/get_cmake_vars" + OPTIONS_DEBUG "-DVCPKG_OUTPUT_FILE:PATH=${CURRENT_BUILDTREES_DIR}/cmake-vars-${TARGET_TRIPLET}-dbg.cmake.log" + OPTIONS_RELEASE "-DVCPKG_OUTPUT_FILE:PATH=${CURRENT_BUILDTREES_DIR}/cmake-vars-${TARGET_TRIPLET}-rel.cmake.log" + PREFER_NINJA + LOGNAME get-cmake-vars-${TARGET_TRIPLET} + Z_GET_CMAKE_VARS_USAGE # ignore vcpkg_cmake_configure, be quiet, don't set variables... + ) + + set(include_string "") + if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") + string(APPEND include_string "include(\"\${CMAKE_CURRENT_LIST_DIR}/cmake-vars-${TARGET_TRIPLET}-rel.cmake.log\")\n") + endif() + if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") + string(APPEND include_string "include(\"\${CMAKE_CURRENT_LIST_DIR}/cmake-vars-${TARGET_TRIPLET}-dbg.cmake.log\")\n") + endif() + file(WRITE "${Z_VCPKG_GET_CMAKE_VARS_FILE}" "${include_string}") + endif() + + set("${out_file}" "${Z_VCPKG_GET_CMAKE_VARS_FILE}" PARENT_SCOPE) +endfunction() diff --git a/scripts/ports.cmake b/scripts/ports.cmake index 98a6e23520..c444634110 100644 --- a/scripts/ports.cmake +++ b/scripts/ports.cmake @@ -129,13 +129,13 @@ if(CMD MATCHES "^BUILD$") include("${SCRIPTS}/cmake/vcpkg_install_msbuild.cmake") include("${SCRIPTS}/cmake/vcpkg_install_nmake.cmake") include("${SCRIPTS}/cmake/vcpkg_install_qmake.cmake") - include("${SCRIPTS}/cmake/vcpkg_internal_get_cmake_vars.cmake") include("${SCRIPTS}/cmake/vcpkg_list.cmake") include("${SCRIPTS}/cmake/vcpkg_replace_string.cmake") include("${SCRIPTS}/cmake/vcpkg_test_cmake.cmake") include("${SCRIPTS}/cmake/z_vcpkg_apply_patches.cmake") include("${SCRIPTS}/cmake/z_vcpkg_forward_output_variable.cmake") + include("${SCRIPTS}/cmake/z_vcpkg_get_cmake_vars.cmake") include("${SCRIPTS}/cmake/z_vcpkg_prettify_command_line.cmake") include("${CURRENT_PORT_DIR}/portfile.cmake") diff --git a/versions/baseline.json b/versions/baseline.json index 08d017fad4..e441a4e159 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -1998,7 +1998,7 @@ }, "ffmpeg": { "baseline": "4.4", - "port-version": 11 + "port-version": 12 }, "ffnvcodec": { "baseline": "10.0.26.0", @@ -6569,8 +6569,8 @@ "port-version": 0 }, "vcpkg-cmake": { - "baseline": "2021-06-25", - "port-version": 5 + "baseline": "2021-07-26", + "port-version": 0 }, "vcpkg-cmake-config": { "baseline": "2021-05-22", diff --git a/versions/f-/ffmpeg.json b/versions/f-/ffmpeg.json index 0897dd09b6..df25f3a826 100644 --- a/versions/f-/ffmpeg.json +++ b/versions/f-/ffmpeg.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "4d910207840ec65730eb972e472dab548fb8b5d2", + "version": "4.4", + "port-version": 12 + }, { "git-tree": "6e44538ad578a511886a010a5485fbe9ab514bf1", "version": "4.4", diff --git a/versions/v-/vcpkg-cmake.json b/versions/v-/vcpkg-cmake.json index c632ab855e..02a8816c1a 100644 --- a/versions/v-/vcpkg-cmake.json +++ b/versions/v-/vcpkg-cmake.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "ae2178d81ee39baf4c7e9fd6ed3f011b01a93635", + "version-date": "2021-07-26", + "port-version": 0 + }, { "git-tree": "07c3e68ce9ae8f30bcc0b21def7a528dbb8ecb07", "version-date": "2021-06-25",