Skip to content

Commit

Permalink
Support relative paths when prebuilding dependencies with CMake (#1174)
Browse files Browse the repository at this point in the history
**Issue:**
When aws-crt-java started prebuilding AWS-LC, the release pipeline  broke due to a relative path being passed to CMake (see: awslabs/aws-crt-java#851)

Since the AwsPrebuildDependency changed the working directory while running CMake, the relative path became invalid.

**Description of changes:**
Instead of changing the working directory while running CMake, use the `-B<path-to-build>` option (which exists prior to CMake 3.13 even though it's not documented, note that it's a bit weird pre-3.13 with no space after the B))
  • Loading branch information
graebm authored Dec 4, 2024
1 parent 0226008 commit fadfef4
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions cmake/AwsPrebuildDependency.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ function(aws_prebuild_dependency)
list(APPEND cmakeCommand ${cmakeOptionalVariables})

# The following variables should always be used.
list(APPEND cmakeCommand -B${depBinaryDir})
list(APPEND cmakeCommand ${AWS_PREBUILD_SOURCE_DIR})
list(APPEND cmakeCommand -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE})
list(APPEND cmakeCommand -DCMAKE_PREFIX_PATH=${ESCAPED_PREFIX_PATH})
Expand All @@ -57,7 +58,6 @@ function(aws_prebuild_dependency)
# Configure dependency project.
execute_process(
COMMAND ${cmakeCommand}
WORKING_DIRECTORY ${depBinaryDir}
RESULT_VARIABLE result
)

Expand All @@ -67,8 +67,7 @@ function(aws_prebuild_dependency)

# Build and install dependency project into depInstallDir directory.
execute_process(
COMMAND ${CMAKE_COMMAND} --build . --target install
WORKING_DIRECTORY ${depBinaryDir}
COMMAND ${CMAKE_COMMAND} --build ${depBinaryDir} --target install
RESULT_VARIABLE result
)
if (NOT ${result} EQUAL 0)
Expand Down

0 comments on commit fadfef4

Please sign in to comment.