Skip to content
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
19d4901
Encapsulate logic for finding,setting up, and logging found dependenc…
gibber9809 Jul 15, 2025
d60ffff
Update cmake scripts to point of just working after removing CLP_NEED…
gibber9809 Jul 15, 2025
47cd6a6
Comment out status messages that would repeat on every call to find_X
gibber9809 Jul 16, 2025
c98d664
Rename find_X functions to clp_find_X
gibber9809 Jul 16, 2025
7d1da0b
Use macros for most clp_find_X functions to avoid having to manually …
gibber9809 Jul 16, 2025
d588c3f
Fix docstring
gibber9809 Jul 16, 2025
4a39d14
Delete macros that are equivalent to a simple find_package call
gibber9809 Jul 16, 2025
4200b50
Remove most messages in utils
gibber9809 Jul 16, 2025
c806443
Move cmake/Utils/utils.cmake -> cmake/find_utils.cmake
gibber9809 Jul 17, 2025
2973087
Merge branch 'main' into remove-needs-flags
gibber9809 Jul 17, 2025
e749db4
Merge remote-tracking branch 'upstream/main' into remove-needs-flags
gibber9809 Aug 19, 2025
1afacc5
Minor fixup after merge.
gibber9809 Aug 19, 2025
609ea59
Delete files accidentally added back in merge.
gibber9809 Aug 19, 2025
b2f917b
Merge remote-tracking branch 'upstream/main' into remove-needs-flags
gibber9809 Aug 21, 2025
e5b9b7c
Merge remote-tracking branch 'upstream/main' into remove-needs-flags
gibber9809 Aug 25, 2025
d2c24ae
Add missing clp_find_msgpack() calls
gibber9809 Aug 26, 2025
4c2bc50
Add one more missing instance of clp_find_msgpack
gibber9809 Aug 26, 2025
47c8643
Merge branch 'main' into remove-needs-flags
Bill-hbrhbr Aug 31, 2025
9cd35ee
Merge remote-tracking branch 'upstream/main' into remove-needs-flags
gibber9809 Sep 2, 2025
f76a408
Update components/core/cmake/find_utils.cmake
gibber9809 Sep 3, 2025
2d4ef0c
Remove unnecessary find_package(yaml-cpp) calls
gibber9809 Sep 3, 2025
51d26f6
Address review comment
gibber9809 Sep 3, 2025
b1e5d37
Merge remote-tracking branch 'upstream/main' into remove-needs-flags
gibber9809 Sep 3, 2025
1251b95
Move remaining find_package calls into macros.
gibber9809 Sep 4, 2025
b6aeef6
Merge remote-tracking branch 'upstream/main' into remove-needs-flags
gibber9809 Sep 4, 2025
322bfb4
Fix boost warning
gibber9809 Sep 4, 2025
02fc9f3
Make boost find_package call silent after first invocation.
gibber9809 Sep 4, 2025
0019aa2
Merge remote-tracking branch 'upstream/main' into remove-needs-flags
gibber9809 Sep 4, 2025
3808fe2
Delete unnecessary function.
gibber9809 Sep 4, 2025
48ab8b2
Merge remote-tracking branch 'upstream/main' into remove-needs-flags
gibber9809 Sep 24, 2025
a42fd90
Fix ystdlib-specific issue related to how ystdlib config scripts are …
gibber9809 Sep 24, 2025
05836ac
Merge remote-tracking branch 'upstream/main' into remove-needs-flags
gibber9809 Nov 3, 2025
735f91e
Add missing clp_find statements to log-converter CMakeLists
gibber9809 Nov 3, 2025
cf9f42a
Bump ystdlib to c03806a
gibber9809 Nov 3, 2025
3298467
Remove workaround for finding ystdlib
gibber9809 Nov 3, 2025
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
213 changes: 24 additions & 189 deletions components/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ validate_compiler_versions()
# Include options for CLP build
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/Options/options.cmake")

validate_and_setup_all_clp_dependency_flags()
convert_clp_dependency_properties_to_variables()
validate_all_clp_dependency_flags()

# Include utilities to find and configure dependencies
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/find_utils.cmake")

