From 7598038b12d9013dde68ac63f750280d7d65e66c Mon Sep 17 00:00:00 2001 From: Kaushik Iska Date: Wed, 19 Aug 2026 13:14:53 -0500 Subject: [PATCH] Replace git submodules with pinned CMake FetchContent ClickHouse consumes this repository as a submodule and builds it with its own contrib CMake. The nested zlib, googletest, and clickhouse-cpp submodules (used only for this repository's own build and tests) made main unusable as a direct submodule pin: ClickHouse must not carry recursive submodules, which forced a separately maintained remove-recursive-submodules integration branch that had to be advanced by hand after every change. Fetch the three dependencies with FetchContent instead, pinned to the exact commits the submodules tracked, using GitHub archive tarballs so configure needs no git. The Populate-then-add_subdirectory form keeps EXCLUDE_FROM_ALL semantics (and zlib's install rules out of our install tree) while staying compatible with the project's CMake 3.16 minimum. With no .gitmodules left, a plain clone builds and ClickHouse can pin main directly; the integration branch becomes unnecessary. Former submodule paths are gitignored so existing checkouts stay clean. --- .gitignore | 6 +++++- .gitmodules | 9 --------- CMakeLists.txt | 2 +- DEVELOPMENT.md | 2 +- scripts/build.py | 4 ++-- third_party/clickhouse-cmake/CMakeLists.txt | 17 +++++++++++++---- third_party/clickhouse-cpp | 1 - third_party/googletest | 1 - third_party/googletest-cmake/CMakeLists.txt | 16 +++++++++++----- third_party/zlib | 1 - third_party/zlib-cmake/CMakeLists.txt | 16 +++++++++++----- 11 files changed, 44 insertions(+), 31 deletions(-) delete mode 100644 .gitmodules delete mode 160000 third_party/clickhouse-cpp delete mode 160000 third_party/googletest delete mode 160000 third_party/zlib diff --git a/.gitignore b/.gitignore index 928ea25..75030b4 100644 --- a/.gitignore +++ b/.gitignore @@ -159,4 +159,8 @@ config.json .envrc .cache/ -.claude/ \ No newline at end of file +.claude/ +# Former submodule checkouts (dependencies are now fetched by CMake) +/third_party/zlib/ +/third_party/googletest/ +/third_party/clickhouse-cpp/ diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 77f1d55..0000000 --- a/.gitmodules +++ /dev/null @@ -1,9 +0,0 @@ -[submodule "third_party/zlib"] - path = third_party/zlib - url = https://github.com/madler/zlib.git -[submodule "third_party/googletest"] - path = third_party/googletest - url = https://github.com/google/googletest.git -[submodule "third_party/clickhouse-cpp"] - path = third_party/clickhouse-cpp - url = https://github.com/ClickHouse/clickhouse-cpp.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 1849e29..bad5064 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,7 +17,7 @@ option(BUILD_TESTS "Build tests" OFF) option(BUILD_EXAMPLES "Build example applications" ON) option(BUILD_SHARED_LIBS "Build shared libraries" OFF) -# Add third party directory with submodules +# Add third party directory (vendored and CMake-fetched dependencies) add_subdirectory(third_party) # Find system OpenSSL diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 4367a20..4e798f5 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -22,7 +22,7 @@ This document provides comprehensive information about developing, building, and ### 1. Clone the Repository ```bash -git clone --recursive https://github.com/ClickHouse/ai-sdk-cpp.git +git clone https://github.com/ClickHouse/ai-sdk-cpp.git cd ai-sdk-cpp ``` diff --git a/scripts/build.py b/scripts/build.py index dc6e854..da37866 100755 --- a/scripts/build.py +++ b/scripts/build.py @@ -17,7 +17,7 @@ uv run scripts/build.py --mode debug --tests --clean --export-compile-commands This script handles: -- CMake configuration with git submodule dependencies +- CMake configuration with vendored and CMake-fetched dependencies - Building in Debug or Release mode - Optional test building - Clean builds @@ -133,7 +133,7 @@ def main(mode: str, tests: bool, clean: bool, verbose: bool, export_compile_comm # Create build directory build_dir.mkdir(exist_ok=True) - console.print("[green]✓[/green] Dependencies configured via git submodules") + console.print("[green]✓[/green] Dependencies vendored in-tree or fetched by CMake") console.print() # Configure CMake diff --git a/third_party/clickhouse-cmake/CMakeLists.txt b/third_party/clickhouse-cmake/CMakeLists.txt index 1b42e06..cd818fe 100644 --- a/third_party/clickhouse-cmake/CMakeLists.txt +++ b/third_party/clickhouse-cmake/CMakeLists.txt @@ -1,13 +1,22 @@ # ClickHouse C++ Client CMake wrapper -# This wrapper provides a consistent interface for the ClickHouse C++ client library +# Fetches clickhouse-cpp, pinned to the revision this repository previously +# tracked as a git submodule. # Only build ClickHouse client for tests if(NOT BUILD_TESTS) return() endif() -# Add ClickHouse client as subdirectory -add_subdirectory(../clickhouse-cpp clickhouse-cpp EXCLUDE_FROM_ALL) +include(FetchContent) + +FetchContent_Declare(clickhouse-cpp + URL https://github.com/ClickHouse/clickhouse-cpp/archive/cae657a672ff09b715d7127b13eb25d63bea01d4.tar.gz +) +FetchContent_GetProperties(clickhouse-cpp) +if(NOT clickhouse-cpp_POPULATED) + FetchContent_Populate(clickhouse-cpp) + add_subdirectory(${clickhouse-cpp_SOURCE_DIR} ${clickhouse-cpp_BINARY_DIR} EXCLUDE_FROM_ALL) +endif() # Create an interface target that properly exposes ClickHouse client add_library(clickhouse-cpp-client INTERFACE) @@ -32,4 +41,4 @@ else() endif() # Create alias for consistent naming -add_library(ClickHouse::Client ALIAS clickhouse-cpp-client) \ No newline at end of file +add_library(ClickHouse::Client ALIAS clickhouse-cpp-client) diff --git a/third_party/clickhouse-cpp b/third_party/clickhouse-cpp deleted file mode 160000 index cae657a..0000000 --- a/third_party/clickhouse-cpp +++ /dev/null @@ -1 +0,0 @@ -Subproject commit cae657a672ff09b715d7127b13eb25d63bea01d4 diff --git a/third_party/googletest b/third_party/googletest deleted file mode 160000 index 3983f67..0000000 --- a/third_party/googletest +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 3983f67e32fb3e9294487b9d4f9586efa6e5d088 diff --git a/third_party/googletest-cmake/CMakeLists.txt b/third_party/googletest-cmake/CMakeLists.txt index 609c288..0cf8545 100644 --- a/third_party/googletest-cmake/CMakeLists.txt +++ b/third_party/googletest-cmake/CMakeLists.txt @@ -1,10 +1,16 @@ +# Fetch GoogleTest, pinned to the revision this repository previously tracked +# as a git submodule. +include(FetchContent) + # Configure GoogleTest build options set(INSTALL_GTEST OFF CACHE INTERNAL "Disable GoogleTest installation") set(gtest_force_shared_crt ON CACHE INTERNAL "Use shared CRT on Windows") -# Add GoogleTest as subdirectory -add_subdirectory( - ${AI_SDK_THIRD_PARTY_DIR}/googletest - ${CMAKE_CURRENT_BINARY_DIR}/googletest - EXCLUDE_FROM_ALL +FetchContent_Declare(googletest + URL https://github.com/google/googletest/archive/3983f67e32fb3e9294487b9d4f9586efa6e5d088.tar.gz ) +FetchContent_GetProperties(googletest) +if(NOT googletest_POPULATED) + FetchContent_Populate(googletest) + add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR} EXCLUDE_FROM_ALL) +endif() diff --git a/third_party/zlib b/third_party/zlib deleted file mode 160000 index 5a82f71..0000000 --- a/third_party/zlib +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 5a82f71ed1dfc0bec044d9702463dbdf84ea3b71 diff --git a/third_party/zlib-cmake/CMakeLists.txt b/third_party/zlib-cmake/CMakeLists.txt index c2ecb1f..1c3e1d6 100644 --- a/third_party/zlib-cmake/CMakeLists.txt +++ b/third_party/zlib-cmake/CMakeLists.txt @@ -1,12 +1,18 @@ +# Fetch zlib (needed by httplib compression), pinned to the revision this +# repository previously tracked as a git submodule. +include(FetchContent) + # Configure zlib build options set(ZLIB_BUILD_EXAMPLES OFF CACHE INTERNAL "Disable zlib examples") -# Add zlib as subdirectory -add_subdirectory( - ${AI_SDK_THIRD_PARTY_DIR}/zlib - ${CMAKE_CURRENT_BINARY_DIR}/zlib - EXCLUDE_FROM_ALL +FetchContent_Declare(zlib + URL https://github.com/madler/zlib/archive/5a82f71ed1dfc0bec044d9702463dbdf84ea3b71.tar.gz ) +FetchContent_GetProperties(zlib) +if(NOT zlib_POPULATED) + FetchContent_Populate(zlib) + add_subdirectory(${zlib_SOURCE_DIR} ${zlib_BINARY_DIR} EXCLUDE_FROM_ALL) +endif() # Create ZLIB::ZLIB alias if it doesn't exist if(TARGET zlibstatic AND NOT TARGET ZLIB::ZLIB)