Skip to content

Commit b88b893

Browse files
Angelia-Wangjoeyyjwang
andauthored
fix(cmake): generate version.h under PROJECT_BINARY_DIR to support add_subdirectory() builds (#906)
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. Co-authored-by: joeyyjwang <joeyyjwang@tencent.com>
1 parent 8e1cb7a commit b88b893

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎CMakeLists.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ project(Iceberg
3030

3131
include(IcebergBuildUtils)
3232
iceberg_configure_version_header("${CMAKE_CURRENT_SOURCE_DIR}/src/iceberg/version.h.in"
33-
"${CMAKE_BINARY_DIR}/src/iceberg/version.h")
33+
"${PROJECT_BINARY_DIR}/src/iceberg/version.h")
3434

3535
set(CMAKE_CXX_STANDARD 23)
3636
set(CMAKE_CXX_STANDARD_REQUIRED ON)

0 commit comments

Comments
 (0)