Skip to content

Commit

Permalink
[fix] prebuild set CMAKE_PREFIX_PATH properly (#1154)
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Graeb <[email protected]>
  • Loading branch information
TingDaoK and graebm committed Oct 14, 2024
1 parent dc94351 commit e9f38b9
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions cmake/AwsPrebuildDependency.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ function(aws_prebuild_dependency)
set(depInstallDir ${depBinaryDir}/install)
file(MAKE_DIRECTORY ${depBinaryDir})

# Convert prefix path from list to escaped string, to be passed on command line
string(REPLACE ";" "\\\\;" ESCAPED_PREFIX_PATH "${CMAKE_PREFIX_PATH}")
# 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_PREFIX_PATH=${ESCAPED_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 +41,13 @@ function(aws_prebuild_dependency)
list(APPEND cmakeCommand ${AWS_PREBUILD_CMAKE_ARGUMENTS})
endif()

list(APPEND cmakeCommand WORKING_DIRECTORY ${depBinaryDir})
list(APPEND cmakeCommand RESULT_VARIABLE result)

# 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

0 comments on commit e9f38b9

Please sign in to comment.