if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(default_build_type "Release")
Expand Down Expand Up @@ -137,195 +139,8 @@ if(PROJECT_IS_TOP_LEVEL)
endif()
endif()

if(CLP_NEED_ABSL)
find_package(absl REQUIRED)
if (absl_FOUND)
message(STATUS "Found absl ${absl_VERSION}")
endif()
endif()

# Find and setup ANTLR Library
if(CLP_NEED_ANTLR)
find_package(antlr4-runtime REQUIRED)
if (antlr4-runtime_FOUND)
message(STATUS "Found antlr4-runtime ${antlr4-runtime_VERSION}")
endif()
endif()

# Find and setup Boost Library
if(CLP_NEED_BOOST)
if(CLP_USE_STATIC_LIBS)
set(Boost_USE_STATIC_LIBS ON)
endif()
find_package(Boost 1.89 REQUIRED iostreams program_options filesystem regex url)
if(Boost_FOUND)
message(STATUS "Found Boost ${Boost_VERSION}")
else()
message(FATAL_ERROR "Could not find ${CLP_LIBS_STRING} libraries for Boost")
endif()
endif()

if(CLP_NEED_CATCH2)
find_package(Catch2 3.8.0 REQUIRED)
message(STATUS "Found Catch2 ${Catch2_VERSION}")
endif()

if(CLP_NEED_DATE)
find_package(date REQUIRED)
if (date_FOUND)
message(STATUS "Found date ${date_VERSION}")
endif()
endif()

if(CLP_NEED_FMT)
find_package(fmt REQUIRED)
if(fmt_FOUND)
message(STATUS "Found fmt ${fmt_VERSION}")
endif()
endif()

if(CLP_NEED_LOG_SURGEON)
find_package(log_surgeon REQUIRED)
if(log_surgeon_FOUND)
message(STATUS "Found log_surgeon ${log_surgeon_VERSION}")
endif()
endif()

if(CLP_NEED_NLOHMANN_JSON)
find_package(nlohmann_json REQUIRED)
if(nlohmann_json_FOUND)
message(STATUS "Found nlohmann_json ${nlohmann_json_VERSION}")
endif()
endif()

if(CLP_NEED_SIMDJSON)
find_package(simdjson REQUIRED)
if(simdjson_FOUND)
message(STATUS "Found simdjson ${simdjson_VERSION}")
endif()
endif()

if(CLP_NEED_SPDLOG)
find_package(spdlog REQUIRED)
if(spdlog_FOUND)
message(STATUS "Found spdlog ${spdlog_VERSION}")
endif()
endif()

# Find and setup libarchive
if(CLP_NEED_LIBARCHIVE)
if(CLP_USE_STATIC_LIBS)
set(LibArchive_USE_STATIC_LIBS ON)
endif()
find_package(LibArchive REQUIRED)
if(LibArchive_FOUND)
message(STATUS "Found LibArchive ${LibArchive_VERSION}")
else()
message(FATAL_ERROR "Could not find ${CLP_LIBS_STRING} libraries for LibArchive")
endif()
endif()

# Find and setup libcurl
# By default, CURL does not provide static libraries
if(CLP_NEED_CURL)
find_package(CURL 7.61.1 REQUIRED)
if(CURL_FOUND)
message(STATUS "Found CURL ${CURL_VERSION_STRING}")
else()
message(FATAL_ERROR "Could not find ${CLP_LIBS_STRING} libraries for CURL")
endif()
endif()

# Find OpenSSL
if(CLP_NEED_OPENSSL)
find_package(OpenSSL REQUIRED)
if(OPENSSL_FOUND)
message(STATUS "Found OpenSSL (${OPENSSL_VERSION})")
else()
message(FATAL_ERROR "OpenSSL not found")
endif()
endif()

# Find and setup MariaDBClient library
if(CLP_NEED_MARIADB)
if(CLP_USE_STATIC_LIBS)
# NOTE: We can't statically link to MariaDBClient since it's GPL
message(AUTHOR_WARNING "MariaDBClient cannot be statically linked due to its license.")
endif()
find_package(MariaDBClient 3.1.0 REQUIRED)
if(MariaDBClient_FOUND)
message(STATUS "Found MariaDBClient ${MariaDBClient_VERSION}")
else()
message(FATAL_ERROR "Could not find ${CLP_LIBS_STRING} libraries for MariaDBClient")
endif()
endif()

