Files
zeekay 3094cd1739 build: point the last 13 contrib cmake files at Datastore_SOURCE_DIR
Configure now COMPLETES ("Configuring done (19.3s)") and the build died in the
generate step instead, on "No SOURCES given to target" for _zxc, _zxc_*_avx2/512,
_simdutf and libdeflate.

The targets are not empty; the paths were. CMake defines <PROJECT>_SOURCE_DIR,
and CMakeLists.txt:18 declares project(Datastore), so ClickHouse_SOURCE_DIR is
simply an undefined variable that expands to the empty string. Every contrib
wrapper still spelling it that way built its source path as "/contrib/zxc" or
"/contrib/simdutf/src" — rooted at /, not at the source tree — so the globs
matched nothing and add_library was handed an empty list. An undefined variable
is not an error in CMake, which is why this surfaced as a missing-sources
complaint about the target rather than a bad path.

This is the same unfinished rename as the previous commit wearing different
clothes. Swept both spellings across every in-repo cmake file: exactly two tokens,
ClickHouse_SOURCE_DIR and ClickHouse_BINARY_DIR, 23 occurrences in 13 files, all
of them contrib/*-cmake wrappers plus src/CMakeLists.txt. The submodules
themselves are untouched — the wrappers are ours, contrib/<name>-cmake is not a
.gitmodules path.

Renamed rather than aliased. A one-line set(ClickHouse_SOURCE_DIR
${Datastore_SOURCE_DIR}) in the root would also have worked and would cost less
on the next upstream merge, but the tree already carries hundreds of
Datastore_SOURCE_DIR uses in these same directories: the choice to rename was
made when the project was renamed, and these 13 files are the remainder of that
job, not a new decision. Two spellings for one path is the thing that produced
this bug in the first place.
2026-08-06 14:18:48 -07:00

109 lines
4.7 KiB
CMake

set(LIBCXX_SOURCE_DIR "${Datastore_SOURCE_DIR}/contrib/llvm-project/libcxx")
set(LIBCXX_BINARY_DIR "${Datastore_BINARY_DIR}/contrib/llvm-project/libcxx")
set(LIBCXX_GENERATED_INCLUDE_DIR "${LIBCXX_BINARY_DIR}/include/c++/v1")
set(LIBC_DIR "${Datastore_SOURCE_DIR}/contrib/llvm-project/libc")
set(SRCS
"${LIBCXX_SOURCE_DIR}/src/algorithm.cpp"
"${LIBCXX_SOURCE_DIR}/src/any.cpp"
"${LIBCXX_SOURCE_DIR}/src/atomic.cpp"
"${LIBCXX_SOURCE_DIR}/src/expected.cpp"
"${LIBCXX_SOURCE_DIR}/src/barrier.cpp"
"${LIBCXX_SOURCE_DIR}/src/bind.cpp"
"${LIBCXX_SOURCE_DIR}/src/call_once.cpp"
"${LIBCXX_SOURCE_DIR}/src/charconv.cpp"
"${LIBCXX_SOURCE_DIR}/src/chrono.cpp"
"${LIBCXX_SOURCE_DIR}/src/condition_variable.cpp"
"${LIBCXX_SOURCE_DIR}/src/condition_variable_destructor.cpp"
"${LIBCXX_SOURCE_DIR}/src/error_category.cpp"
"${LIBCXX_SOURCE_DIR}/src/exception.cpp"
"${LIBCXX_SOURCE_DIR}/src/experimental/keep.cpp"
"${LIBCXX_SOURCE_DIR}/src/filesystem/directory_entry.cpp"
"${LIBCXX_SOURCE_DIR}/src/filesystem/directory_iterator.cpp"
"${LIBCXX_SOURCE_DIR}/src/filesystem/filesystem_clock.cpp"
"${LIBCXX_SOURCE_DIR}/src/filesystem/filesystem_error.cpp"
"${LIBCXX_SOURCE_DIR}/src/filesystem/int128_builtins.cpp"
"${LIBCXX_SOURCE_DIR}/src/filesystem/operations.cpp"
"${LIBCXX_SOURCE_DIR}/src/filesystem/path.cpp"
"${LIBCXX_SOURCE_DIR}/src/fstream.cpp"
"${LIBCXX_SOURCE_DIR}/src/functional.cpp"
"${LIBCXX_SOURCE_DIR}/src/future.cpp"
"${LIBCXX_SOURCE_DIR}/src/hash.cpp"
"${LIBCXX_SOURCE_DIR}/src/ios.cpp"
"${LIBCXX_SOURCE_DIR}/src/ios.instantiations.cpp"
"${LIBCXX_SOURCE_DIR}/src/iostream.cpp"
"${LIBCXX_SOURCE_DIR}/src/locale.cpp"
"${LIBCXX_SOURCE_DIR}/src/memory.cpp"
"${LIBCXX_SOURCE_DIR}/src/memory_resource.cpp"
"${LIBCXX_SOURCE_DIR}/src/mutex.cpp"
"${LIBCXX_SOURCE_DIR}/src/mutex_destructor.cpp"
"${LIBCXX_SOURCE_DIR}/src/new.cpp"
"${LIBCXX_SOURCE_DIR}/src/new_handler.cpp"
"${LIBCXX_SOURCE_DIR}/src/new_helpers.cpp"
"${LIBCXX_SOURCE_DIR}/src/optional.cpp"
"${LIBCXX_SOURCE_DIR}/src/ostream.cpp"
"${LIBCXX_SOURCE_DIR}/src/print.cpp"
"${LIBCXX_SOURCE_DIR}/src/random.cpp"
"${LIBCXX_SOURCE_DIR}/src/random_shuffle.cpp"
"${LIBCXX_SOURCE_DIR}/src/regex.cpp"
"${LIBCXX_SOURCE_DIR}/src/ryu/d2fixed.cpp"
"${LIBCXX_SOURCE_DIR}/src/ryu/d2s.cpp"
"${LIBCXX_SOURCE_DIR}/src/ryu/f2s.cpp"
"${LIBCXX_SOURCE_DIR}/src/shared_mutex.cpp"
"${LIBCXX_SOURCE_DIR}/src/stdexcept.cpp"
"${LIBCXX_SOURCE_DIR}/src/string.cpp"
"${LIBCXX_SOURCE_DIR}/src/strstream.cpp"
"${LIBCXX_SOURCE_DIR}/src/system_error.cpp"
"${LIBCXX_SOURCE_DIR}/src/thread.cpp"
"${LIBCXX_SOURCE_DIR}/src/typeinfo.cpp"
"${LIBCXX_SOURCE_DIR}/src/valarray.cpp"
"${LIBCXX_SOURCE_DIR}/src/variant.cpp"
"${LIBCXX_SOURCE_DIR}/src/vector.cpp"
"${LIBCXX_SOURCE_DIR}/src/verbose_abort.cpp"
)
configure_file("${LIBCXX_SOURCE_DIR}/include/__assertion_handler" "${LIBCXX_GENERATED_INCLUDE_DIR}/__assertion_handler" COPYONLY)
configure_file("${LIBCXX_SOURCE_DIR}/include/__config_site" "${LIBCXX_GENERATED_INCLUDE_DIR}/__config_site" COPYONLY)
set(_all_includes "${LIBCXX_GENERATED_INCLUDE_DIR}/__config_site" "${LIBCXX_GENERATED_INCLUDE_DIR}/__assertion_handler")
add_custom_target(generate-cxx-headers ALL DEPENDS ${_all_includes})
add_library(cxx-headers INTERFACE)
add_dependencies(cxx-headers generate-cxx-headers)
target_include_directories(cxx-headers INTERFACE ${LIBCXX_GENERATED_INCLUDE_DIR} ${LIBC_DIR})
add_library(cxx ${SRCS})
set_target_properties(cxx PROPERTIES FOLDER "contrib/libcxx-cmake")
set(LIBC_NAMESPACE "__llvm_libc")
target_include_directories(cxx SYSTEM BEFORE PRIVATE $<BUILD_INTERFACE:${LIBCXX_SOURCE_DIR}/src>)
target_include_directories(cxx SYSTEM BEFORE PUBLIC $<$<COMPILE_LANGUAGE:CXX>:$<BUILD_INTERFACE:${LIBCXX_SOURCE_DIR}/include>>)
target_compile_definitions(cxx PRIVATE -D_LIBCPP_BUILDING_LIBRARY -DLIBCXX_BUILDING_LIBCXXABI -DLIBC_NAMESPACE=${LIBC_NAMESPACE})
target_compile_definitions(cxx PUBLIC -D_LIBCPP_REMOVE_TRANSITIVE_INCLUDES=1)
# Enable capturing stack traces for all exceptions.
target_compile_definitions(cxx PUBLIC -DSTD_EXCEPTION_HAS_STACK_TRACE=1)
if (USE_MUSL)
target_compile_definitions(cxx PUBLIC -D_LIBCPP_HAS_MUSL_LIBC=1)
add_dependencies(cxx musl-headers)
# The arch dirs are not in the toolchain flags to avoid include order issues in musl's own build.
target_include_directories(cxx SYSTEM BEFORE PRIVATE
"${Datastore_SOURCE_DIR}/contrib/musl/arch/${MUSL_ARCH}"
"${Datastore_SOURCE_DIR}/contrib/musl/arch/generic"
)
endif ()
target_compile_options(cxx PUBLIC $<$<COMPILE_LANGUAGE:CXX>:-nostdinc++>)
# Third party library may have substandard code.
target_compile_options(cxx PRIVATE -w)
# Enable support for Clang-Thread-Safety-Analysis in libcxx
target_compile_definitions(cxx PUBLIC -D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS)
target_link_libraries(cxx PUBLIC cxx-headers)
target_link_libraries(cxx PUBLIC cxxabi)