Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 8 additions & 17 deletions src/iceberg/iceberg-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,14 @@ 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 iceberg_FOUND iceberg_NOT_FOUND_MESSAGE)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PROPAGATE list hard-codes iceberg_FOUND / iceberg_NOT_FOUND_MESSAGE, but find_dependency() sets ${CMAKE_FIND_PACKAGE_NAME}_FOUND / _NOT_FOUND_MESSAGE before return(). CMAKE_FIND_PACKAGE_NAME is the name the caller passed to find_package(). With find_package(Iceberg), Iceberg_FOUND is set inside the block and never reaches the caller. When a dependency is missing, the package is then reported as found with no targets.

Suggested change
block(SCOPE_FOR VARIABLES PROPAGATE iceberg_FOUND iceberg_NOT_FOUND_MESSAGE)
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)
Expand Down
Loading