diff options
| author | nicole mazzuca <83086508+strega-nil-ms@users.noreply.github.com> | 2021-07-20 12:24:58 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-07-20 10:24:58 -0700 |
| commit | 0e1dc121856eef84bf1852134e548bf9898dabac (patch) | |
| tree | 4bbae150d61121c81c33a2f4b7b92063e4db3060 /scripts/cmake/vcpkg_configure_cmake.cmake | |
| parent | b67fab9861239e33b722b9a44f5c96dec6ca807e (diff) | |
| download | vcpkg-0e1dc121856eef84bf1852134e548bf9898dabac.tar.gz vcpkg-0e1dc121856eef84bf1852134e548bf9898dabac.zip | |
[rollup] Rollup PR 2021-07-16 (#19001)
* [rollup:2021-07-16 1/7] PR #18201 (@JackBoosY)
[vcpkg-cmake] Add check for unused cmake variables
* [rollup:2021-07-16 2/7] PR #18397 (@strega-nil)
[vcpkg_list] add new function
* [rollup:2021-07-16 3/7] PR #18782 (@strega-nil)
[scripts-audit] vcpkg_build_ninja
* [rollup:2021-07-16 4/7] PR #18784 (@strega-nil)
[scripts-audit] vcpkg_minimum_required
* [rollup:2021-07-16 5/7] PR #18785 (@strega-nil)
[scripts-audit] vcpkg_replace_string
* [rollup:2021-07-16 6/7] PR #18786 (@strega-nil)
[scripts-audit] windows scripts
* [rollup:2021-07-16 7/7] PR #18945 (@strega-nil)
[many ports] remove deprecated vcpkg_check_features call [1/5]
Co-authored-by: nicole mazzuca <mazzucan@outlook.com>
Co-authored-by: PhoebeHui <20694052+PhoebeHui@users.noreply.github.com>
Diffstat (limited to 'scripts/cmake/vcpkg_configure_cmake.cmake')
| -rw-r--r-- | scripts/cmake/vcpkg_configure_cmake.cmake | 64 |
1 files changed, 62 insertions, 2 deletions
diff --git a/scripts/cmake/vcpkg_configure_cmake.cmake b/scripts/cmake/vcpkg_configure_cmake.cmake index 1eb50e852..bce3f6af5 100644 --- a/scripts/cmake/vcpkg_configure_cmake.cmake +++ b/scripts/cmake/vcpkg_configure_cmake.cmake @@ -15,6 +15,7 @@ vcpkg_configure_cmake( [OPTIONS <-DUSE_THIS_IN_ALL_BUILDS=1>...] [OPTIONS_RELEASE <-DOPTIMIZE=1>...] [OPTIONS_DEBUG <-DDEBUGGABLE=1>...] + [MAYBE_UNUSED_VARIABLES <option-name>...] ) ``` @@ -53,6 +54,9 @@ Additional options passed to CMake during the Release configuration. These are i ### OPTIONS_DEBUG Additional options passed to CMake during the Debug configuration. These are in addition to `OPTIONS`. +### MAYBE_UNUSED_VARIABLES +Any CMake variables which are explicitly passed in, but which may not be used on all platforms. + ### LOGNAME Name of the log to write the output of the configure call to. @@ -73,9 +77,9 @@ function(vcpkg_configure_cmake) endif() cmake_parse_arguments(PARSE_ARGV 0 arg - "PREFER_NINJA;DISABLE_PARALLEL_CONFIGURE;NO_CHARSET_FLAG" + "PREFER_NINJA;DISABLE_PARALLEL_CONFIGURE;NO_CHARSET_FLAG;Z_VCPKG_IGNORE_UNUSED_VARIABLES" "SOURCE_PATH;GENERATOR;LOGNAME" - "OPTIONS;OPTIONS_DEBUG;OPTIONS_RELEASE" + "OPTIONS;OPTIONS_DEBUG;OPTIONS_RELEASE;MAYBE_UNUSED_VARIABLES" ) if(NOT VCPKG_PLATFORM_TOOLSET) @@ -87,6 +91,18 @@ function(vcpkg_configure_cmake) set(arg_LOGNAME config-${TARGET_TRIPLET}) endif() + set(manually_specified_variables "") + if(NOT arg_Z_VCPKG_IGNORE_UNUSED_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}") + endif() + if(CMAKE_HOST_WIN32) if(DEFINED ENV{PROCESSOR_ARCHITEW6432}) set(arg_HOST_ARCHITECTURE $ENV{PROCESSOR_ARCHITEW6432}) @@ -326,6 +342,10 @@ function(vcpkg_configure_cmake) WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/vcpkg-parallel-configure LOGNAME ${arg_LOGNAME} ) + + list(APPEND config_logs + "${CURRENT_BUILDTREES_DIR}/${arg_LOGNAME}-out.log" + "${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") @@ -335,6 +355,9 @@ function(vcpkg_configure_cmake) WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg LOGNAME ${arg_LOGNAME}-dbg ) + list(APPEND config_logs + "${CURRENT_BUILDTREES_DIR}/${arg_LOGNAME}-dbg-out.log" + "${CURRENT_BUILDTREES_DIR}/${arg_LOGNAME}-dbg-err.log") endif() if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") @@ -345,7 +368,44 @@ function(vcpkg_configure_cmake) WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel LOGNAME ${arg_LOGNAME}-rel ) + list(APPEND config_logs + "${CURRENT_BUILDTREES_DIR}/${arg_LOGNAME}-rel-out.log" + "${CURRENT_BUILDTREES_DIR}/${arg_LOGNAME}-rel-err.log") + endif() + endif() + + # Check unused variables + set(all_unused_variables) + foreach(config_log IN LISTS config_logs) + if (NOT EXISTS "${config_log}") + continue() + endif() + file(READ "${config_log}" log_contents) + debug_message("Reading configure log ${config_log}...") + if(NOT log_contents MATCHES "Manually-specified variables were not used by the project:\n\n(( [^\n]*\n)*)") + continue() endif() + string(STRIP "${CMAKE_MATCH_1}" unused_variables) # remove leading ` ` and trailing `\n` + string(REPLACE "\n " ";" unused_variables "${unused_variables}") + debug_message("unused variables: ${unused_variables}") + + foreach(unused_variable IN LISTS unused_variables) + if(unused_variable IN_LIST manually_specified_variables) + debug_message("manually specified unused variable: ${unused_variable}") + list(APPEND all_unused_variables "${unused_variable}") + else() + debug_message("unused variable (not manually specified): ${unused_variable}") + endif() + endforeach() + endforeach() + + if(DEFINED all_unused_variables) + list(REMOVE_DUPLICATES all_unused_variables) + list(JOIN all_unused_variables "\n " all_unused_variables) + message(WARNING "The following variables are not used in CMakeLists.txt: + ${all_unused_variables} +Please recheck them and remove the unnecessary options from the `vcpkg_configure_cmake` call. +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) |
