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

[fix] prebuild set CMAKE_PREFIX_PATH properly #1154

Merged
merged 7 commits into from
Oct 11, 2024
Merged
Changes from 5 commits
Commits
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
20 changes: 15 additions & 5 deletions cmake/AwsPrebuildDependency.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ function(aws_prebuild_dependency)
file(MAKE_DIRECTORY ${depBinaryDir})

# For execute_process to accept a dynamically constructed command, it should be passed in a list format.
set(cmakeCommand "COMMAND" "${CMAKE_COMMAND}")
set(cmakeCommand "${CMAKE_COMMAND}")
list(APPEND cmakeCommand -S ${AWS_PREBUILD_SOURCE_DIR})
list(APPEND cmakeCommand -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE})
list(APPEND cmakeCommand -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH})
list(APPEND cmakeCommand -DCMAKE_INSTALL_PREFIX=${depInstallDir})
list(APPEND cmakeCommand -DCMAKE_INSTALL_RPATH=${CMAKE_INSTALL_RPATH})
list(APPEND cmakeCommand -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS})
Expand All @@ -39,11 +38,22 @@ function(aws_prebuild_dependency)
list(APPEND cmakeCommand ${AWS_PREBUILD_CMAKE_ARGUMENTS})
endif()

list(APPEND cmakeCommand WORKING_DIRECTORY ${depBinaryDir})
list(APPEND cmakeCommand RESULT_VARIABLE result)
# Set cmake prefix path via envrionment variable incase it's already a list.
# Some version of cmake will treat the values in the list as separate args.
if(WIN32)
list(JOIN CMAKE_PREFIX_PATH ";" PREFIX_PATH_ENV_VAR)
else()
list(JOIN CMAKE_PREFIX_PATH ":" PREFIX_PATH_ENV_VAR)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

list(JOIN) is cmake 3.12+

endif()
set(ENV{CMAKE_PREFIX_PATH} ${PREFIX_PATH_ENV_VAR})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changing an environment variable seems like trouble
try to find a way to continue passing this as arguments
can do something to convince cmake more strongly that we want to treat this as a string, not a list


# Configure dependency project.
execute_process(${cmakeCommand})
execute_process(
COMMAND ${cmakeCommand}
WORKING_DIRECTORY ${depBinaryDir}
RESULT_VARIABLE result
)

if (NOT ${result} EQUAL 0)
message(FATAL_ERROR "Configuration failed for dependency project ${AWS_PREBUILD_DEPENDENCY_NAME}")
endif()
Expand Down
Loading