# Find and setup mongocxx
if(CLP_NEED_MONGOCXX)
find_package(mongocxx REQUIRED)
message(STATUS "Found mongocxx ${mongocxx_VERSION}")
if(CLP_USE_STATIC_LIBS)
set(MONGOCXX_TARGET mongo::mongocxx_static)
else()
set(MONGOCXX_TARGET mongo::mongocxx_shared)
endif()
endif()

# Find and setup msgpack
if(CLP_NEED_MSGPACKCXX)
find_package(msgpack-cxx 7.0.0 REQUIRED)
if(msgpack-cxx_FOUND)
message(STATUS "Found msgpack-cxx ${msgpack-cxx_VERSION}")
else()
message(FATAL_ERROR "Could not find msgpack-cxx")
endif()
endif()

find_package(Threads REQUIRED)

if(CLP_NEED_YAMLCPP)
find_package(yaml-cpp REQUIRED)
if(yaml-cpp_FOUND)
message(STATUS "Found yaml-cpp ${yaml-cpp_VERSION}")
endif()
endif()

# Add ystdlib
if(CLP_NEED_YSTDLIB)
set(YSTDLIB_CPP_BUILD_TESTING OFF)
add_subdirectory("${CLP_YSTDLIB_SOURCE_DIRECTORY}" "${CMAKE_BINARY_DIR}/ystdlib" EXCLUDE_FROM_ALL)
endif()

if(CLP_NEED_ZSTD)
# v1.4.8 is the lowest version available in the package managers of the OSes we support.
find_package(zstd 1.4.8 REQUIRED)
message(STATUS "Found zstd ${zstd_VERSION}")
if(CLP_USE_STATIC_LIBS)
set(zstd_TARGET zstd::libzstd_static)
else()
set(zstd_TARGET zstd::libzstd_shared)
endif()
endif()

if(CLP_NEED_LIBLZMA)
if(CLP_USE_STATIC_LIBS)
set(LibLZMA_ROOT ${LibLZMA-static_ROOT})
set(LibLZMA_USE_STATIC_LIBS ON)
else()
set(LibLZMA_ROOT ${LibLZMA-shared_ROOT})
endif()
# Version 5.8.1 and above address CVE-2024-3094 and CVE-2025-31115.
find_package(LibLZMA 5.8.1 REQUIRED)
message(STATUS "Found LibLZMA ${LibLZMA_VERSION}")
endif()

# sqlite dependencies
if(CLP_NEED_SQLITE)
set(sqlite_DYNAMIC_LIBS "dl;m;pthread")
include(cmake/Modules/FindLibraryDependencies.cmake)
FindDynamicLibraryDependencies(sqlite "${sqlite_DYNAMIC_LIBS}")
endif()

add_subdirectory(src/clp/regex_utils)
add_subdirectory(src/clp/string_utils)

Expand Down Expand Up @@ -719,6 +534,26 @@ set(SOURCE_FILES_unitTest
)

if(CLP_BUILD_TESTING)
find_package(absl REQUIRED)
clp_find_boost()
clp_find_catch2()
clp_find_curl()
find_package(date REQUIRED)
find_package(fmt REQUIRED)
clp_find_libarchive()
find_package(log_surgeon REQUIRED)
clp_find_lzma()
clp_find_mariadb_client()
clp_find_mongocxx()
find_package(nlohmann_json REQUIRED)
find_package(OpenSSL REQUIRED)
find_package(simdjson REQUIRED)
find_package(spdlog REQUIRED)
clp_find_sqlite()
find_package(yaml-cpp REQUIRED)
clp_find_ystdlib()
clp_find_zstd()

