fix(cmake): generate version.h under PROJECT_BINARY_DIR to support add_subdirectory() builds - #906
Merged
wgtmac merged 1 commit intoSep 3, 2026
Conversation
…d_subdirectory() builds
CMakeLists.txt generates the versioned header at
${CMAKE_BINARY_DIR}/src/iceberg/version.h, but the include path used
to compile the iceberg target (ICEBERG_INCLUDES in
src/iceberg/CMakeLists.txt) is ${PROJECT_BINARY_DIR}/src. This change
makes both consistently use PROJECT_BINARY_DIR.
When iceberg-cpp is built as the top-level project, CMAKE_BINARY_DIR
and PROJECT_BINARY_DIR happen to be the same directory, so this
mismatch is invisible.
When iceberg-cpp is consumed via add_subdirectory() from another
CMake project (e.g. vendoring it under third/iceberg-cpp/),
CMAKE_BINARY_DIR resolves to the outermost project's build directory,
while PROJECT_BINARY_DIR correctly resolves to the build directory
nested under the outer project (e.g.
<outer_build_dir>/third/iceberg-cpp/). The generated version.h then
ends up in the wrong place and any translation unit that does
#include "iceberg/version.h" (e.g. catalog/rest/constant.h,
deletes/dv_util.cc, deletes/dv_writer.cc) fails with a missing header
when building as a nested dependency.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
CMakeLists.txtgenerates the versioned header at${CMAKE_BINARY_DIR}/src/iceberg/version.h, but the include path used to compile theicebergtarget (ICEBERG_INCLUDESinsrc/iceberg/CMakeLists.txt) is${PROJECT_BINARY_DIR}/src. This change makes both consistently usePROJECT_BINARY_DIR.Why
When iceberg-cpp is built as the top-level project,
CMAKE_BINARY_DIRandPROJECT_BINARY_DIRhappen to be the same directory, so this mismatch is invisible.When iceberg-cpp is consumed via
add_subdirectory()from another CMake project (e.g. vendoring it underthird/iceberg-cpp/),CMAKE_BINARY_DIRresolves to the outermost project's build directory, whilePROJECT_BINARY_DIRcorrectly resolves to the build directory nested under the outer project (e.g.<outer_build_dir>/third/iceberg-cpp/). The generatedversion.hthen ends up in the wrong place and any translation unit that does#include "iceberg/version.h"(e.g.catalog/rest/constant.h,deletes/dv_util.cc,deletes/dv_writer.cc) fails with a missing header when building as a nested dependency.How
Use
PROJECT_BINARY_DIRinstead ofCMAKE_BINARY_DIRas the output path passed toiceberg_configure_version_header(), matching the directory already used byICEBERG_INCLUDES.Testing
CMAKE_BINARY_DIR == PROJECT_BINARY_DIRat the top level.add_subdirectory()from an external CMake project; the build previously failed to locateiceberg/version.hand now succeeds.