From a59b766cde6de65a46d7d442363165602d2d29c8 Mon Sep 17 00:00:00 2001 From: Dengke Date: Thu, 10 Oct 2024 14:32:32 -0700 Subject: [PATCH 1/7] try to fix prebuild --- cmake/AwsPrebuildDependency.cmake | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/cmake/AwsPrebuildDependency.cmake b/cmake/AwsPrebuildDependency.cmake index c0048f20a..bbeac61e6 100644 --- a/cmake/AwsPrebuildDependency.cmake +++ b/cmake/AwsPrebuildDependency.cmake @@ -26,7 +26,7 @@ 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}) @@ -39,11 +39,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() From fc208947ea2d275a00572628eeef8e660bcee9f6 Mon Sep 17 00:00:00 2001 From: Dengke Date: Thu, 10 Oct 2024 14:40:02 -0700 Subject: [PATCH 2/7] print out the dir --- cmake/AwsPrebuildDependency.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/AwsPrebuildDependency.cmake b/cmake/AwsPrebuildDependency.cmake index bbeac61e6..5bb6c7d87 100644 --- a/cmake/AwsPrebuildDependency.cmake +++ b/cmake/AwsPrebuildDependency.cmake @@ -24,7 +24,7 @@ function(aws_prebuild_dependency) set(depBinaryDir ${CMAKE_BINARY_DIR}/deps/${AWS_PREBUILD_DEPENDENCY_NAME}) set(depInstallDir ${depBinaryDir}/install) file(MAKE_DIRECTORY ${depBinaryDir}) - + message(STATUS "XXXXXXXXXXXX depBinaryDir ${depBinaryDir}") # For execute_process to accept a dynamically constructed command, it should be passed in a list format. set(cmakeCommand "${CMAKE_COMMAND}") list(APPEND cmakeCommand -S ${AWS_PREBUILD_SOURCE_DIR}) From 26986bc715f25a64645c242deab2c03153dc6ccf Mon Sep 17 00:00:00 2001 From: Dengke Date: Thu, 10 Oct 2024 14:46:47 -0700 Subject: [PATCH 3/7] add -B? --- cmake/AwsPrebuildDependency.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/AwsPrebuildDependency.cmake b/cmake/AwsPrebuildDependency.cmake index 5bb6c7d87..5c5da5332 100644 --- a/cmake/AwsPrebuildDependency.cmake +++ b/cmake/AwsPrebuildDependency.cmake @@ -28,6 +28,7 @@ function(aws_prebuild_dependency) # For execute_process to accept a dynamically constructed command, it should be passed in a list format. set(cmakeCommand "${CMAKE_COMMAND}") list(APPEND cmakeCommand -S ${AWS_PREBUILD_SOURCE_DIR}) + list(APPEND cmakeCommand -B ${depBinaryDir}) 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}) From c4d24392c30daaf9c67438f78b78d47c34abddd9 Mon Sep 17 00:00:00 2001 From: Dengke Date: Thu, 10 Oct 2024 14:52:43 -0700 Subject: [PATCH 4/7] remove the debug message --- cmake/AwsPrebuildDependency.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/cmake/AwsPrebuildDependency.cmake b/cmake/AwsPrebuildDependency.cmake index 5c5da5332..766d6cc42 100644 --- a/cmake/AwsPrebuildDependency.cmake +++ b/cmake/AwsPrebuildDependency.cmake @@ -24,7 +24,6 @@ function(aws_prebuild_dependency) set(depBinaryDir ${CMAKE_BINARY_DIR}/deps/${AWS_PREBUILD_DEPENDENCY_NAME}) set(depInstallDir ${depBinaryDir}/install) file(MAKE_DIRECTORY ${depBinaryDir}) - message(STATUS "XXXXXXXXXXXX depBinaryDir ${depBinaryDir}") # For execute_process to accept a dynamically constructed command, it should be passed in a list format. set(cmakeCommand "${CMAKE_COMMAND}") list(APPEND cmakeCommand -S ${AWS_PREBUILD_SOURCE_DIR}) From d89397a1d3376f0760fe5e3691a2a4aa563149fb Mon Sep 17 00:00:00 2001 From: Dengke Date: Thu, 10 Oct 2024 16:08:03 -0700 Subject: [PATCH 5/7] another way to fix it --- cmake/AwsPrebuildDependency.cmake | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cmake/AwsPrebuildDependency.cmake b/cmake/AwsPrebuildDependency.cmake index 766d6cc42..61f6dee93 100644 --- a/cmake/AwsPrebuildDependency.cmake +++ b/cmake/AwsPrebuildDependency.cmake @@ -24,12 +24,11 @@ function(aws_prebuild_dependency) set(depBinaryDir ${CMAKE_BINARY_DIR}/deps/${AWS_PREBUILD_DEPENDENCY_NAME}) set(depInstallDir ${depBinaryDir}/install) file(MAKE_DIRECTORY ${depBinaryDir}) + # For execute_process to accept a dynamically constructed command, it should be passed in a list format. set(cmakeCommand "${CMAKE_COMMAND}") list(APPEND cmakeCommand -S ${AWS_PREBUILD_SOURCE_DIR}) - list(APPEND cmakeCommand -B ${depBinaryDir}) 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}) @@ -39,6 +38,15 @@ function(aws_prebuild_dependency) list(APPEND cmakeCommand ${AWS_PREBUILD_CMAKE_ARGUMENTS}) endif() + # 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) + endif() + set(ENV{CMAKE_PREFIX_PATH} ${PREFIX_PATH_ENV_VAR}) + # Configure dependency project. execute_process( COMMAND ${cmakeCommand} From 4765474e1fe351619715bac9ad54d0a22cf1be58 Mon Sep 17 00:00:00 2001 From: Dengke Date: Fri, 11 Oct 2024 13:20:27 -0700 Subject: [PATCH 6/7] escape instead of setting the env var --- cmake/AwsPrebuildDependency.cmake | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/cmake/AwsPrebuildDependency.cmake b/cmake/AwsPrebuildDependency.cmake index 61f6dee93..2ad885811 100644 --- a/cmake/AwsPrebuildDependency.cmake +++ b/cmake/AwsPrebuildDependency.cmake @@ -25,10 +25,14 @@ function(aws_prebuild_dependency) set(depInstallDir ${depBinaryDir}/install) file(MAKE_DIRECTORY ${depBinaryDir}) + # Conver the prefix path from list to escaped string to be passed as value used by + # `-DCMAKE_PREFIX_PATH` for the subprecoess + string(REPLACE ";" "\\\\;" ESCAPDED_PREFIX_PATH "${CMAKE_PREFIX_PATH}") # For execute_process to accept a dynamically constructed command, it should be passed in a list format. 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=${ESCAPDED_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}) @@ -38,15 +42,6 @@ function(aws_prebuild_dependency) list(APPEND cmakeCommand ${AWS_PREBUILD_CMAKE_ARGUMENTS}) endif() - # 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) - endif() - set(ENV{CMAKE_PREFIX_PATH} ${PREFIX_PATH_ENV_VAR}) - # Configure dependency project. execute_process( COMMAND ${cmakeCommand} From 7310e922cd38e58a3d1474567d01e9fb4ebdbd6a Mon Sep 17 00:00:00 2001 From: Dengke Tang Date: Fri, 11 Oct 2024 14:43:31 -0700 Subject: [PATCH 7/7] Apply suggestions from code review Co-authored-by: Michael Graeb --- cmake/AwsPrebuildDependency.cmake | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cmake/AwsPrebuildDependency.cmake b/cmake/AwsPrebuildDependency.cmake index 2ad885811..598ea2aa4 100644 --- a/cmake/AwsPrebuildDependency.cmake +++ b/cmake/AwsPrebuildDependency.cmake @@ -25,14 +25,13 @@ function(aws_prebuild_dependency) set(depInstallDir ${depBinaryDir}/install) file(MAKE_DIRECTORY ${depBinaryDir}) - # Conver the prefix path from list to escaped string to be passed as value used by - # `-DCMAKE_PREFIX_PATH` for the subprecoess - string(REPLACE ";" "\\\\;" ESCAPDED_PREFIX_PATH "${CMAKE_PREFIX_PATH}") + # 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 "${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=${ESCAPDED_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})