add_executable(unitTest
${SOURCE_FILES_unitTest}
${SOURCE_FILES_clp_s_unitTest}
Expand Down
103 changes: 103 additions & 0 deletions components/core/cmake/Modules/FindLZ4.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Try to find LZ4
#
# Set LZ4_USE_STATIC_LIBS=ON to look for static libraries.
#
# Once done this will define:
# LZ4_FOUND - Whether LZ4 was found on the system
# LZ4_INCLUDE_DIR - The LZ4 include directories
# LZ4_VERSION - The version of LZ4 installed on the system
#
# Conventions:
# - Variables only for use within the script are prefixed with "lz4_"
# - Variables that should be externally visible are prefixed with "LZ4_"

set(lz4_LIBNAME "lz4")

include("${PROJECT_SOURCE_DIR}/cmake/Modules/FindLibraryDependencies.cmake")

# Run pkg-config
find_package(PkgConfig)
pkg_check_modules(lz4_PKGCONF QUIET "lib${lz4_LIBNAME}")

# Set include directory
find_path(LZ4_INCLUDE_DIR lz4.h
HINTS ${lz4_PKGCONF_INCLUDEDIR}
PATH_SUFFIXES include
)

# Handle static libraries
if(LZ4_USE_STATIC_LIBS)
# Save current value of CMAKE_FIND_LIBRARY_SUFFIXES
set(lz4_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})

# Temporarily change CMAKE_FIND_LIBRARY_SUFFIXES to static library suffix
set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
endif()

# Find library
find_library(LZ4_LIBRARY
NAMES ${lz4_LIBNAME}
HINTS ${lz4_PKGCONF_LIBDIR}
PATH_SUFFIXES lib
)
if (LZ4_LIBRARY)
# NOTE: This must be set for find_package_handle_standard_args to work
set(LZ4_FOUND ON)
endif()

if(LZ4_USE_STATIC_LIBS)
FindStaticLibraryDependencies(${lz4_LIBNAME} lz4 "${lz4_PKGCONF_STATIC_LIBRARIES}")

# Restore original value of CMAKE_FIND_LIBRARY_SUFFIXES
set(CMAKE_FIND_LIBRARY_SUFFIXES ${lz4_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
unset(lz4_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES)
endif()

FindDynamicLibraryDependencies(lz4 "${lz4_DYNAMIC_LIBS}")

# Set version
set(LZ4_VERSION ${lz4_PKGCONF_VERSION})

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LZ4
REQUIRED_VARS LZ4_INCLUDE_DIR
VERSION_VAR LZ4_VERSION
)

if(NOT TARGET LZ4::LZ4)
# Add library to build
if (LZ4_FOUND)
if (LZ4_USE_STATIC_LIBS)
add_library(LZ4::LZ4 STATIC IMPORTED)
else()
# NOTE: We use UNKNOWN so that if the user doesn't have the SHARED
# libraries installed, we can still use the STATIC libraries
add_library(LZ4::LZ4 UNKNOWN IMPORTED)
endif()
endif()

# Set include directories for library
if(LZ4_INCLUDE_DIR)
set_target_properties(LZ4::LZ4
PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${LZ4_INCLUDE_DIR}"
)
endif()

# Set location of library
if(EXISTS "${LZ4_LIBRARY}")
set_target_properties(LZ4::LZ4
PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${LZ4_LIBRARY}"
)

# Add component's dependencies for linking
if(lz4_LIBRARY_DEPENDENCIES)
set_target_properties(LZ4::LZ4
PROPERTIES
INTERFACE_LINK_LIBRARIES "${lz4_LIBRARY_DEPENDENCIES}"
)
endif()
endif()
endif()
2 changes: 1 addition & 1 deletion components/core/cmake/Modules/FindLibArchive.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

set(libarchive_LIBNAME "archive")

include(cmake/Modules/FindLibraryDependencies.cmake)
include("${PROJECT_SOURCE_DIR}/cmake/Modules/FindLibraryDependencies.cmake")

# On macOS, libarchive installed through brew is not linked into prefix by default.
# So it cannot be found by pkg-config and we need to manually find it.
Expand Down
2 changes: 1 addition & 1 deletion components/core/cmake/Modules/FindMariaDBClient.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

set(mariadbclient_LIBNAME "mariadb")

include(cmake/Modules/FindLibraryDependencies.cmake)
include("${PROJECT_SOURCE_DIR}/cmake/Modules/FindLibraryDependencies.cmake")

# Run pkg-config
find_package(PkgConfig)
Expand Down
Loading
Loading