This is an automated email from the ASF dual-hosted git repository.
wgtmac pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-cpp.git
The following commit(s) were added to refs/heads/main by this push:
new cda82440 fix(cmake): preserve module path when dependency discovery
fails (#1097)
cda82440 is described below
commit cda824400a9032b72850d92df507009da80cebe5
Author: Gang Wu <[email protected]>
AuthorDate: Mon Nov 9 11:02:23 2026 +0800
fix(cmake): preserve module path when dependency discovery fails (#1097)
Co-authored-by: Junwang Zhao <[email protected]>
---
src/iceberg/iceberg-config.cmake.in | 27 ++++++++++-----------------
1 file changed, 10 insertions(+), 17 deletions(-)
diff --git a/src/iceberg/iceberg-config.cmake.in
b/src/iceberg/iceberg-config.cmake.in
index 4f440362..47143a15 100644
--- a/src/iceberg/iceberg-config.cmake.in
+++ b/src/iceberg/iceberg-config.cmake.in
@@ -47,23 +47,16 @@ set(ICEBERG_FIND_EXTRA_ARGS_AWSSDK
"@ICEBERG_FIND_EXTRA_ARGS_AWSSDK@")
include(CMakeFindDependencyMacro)
macro(iceberg_find_dependencies dependencies)
- if(DEFINED CMAKE_MODULE_PATH)
- set(ICEBERG_CMAKE_MODULE_PATH_OLD ${CMAKE_MODULE_PATH})
- else()
- unset(ICEBERG_CMAKE_MODULE_PATH_OLD)
- endif()
- set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
-
- foreach(dependency ${dependencies})
- find_dependency(${dependency} ${ICEBERG_FIND_EXTRA_ARGS_${dependency}})
- endforeach()
-
- if(DEFINED ICEBERG_CMAKE_MODULE_PATH_OLD)
- set(CMAKE_MODULE_PATH ${ICEBERG_CMAKE_MODULE_PATH_OLD})
- unset(ICEBERG_CMAKE_MODULE_PATH_OLD)
- else()
- unset(CMAKE_MODULE_PATH)
- endif()
+ # find_dependency() returns from this file when a dependency is not found.
+ # Keep changes to CMAKE_MODULE_PATH local even on that early return.
+ block(SCOPE_FOR VARIABLES
+ PROPAGATE ${CMAKE_FIND_PACKAGE_NAME}_FOUND
+
${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE)
+ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
+ foreach(dependency ${dependencies})
+ find_dependency(${dependency} ${ICEBERG_FIND_EXTRA_ARGS_${dependency}})
+ endforeach()
+ endblock()
endmacro()
macro(iceberg_find_components components)