Skip to content

Commit

Permalink
Add VARS_TO_IGNORE
Browse files Browse the repository at this point in the history
  • Loading branch information
sfodagain committed Nov 4, 2024
1 parent b107785 commit 917e24c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cmake/AwsGetCmdArguments.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,22 @@
# strings for variables provided via command line to the "No help, variable specified on the command line." phrase since
# at least v3.0.
# Via https://cmake.org/pipermail/cmake/2018-January/067002.html
# Arguments:
# VARS_TO_IGNORE Variables that should be ignored even if they were provided via command line. Multiple variables can
# be specified separated by space.
#
# MUST be done before call to 'project'. The reason is that project() resets help strings for some variables
# (e.g. CMAKE_INSTALL_PREFIX).
#
# Populate AWS_CMAKE_CMD_ARGS with command line variables and their values.
function(aws_get_cmd_arguments)
set(multiValueArgs VARS_TO_IGNORE)
cmake_parse_arguments(AWS_GET_CMD_ARGS "" "" "${multiValueArgs}" ${ARGN})

if (AWS_GET_CMD_ARGS_VARS_TO_IGNORE)
message(STATUS "Ignored vars: ${AWS_GET_CMD_ARGS_VARS_TO_IGNORE}")
endif()

if (PROJECT_NAME)
message(WARNING "aws_get_cmd_arguments is called after project(), some variables may be missed")
endif()
Expand All @@ -25,6 +35,9 @@ function(aws_get_cmd_arguments)
foreach(var ${vars})
get_property(currentHelpString CACHE "${var}" PROPERTY HELPSTRING)
if ("${currentHelpString}" MATCHES "No help, variable specified on the command line.")
if("${var}" IN_LIST AWS_GET_CMD_ARGS_VARS_TO_IGNORE)
continue()
endif()
set(escaped_var ${${var}})
# To store a list within another list, it needs to be escaped first.
string(REPLACE ";" "\\\\;" escaped_var "${${var}}")
Expand Down

0 comments on commit 917e24c

Please sign in to comment.