From fadfef492042ae53387d4369a6de652c930a5be4 Mon Sep 17 00:00:00 2001 From: Michael Graeb Date: Tue, 3 Dec 2024 16:05:05 -0800 Subject: [PATCH] Support relative paths when prebuilding dependencies with CMake (#1174) **Issue:** When aws-crt-java started prebuilding AWS-LC, the release pipeline broke due to a relative path being passed to CMake (see: https://github.com/awslabs/aws-crt-java/pull/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` 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)) --- cmake/AwsPrebuildDependency.cmake | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cmake/AwsPrebuildDependency.cmake b/cmake/AwsPrebuildDependency.cmake index 2637f9594..e9bdbb6f3 100644 --- a/cmake/AwsPrebuildDependency.cmake +++ b/cmake/AwsPrebuildDependency.cmake @@ -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}) @@ -57,7 +58,6 @@ function(aws_prebuild_dependency) # Configure dependency project. execute_process( COMMAND ${cmakeCommand} - WORKING_DIRECTORY ${depBinaryDir} RESULT_VARIABLE result ) @@ -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)