Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forward CMake variables to prebuilding dependencies #1161

Merged
merged 31 commits into from
Nov 26, 2024
Merged
Changes from 4 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
2098e1c
Add cmake function to gather cmd arguments
sfodagain Oct 23, 2024
b107785
Merge branch 'main' into add-cmake-cmd-args
sfod Oct 29, 2024
917e24c
Add VARS_TO_IGNORE
sfodagain Nov 4, 2024
ceed439
Merge branch 'main' into add-cmake-cmd-args
sfodagain Nov 4, 2024
3b06022
Add aws_get_cmd_arguments_for_prebuild_dependency
sfodagain Nov 7, 2024
d1fa8fa
fixup
sfodagain Nov 7, 2024
921950a
Debugging
sfodagain Nov 7, 2024
f2cd1e7
Simplify aws_get_cmd_arguments_for_prebuild_dependency
sfodagain Nov 8, 2024
70ec6a2
Add CMAKE_C_FLAGS, remove COMMAND_ECHO
sfodagain Nov 8, 2024
4e855e9
Restore passing AWS_PREBUILD_CMAKE_ARGUMENTS
sfodagain Nov 8, 2024
4c034b6
Remove separate aws_get_cmd_arguments
sfodagain Nov 8, 2024
058fdaa
Pass CMAKE_GENERATOR
sfodagain Nov 8, 2024
a13540b
Set CMAKE_FIND_ROOT_PATH
sfodagain Nov 8, 2024
9344a01
Rephrase comment
sfodagain Nov 9, 2024
cdb20c2
Do not parse cmd vars
sfodagain Nov 13, 2024
31095b8
Merge branch 'main' into add-cmake-cmd-args
sfodagain Nov 13, 2024
154317e
Merge branch 'main' into add-cmake-cmd-args
sfod Nov 13, 2024
b567baf
Cleanup
sfodagain Nov 14, 2024
f4771da
Check CMAKE_CROSSOMPILING
sfodagain Nov 14, 2024
625ba4f
Check platform
sfodagain Nov 14, 2024
a30b5f5
Check if CMAKE_GENERATOR is set
sfodagain Nov 14, 2024
aeb891e
Rephrase comment
sfodagain Nov 14, 2024
c6cb3cd
Extract cross-compiling vars
sfodagain Nov 14, 2024
2022b24
Fix comment
sfodagain Nov 14, 2024
3944483
fixup
sfodagain Nov 14, 2024
867d0a5
Update cmake/AwsPrebuildDependency.cmake
sfod Nov 25, 2024
9f55dc9
Remove excess var
sfodagain Nov 25, 2024
4e3efd4
Merge branch 'main' into add-cmake-cmd-args
sfodagain Nov 25, 2024
23bae32
Add linker flags
sfodagain Nov 25, 2024
2daea27
Add non-empty vars
sfodagain Nov 25, 2024
8f8067c
Merge branch 'main' into add-cmake-cmd-args
sfod Nov 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions cmake/AwsGetCmdArguments.cmake
graebm marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0.

# Get list of variables provided via command line arguments (i.e. -DVARIABLE=VALUE). This function iterates over all
# variables and determines if they're provided via command line or not by checking their help strings. CMake sets help
# 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
sfod marked this conversation as resolved.
Show resolved Hide resolved
# 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
sfod marked this conversation as resolved.
Show resolved Hide resolved
# (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()

if (AWS_CMAKE_CMD_ARGS)
message(STATUS "AWS_CMAKE_CMD_ARGS variable is already set, resetting it")
set(AWS_CMAKE_CMD_ARGS "")
endif()

get_cmake_property(vars CACHE_VARIABLES)
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}}")
list(APPEND AWS_CMAKE_CMD_ARGS "-D${var}=${escaped_var}")
endif()
endforeach()
# Store cmd variables in the cache.
set(AWS_CMAKE_CMD_ARGS ${AWS_CMAKE_CMD_ARGS} CACHE STRING "Command line variables" FORCE)
endfunction()
Loading