diff --git a/components/core/CMakeLists.txt b/components/core/CMakeLists.txt index c5f42f1eac..a0889845b2 100644 --- a/components/core/CMakeLists.txt +++ b/components/core/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.16.3) +cmake_minimum_required(VERSION 3.21) # Toolchain setup must come before the first project() call in the entire CMake buildsystem. # If CLP is not the top-level project, the following setup has no effect. @@ -9,6 +9,12 @@ project(CLP LANGUAGES CXX C) 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() + if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set(default_build_type "Release") message(STATUS "No build type specified. Setting to '${default_build_type}'.") @@ -113,161 +119,203 @@ if(PROJECT_IS_TOP_LEVEL) endif() endif() -find_package(absl REQUIRED) -if (absl_FOUND) - message(STATUS "Found absl ${absl_VERSION}") +if(CLP_NEED_ABSL) + find_package(absl REQUIRED) + if (absl_FOUND) + message(STATUS "Found absl ${absl_VERSION}") + endif() endif() # Find and setup ANTLR Library -find_package(antlr4-runtime REQUIRED) -if (antlr4-runtime_FOUND) - message(STATUS "Found antlr4-runtime ${antlr4-runtime_VERSION}") +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_USE_STATIC_LIBS) - set(Boost_USE_STATIC_LIBS ON) -endif() -find_package(Boost 1.81 REQUIRED iostreams program_options filesystem system regex url) -if(Boost_FOUND) - message(STATUS "Found Boost ${Boost_VERSION}") -else() - message(FATAL_ERROR "Could not find ${CLP_LIBS_STRING} libraries for Boost") +if(CLP_NEED_BOOST) + if(CLP_USE_STATIC_LIBS) + set(Boost_USE_STATIC_LIBS ON) + endif() + find_package(Boost 1.81 REQUIRED iostreams program_options filesystem system 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() -find_package(Catch2 REQUIRED) -if (Catch2_FOUND) - message(STATUS "Found Catch2 ${Catch2_VERSION}") +if(CLP_NEED_CATCH2) + find_package(Catch2 REQUIRED) + if (Catch2_FOUND) + message(STATUS "Found Catch2 ${Catch2_VERSION}") + endif() endif() -find_package(date REQUIRED) -if (date_FOUND) - message(STATUS "Found date ${date_VERSION}") +if(CLP_NEED_DATE) + find_package(date REQUIRED) + if (date_FOUND) + message(STATUS "Found date ${date_VERSION}") + endif() endif() -find_package(fmt REQUIRED) -if(fmt_FOUND) - message(STATUS "Found fmt ${fmt_VERSION}") +if(CLP_NEED_FMT) + find_package(fmt REQUIRED) + if(fmt_FOUND) + message(STATUS "Found fmt ${fmt_VERSION}") + endif() endif() -find_package(log_surgeon REQUIRED) -if(log_surgeon_FOUND) - message(STATUS "Found log_surgeon ${log_surgeon_VERSION}") +if(CLP_NEED_LOG_SURGEON) + find_package(log_surgeon REQUIRED) + if(log_surgeon_FOUND) + message(STATUS "Found log_surgeon ${log_surgeon_VERSION}") + endif() endif() -find_package(nlohmann_json REQUIRED) -if(nlohmann_json_FOUND) - message(STATUS "Found nlohmann_json ${nlohmann_json_VERSION}") +if(CLP_NEED_NLOHMANN_JSON) + find_package(nlohmann_json REQUIRED) + if(nlohmann_json_FOUND) + message(STATUS "Found nlohmann_json ${nlohmann_json_VERSION}") + endif() endif() -find_package(simdjson REQUIRED) -if(simdjson_FOUND) - message(STATUS "Found simdjson ${simdjson_VERSION}") +if(CLP_NEED_SIMDJSON) + find_package(simdjson REQUIRED) + if(simdjson_FOUND) + message(STATUS "Found simdjson ${simdjson_VERSION}") + endif() endif() -find_package(spdlog REQUIRED) -if(spdlog_FOUND) - message(STATUS "Found spdlog ${spdlog_VERSION}") +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_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") +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 -find_package(CURL 7.68.0 REQUIRED) -if(CURL_FOUND) - message(STATUS "Found CURL ${CURL_VERSION_STRING}") -else() - message(FATAL_ERROR "Could not find ${CLP_LIBS_STRING} libraries for CURL") +if(CLP_NEED_CURL) + find_package(CURL 7.68.0 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 -find_package(OpenSSL REQUIRED) -if (OPENSSL_FOUND) - message(STATUS "Found OpenSSL (${OPENSSL_VERSION})") -else () - message(FATAL_ERROR "OpenSSL not found") -endif () +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_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") +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 -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) +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 -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") +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) -find_package(yaml-cpp REQUIRED) -if(yaml-cpp_FOUND) - message(STATUS "Found yaml-cpp ${yaml-cpp_VERSION}") +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 -set(YSTDLIB_CPP_BUILD_TESTING OFF) -add_subdirectory("${CLP_YSTDLIB_SOURCE_DIRECTORY}" "${CMAKE_BINARY_DIR}/ystdlib" EXCLUDE_FROM_ALL) +if(CLP_NEED_YSTDLIB) + set(YSTDLIB_CPP_BUILD_TESTING OFF) + add_subdirectory("${CLP_YSTDLIB_SOURCE_DIRECTORY}" "${CMAKE_BINARY_DIR}/ystdlib" EXCLUDE_FROM_ALL) +endif() # Find and setup ZStd Library -if(CLP_USE_STATIC_LIBS) - set(ZStd_USE_STATIC_LIBS ON) -endif() -find_package(ZStd 1.4.4 REQUIRED) -if(ZStd_FOUND) - message(STATUS "Found ZStd ${ZStd_VERSION}") -else() - message(FATAL_ERROR "Could not find ${CLP_LIBS_STRING} libraries for ZStd") +if(CLP_NEED_ZSTD) + if(CLP_USE_STATIC_LIBS) + set(ZStd_USE_STATIC_LIBS ON) + endif() + find_package(ZStd 1.4.4 REQUIRED) + if(ZStd_FOUND) + message(STATUS "Found ZStd ${ZStd_VERSION}") + else() + message(FATAL_ERROR "Could not find ${CLP_LIBS_STRING} libraries for ZStd") + endif() endif() # Find and setup LZMA Library # TODO: Add a script in ./cmake/Modules to properly import LZMA in find_package()'s module mode -if(CLP_USE_STATIC_LIBS) - set(LIBLZMA_USE_STATIC_LIBS ON) -endif() -find_package(LibLZMA REQUIRED) -if(LIBLZMA_FOUND) - message(STATUS "Found Lzma ${LIBLZMA_VERSION_STRING}") - message(STATUS "Lzma library location: ${LIBLZMA_LIBRARIES}") - message(STATUS "Lzma Include Dir: ${LIBLZMA_INCLUDE_DIRS}") -else() - message(FATAL_ERROR "Could not find ${CLP_LIBS_STRING} libraries for Lzma") +if(CLP_NEED_LZMA) + if(CLP_USE_STATIC_LIBS) + set(LIBLZMA_USE_STATIC_LIBS ON) + endif() + find_package(LibLZMA REQUIRED) + if(LIBLZMA_FOUND) + message(STATUS "Found Lzma ${LIBLZMA_VERSION_STRING}") + message(STATUS "Lzma library location: ${LIBLZMA_LIBRARIES}") + message(STATUS "Lzma Include Dir: ${LIBLZMA_INCLUDE_DIRS}") + else() + message(FATAL_ERROR "Could not find ${CLP_LIBS_STRING} libraries for Lzma") + endif() + include_directories(${LIBLZMA_INCLUDE_DIRS}) endif() -include_directories(${LIBLZMA_INCLUDE_DIRS}) # sqlite dependencies -set(sqlite_DYNAMIC_LIBS "dl;m;pthread") -include(cmake/Modules/FindLibraryDependencies.cmake) -FindDynamicLibraryDependencies(sqlite "${sqlite_DYNAMIC_LIBS}") +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) @@ -663,45 +711,48 @@ set(SOURCE_FILES_unitTest tests/test-utf8_utils.cpp tests/test-Utils.cpp ) -add_executable(unitTest - ${SOURCE_FILES_unitTest} - ${SOURCE_FILES_clp_s_unitTest} - ${SOURCE_FILES_reducer_unitTest} - ) -target_include_directories(unitTest - PRIVATE - ${CLP_SQLITE3_INCLUDE_DIRECTORY} - ) -target_link_libraries(unitTest - PRIVATE - absl::flat_hash_map - Boost::filesystem Boost::iostreams Boost::program_options Boost::regex Boost::url - Catch2::Catch2 - ${CURL_LIBRARIES} - clp_s::search::ast - clp_s::search::kql - clp_s::search::sql - clp_s::timestamp_pattern - date::date - fmt::fmt - log_surgeon::log_surgeon - LibArchive::LibArchive - MariaDBClient::MariaDBClient - ${MONGOCXX_TARGET} - nlohmann_json::nlohmann_json - simdjson::simdjson - spdlog::spdlog - OpenSSL::Crypto - ${sqlite_LIBRARY_DEPENDENCIES} - ${STD_FS_LIBS} - clp::regex_utils - clp::string_utils - yaml-cpp - ystdlib::containers - ystdlib::error_handling - ${LIBLZMA_LIBRARIES} - ZStd::ZStd - ) -target_compile_features(unitTest - PRIVATE cxx_std_20 - ) + +if(CLP_BUILD_TESTING) + add_executable(unitTest + ${SOURCE_FILES_unitTest} + ${SOURCE_FILES_clp_s_unitTest} + ${SOURCE_FILES_reducer_unitTest} + ) + target_include_directories(unitTest + PRIVATE + ${CLP_SQLITE3_INCLUDE_DIRECTORY} + ) + target_link_libraries(unitTest + PRIVATE + absl::flat_hash_map + Boost::filesystem Boost::iostreams Boost::program_options Boost::regex Boost::url + Catch2::Catch2 + ${CURL_LIBRARIES} + clp_s::search::ast + clp_s::search::kql + clp_s::search::sql + clp_s::timestamp_pattern + date::date + fmt::fmt + log_surgeon::log_surgeon + LibArchive::LibArchive + MariaDBClient::MariaDBClient + ${MONGOCXX_TARGET} + nlohmann_json::nlohmann_json + simdjson::simdjson + spdlog::spdlog + OpenSSL::Crypto + ${sqlite_LIBRARY_DEPENDENCIES} + ${STD_FS_LIBS} + clp::regex_utils + clp::string_utils + yaml-cpp + ystdlib::containers + ystdlib::error_handling + ${LIBLZMA_LIBRARIES} + ZStd::ZStd + ) + target_compile_features(unitTest + PRIVATE cxx_std_20 + ) +endif() diff --git a/components/core/cmake/Options/options.cmake b/components/core/cmake/Options/options.cmake new file mode 100644 index 0000000000..dfaad0d261 --- /dev/null +++ b/components/core/cmake/Options/options.cmake @@ -0,0 +1,474 @@ +# Build Target Options +option( + CLP_BUILD_EXECUTABLES + "Build all executables." + ON +) + +option( + CLP_BUILD_TESTING + "Build all tests." + ON +) + +option( + CLP_BUILD_CLP_REGEX_UTILS + "Build clp::regex_utils." + ON +) + +option( + CLP_BUILD_CLP_STRING_UTILS + "Build clp::string_utils." + ON +) + +option( + CLP_BUILD_CLP_S_ARCHIVEREADER + "Build clp_s::archive_reader." + ON +) + +option( + CLP_BUILD_CLP_S_ARCHIVEWRITER + "Build clp_s::archive_writer." + ON +) + +option( + CLP_BUILD_CLP_S_CLP_DEPENDENCIES + "BUILD clp_s::clp_dependencies." + ON +) + +option( + CLP_BUILD_CLP_S_IO + "Build clp_s::io." + ON +) + +option( + CLP_BUILD_CLP_S_JSONCONSTRUCTOR + "Build clp_s::json_constructor." + ON +) + +option( + CLP_BUILD_CLP_S_REDUCER_DEPENDENCIES + "Build clp_s::reducer_dependencies." + ON +) + +option( + CLP_BUILD_CLP_S_SEARCH + "Build clp_s::search." + ON +) + +option( + CLP_BUILD_CLP_S_SEARCH_AST + "Build clp_s::search::ast." + ON +) + +option( + CLP_BUILD_CLP_S_SEARCH_KQL + "Build clp_s::search::kql." + ON +) + +option( + CLP_BUILD_CLP_S_SEARCH_SQL + "Build clp_s::search::sql." + ON +) + +option( + CLP_BUILD_CLP_S_TIMESTAMPPATTERN + "Build clp_s::timestamp_pattern." + ON +) + +# Validates that the `CLP_BUILD_` options required by `TARGET_CLP_BUILD_OPTION` are `ON`. +# +# @param {string} TARGET_CLP_BUILD_OPTION +# @param {string[]} ARGN The required `CLP_BUILD_` options +function(validate_clp_dependencies_for_target TARGET_CLP_BUILD_OPTION) + if (NOT DEFINED TARGET_CLP_BUILD_OPTION OR TARGET_CLP_BUILD_OPTION STREQUAL "") + message(FATAL_ERROR "TARGET_CLP_BUILD_OPTION can't be unset or empty.") + endif() + + foreach(DEPENDENCY IN LISTS ARGN) + if (NOT "${${DEPENDENCY}}") + message(FATAL_ERROR "${TARGET_CLP_BUILD_OPTION} requires ${DEPENDENCY}=ON") + endif() + endforeach() +endfunction() + +# Sets the given `CLP_NEED_` flags as directory properties +# +# @param {string[]} ARGV The `CLP_NEED_` flags to set. +function(set_clp_need_flags) + foreach(NEEDS_FLAG IN LISTS ARGV) + set_property(DIRECTORY PROPERTY "${NEEDS_FLAG}" ON) + endforeach() +endfunction() + +function(validate_clp_binaries_dependencies) + validate_clp_dependencies_for_target(CLP_BUILD_EXECUTABLES + CLP_BUILD_CLP_STRING_UTILS + CLP_BUILD_CLP_S_ARCHIVEREADER + CLP_BUILD_CLP_S_ARCHIVEWRITER + CLP_BUILD_CLP_S_CLP_DEPENDENCIES + CLP_BUILD_CLP_S_IO + CLP_BUILD_CLP_S_JSONCONSTRUCTOR + CLP_BUILD_CLP_S_REDUCER_DEPENDENCIES + CLP_BUILD_CLP_S_SEARCH + CLP_BUILD_CLP_S_SEARCH_AST + CLP_BUILD_CLP_S_SEARCH_KQL + ) +endfunction() + +function(set_clp_binaries_dependencies) + set_clp_need_flags( + CLP_NEED_ABSL + CLP_NEED_BOOST + CLP_NEED_CURL + CLP_NEED_DATE + CLP_NEED_FMT + CLP_NEED_LIBARCHIVE + CLP_NEED_LOG_SURGEON + CLP_NEED_MARIADB + CLP_NEED_MONGOCXX + CLP_NEED_MSGPACKCXX + CLP_NEED_NLOHMANN_JSON + CLP_NEED_OPENSSL + CLP_NEED_SIMDJSON + CLP_NEED_SPDLOG + CLP_NEED_SQLITE + CLP_NEED_YAMLCPP + CLP_NEED_YSTDLIB + CLP_NEED_ZSTD + ) +endfunction() + +function(validate_clp_tests_dependencies) + validate_clp_dependencies_for_target(CLP_BUILD_TESTING + CLP_BUILD_CLP_REGEX_UTILS + CLP_BUILD_CLP_STRING_UTILS + CLP_BUILD_CLP_S_SEARCH_AST + CLP_BUILD_CLP_S_SEARCH_KQL + CLP_BUILD_CLP_S_SEARCH_SQL + CLP_BUILD_CLP_S_TIMESTAMPPATTERN + ) +endfunction() + +function(set_clp_tests_dependencies) + set_clp_need_flags( + CLP_NEED_ABSL + CLP_NEED_BOOST + CLP_NEED_CATCH2 + CLP_NEED_DATE + CLP_NEED_FMT + CLP_NEED_LIBARCHIVE + CLP_NEED_LOG_SURGEON + CLP_NEED_LZMA + CLP_NEED_MARIADB + CLP_NEED_MONGOCXX + CLP_NEED_NLOHMANN_JSON + CLP_NEED_OPENSSL + CLP_NEED_SIMDJSON + CLP_NEED_SPDLOG + CLP_NEED_SQLITE + CLP_NEED_YAMLCPP + CLP_NEED_YSTDLIB + CLP_NEED_ZSTD + ) +endfunction() + +function(validate_clp_regex_utils_dependencies) + validate_clp_dependencies_for_target(CLP_BUILD_CLP_REGEX_UTILS + CLP_BUILD_CLP_STRING_UTILS + ) +endfunction() + +function(set_clp_regex_utils_dependencies) + set_property(DIRECTORY PROPERTY CLP_NEED_YSTDLIB TRUE) +endfunction() + +function(validate_clp_s_archivereader_dependencies) + validate_clp_dependencies_for_target(CLP_BUILD_CLP_S_ARCHIVEREADER + CLP_BUILD_CLP_S_CLP_DEPENDENCIES + CLP_BUILD_CLP_S_IO + CLP_BUILD_CLP_S_TIMESTAMPPATTERN + ) +endfunction() + +function(set_clp_s_archivereader_dependencies) + set_clp_need_flags( + CLP_NEED_ABSL + CLP_NEED_BOOST + CLP_NEED_CURL + CLP_NEED_FMT + CLP_NEED_MSGPACKCXX + CLP_NEED_NLOHMANN_JSON + CLP_NEED_SPDLOG + ) +endfunction() + +function(validate_clp_s_archivewriter_dependencies) + validate_clp_dependencies_for_target(CLP_BUILD_CLP_S_ARCHIVEWRITER + CLP_BUILD_CLP_S_CLP_DEPENDENCIES + CLP_BUILD_CLP_S_IO + CLP_BUILD_CLP_S_TIMESTAMPPATTERN + ) +endfunction() + +function(set_clp_s_archivewriter_dependencies) + set_clp_need_flags( + CLP_NEED_ABSL + CLP_NEED_BOOST + CLP_NEED_CURL + CLP_NEED_FMT + CLP_NEED_MSGPACKCXX + CLP_NEED_NLOHMANN_JSON + CLP_NEED_SIMDJSON + CLP_NEED_SPDLOG + ) +endfunction() + +function(validate_clp_s_clp_dependencies_dependencies) + validate_clp_dependencies_for_target(CLP_BUILD_CLP_S_CLP_DEPENDENCIES + CLP_BUILD_CLP_STRING_UTILS + ) +endfunction() + +function(set_clp_s_clp_dependencies_dependencies) + set_clp_need_flags( + CLP_NEED_BOOST + CLP_NEED_CURL + CLP_NEED_FMT + CLP_NEED_NLOHMANN_JSON + CLP_NEED_OPENSSL + CLP_NEED_SPDLOG + CLP_NEED_YSTDLIB + CLP_NEED_ZSTD + ) +endfunction() + +function(validate_clp_s_io_dependencies) + validate_clp_dependencies_for_target(CLP_BUILD_CLP_S_IO + CLP_BUILD_CLP_S_CLP_DEPENDENCIES + ) +endfunction() + +function(set_clp_s_io_dependencies) + set_clp_need_flags( + CLP_NEED_BOOST + CLP_NEED_FMT + CLP_NEED_SPDLOG + CLP_NEED_ZSTD + ) +endfunction() + +function(validate_clp_s_json_constructor_dependencies) + validate_clp_dependencies_for_target(CLP_BUILD_CLP_S_JSONCONSTRUCTOR + CLP_BUILD_CLP_S_ARCHIVEREADER + ) +endfunction() + +function(set_clp_s_json_constructor_dependencies) + set_clp_need_flags( + CLP_NEED_FMT + CLP_NEED_MONGOCXX + CLP_NEED_SPDLOG + ) +endfunction() + +function(validate_clp_s_reducer_dependencies_dependencies) + validate_clp_dependencies_for_target(CLP_BUILD_CLP_S_REDUCER_DEPENDENCIES + CLP_BUILD_CLP_S_CLP_DEPENDENCIES + ) +endfunction() + +function(set_clp_s_reducer_dependencies_dependencies) + set_clp_need_flags( + CLP_NEED_NLOHMANN_JSON + ) +endfunction() + +function(validate_clp_s_search_dependencies) + validate_clp_dependencies_for_target(CLP_BUILD_CLP_S_SEARCH + CLP_BUILD_CLP_S_ARCHIVEREADER + CLP_BUILD_CLP_S_CLP_DEPENDENCIES + CLP_BUILD_CLP_S_SEARCH_AST + ) +endfunction() + +function(set_clp_s_search_dependencies) + set_clp_need_flags( + CLP_NEED_ABSL + CLP_NEED_SIMDJSON + CLP_NEED_SPDLOG + ) +endfunction() + +function(validate_clp_s_search_ast_dependencies) + validate_clp_dependencies_for_target(CLP_BUILD_CLP_S_SEARCH_AST + CLP_BUILD_CLP_S_TIMESTAMPPATTERN + ) +endfunction() + +function(set_clp_s_search_ast_dependencies) + set_clp_need_flags( + CLP_NEED_SIMDJSON + ) +endfunction() + +function(validate_clp_s_search_kql_dependencies) + validate_clp_dependencies_for_target(CLP_BUILD_CLP_S_SEARCH_KQL + CLP_BUILD_CLP_STRING_UTILS + CLP_BUILD_CLP_S_SEARCH_AST + ) +endfunction() + +function(set_clp_s_search_kql_dependencies) + set_clp_need_flags( + CLP_NEED_ANTLR + CLP_NEED_SPDLOG + ) +endfunction() + +function(validate_clp_s_search_sql_dependencies) + validate_clp_dependencies_for_target(CLP_BUILD_CLP_S_SEARCH_SQL + CLP_BUILD_CLP_S_SEARCH_AST + ) +endfunction() + +function(set_clp_s_search_sql_dependencies) + set_clp_need_flags( + CLP_NEED_ANTLR + CLP_NEED_SPDLOG + ) +endfunction() + +function(validate_clp_s_timestamppattern_dependencies) + validate_clp_dependencies_for_target(CLP_BUILD_CLP_S_TIMESTAMPPATTERN + CLP_BUILD_CLP_STRING_UTILS + ) +endfunction() + +function(set_clp_s_timestamppattern_dependencies) + set_clp_need_flags( + CLP_NEED_DATE + CLP_NEED_SPDLOG + ) +endfunction() + +# Validates that for each target whose `CLP_BUILD_` option is `ON`, the `CLP_BUILD_` options for +# the target's dependencies are also `ON`; Sets the required `CLP_NEED_` flags for any target that +# will be built. +function(validate_and_setup_all_clp_dependency_flags) + if (CLP_BUILD_EXECUTABLES) + validate_clp_binaries_dependencies() + set_clp_binaries_dependencies() + endif() + + if (CLP_BUILD_TESTING) + validate_clp_tests_dependencies() + set_clp_tests_dependencies() + endif() + + if (CLP_BUILD_CLP_REGEX_UTILS) + validate_clp_regex_utils_dependencies() + set_clp_regex_utils_dependencies() + endif() + + # clp::string_utils has no dependencies + + if (CLP_BUILD_CLP_S_ARCHIVEREADER) + validate_clp_s_archivereader_dependencies() + set_clp_s_archivereader_dependencies() + endif() + + if (CLP_BUILD_CLP_S_ARCHIVEWRITER) + validate_clp_s_archivewriter_dependencies() + set_clp_s_archivewriter_dependencies() + endif() + + if (CLP_BUILD_CLP_S_CLP_DEPENDENCIES) + validate_clp_s_clp_dependencies_dependencies() + set_clp_s_clp_dependencies_dependencies() + endif() + + if (CLP_BUILD_CLP_S_IO) + validate_clp_s_io_dependencies() + set_clp_s_io_dependencies() + endif() + + if (CLP_BUILD_CLP_S_JSONCONSTRUCTOR) + validate_clp_s_json_constructor_dependencies() + set_clp_s_json_constructor_dependencies() + endif() + + if (CLP_BUILD_CLP_S_REDUCER_DEPENDENCIES) + validate_clp_s_reducer_dependencies_dependencies() + set_clp_s_reducer_dependencies_dependencies() + endif() + + if (CLP_BUILD_CLP_S_SEARCH) + validate_clp_s_search_dependencies() + set_clp_s_search_dependencies() + endif() + + if (CLP_BUILD_CLP_S_SEARCH_AST) + validate_clp_s_search_ast_dependencies() + set_clp_s_search_ast_dependencies() + endif() + + if (CLP_BUILD_CLP_S_SEARCH_KQL) + validate_clp_s_search_kql_dependencies() + set_clp_s_search_kql_dependencies() + endif() + + if (CLP_BUILD_CLP_S_SEARCH_SQL) + validate_clp_s_search_sql_dependencies() + set_clp_s_search_sql_dependencies() + endif() + + if (CLP_BUILD_CLP_S_TIMESTAMPPATTERN) + validate_clp_s_timestamppattern_dependencies() + set_clp_s_timestamppattern_dependencies() + endif() +endfunction() + +function (convert_clp_dependency_properties_to_variables) + list(APPEND CLP_NEED_FLAGS + CLP_NEED_ABSL + CLP_NEED_ANTLR + CLP_NEED_BOOST + CLP_NEED_CATCH2 + CLP_NEED_CURL + CLP_NEED_DATE + CLP_NEED_FMT + CLP_NEED_LOG_SURGEON + CLP_NEED_LIBARCHIVE + CLP_NEED_LZMA + CLP_NEED_MARIADB + CLP_NEED_MONGOCXX + CLP_NEED_MSGPACKCXX + CLP_NEED_NLOHMANN_JSON + CLP_NEED_OPENSSL + CLP_NEED_SIMDJSON + CLP_NEED_SPDLOG + CLP_NEED_SQLITE + CLP_NEED_YAMLCPP + CLP_NEED_YSTDLIB + CLP_NEED_ZSTD + ) + + foreach(FLAG IN LISTS CLP_NEED_FLAGS) + get_property(VALUE DIRECTORY PROPERTY "${FLAG}") + set("${FLAG}" "${VALUE}" PARENT_SCOPE) + endforeach() +endfunction() diff --git a/components/core/src/clp/clg/CMakeLists.txt b/components/core/src/clp/clg/CMakeLists.txt index 78524a93fe..b8e2f1962b 100644 --- a/components/core/src/clp/clg/CMakeLists.txt +++ b/components/core/src/clp/clg/CMakeLists.txt @@ -123,32 +123,34 @@ set( CommandLineArguments.hpp ) -add_executable(clg ${CLG_SOURCES}) -target_compile_features(clg PRIVATE cxx_std_20) -target_include_directories(clg - PRIVATE - "${CLP_SQLITE3_INCLUDE_DIRECTORY}" -) -target_link_libraries(clg - PRIVATE - Boost::filesystem Boost::program_options - date::date - fmt::fmt - log_surgeon::log_surgeon - MariaDBClient::MariaDBClient - nlohmann_json::nlohmann_json - spdlog::spdlog - ${sqlite_LIBRARY_DEPENDENCIES} - ${STD_FS_LIBS} - clp::string_utils - yaml-cpp - ystdlib::containers - ystdlib::error_handling - ZStd::ZStd -) -# Put the built executable at the root of the build directory -set_target_properties( - clg - PROPERTIES - RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}" -) +if(CLP_BUILD_EXECUTABLES) + add_executable(clg ${CLG_SOURCES}) + target_compile_features(clg PRIVATE cxx_std_20) + target_include_directories(clg + PRIVATE + "${CLP_SQLITE3_INCLUDE_DIRECTORY}" + ) + target_link_libraries(clg + PRIVATE + Boost::filesystem Boost::program_options + date::date + fmt::fmt + log_surgeon::log_surgeon + MariaDBClient::MariaDBClient + nlohmann_json::nlohmann_json + spdlog::spdlog + ${sqlite_LIBRARY_DEPENDENCIES} + ${STD_FS_LIBS} + clp::string_utils + yaml-cpp + ystdlib::containers + ystdlib::error_handling + ZStd::ZStd + ) + # Put the built executable at the root of the build directory + set_target_properties( + clg + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}" + ) +endif() diff --git a/components/core/src/clp/clo/CMakeLists.txt b/components/core/src/clp/clo/CMakeLists.txt index 79f8752858..a4cf0ddf47 100644 --- a/components/core/src/clp/clo/CMakeLists.txt +++ b/components/core/src/clp/clo/CMakeLists.txt @@ -151,32 +151,34 @@ set( ../../reducer/types.hpp ) -add_executable(clo ${CLO_SOURCES} ${REDUCER_SOURCES}) -target_compile_features(clo PRIVATE cxx_std_20) -target_include_directories(clo - PRIVATE - "${CLP_SQLITE3_INCLUDE_DIRECTORY}" -) -target_link_libraries(clo - PRIVATE - Boost::filesystem Boost::program_options - date::date - fmt::fmt - log_surgeon::log_surgeon - ${MONGOCXX_TARGET} - msgpack-cxx - nlohmann_json::nlohmann_json - spdlog::spdlog - ${sqlite_LIBRARY_DEPENDENCIES} - ${STD_FS_LIBS} - clp::string_utils - ystdlib::containers - ystdlib::error_handling - ZStd::ZStd -) -# Put the built executable at the root of the build directory -set_target_properties( - clo - PROPERTIES - RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}" -) +if(CLP_BUILD_EXECUTABLES) + add_executable(clo ${CLO_SOURCES} ${REDUCER_SOURCES}) + target_compile_features(clo PRIVATE cxx_std_20) + target_include_directories(clo + PRIVATE + "${CLP_SQLITE3_INCLUDE_DIRECTORY}" + ) + target_link_libraries(clo + PRIVATE + Boost::filesystem Boost::program_options + date::date + fmt::fmt + log_surgeon::log_surgeon + ${MONGOCXX_TARGET} + msgpack-cxx + nlohmann_json::nlohmann_json + spdlog::spdlog + ${sqlite_LIBRARY_DEPENDENCIES} + ${STD_FS_LIBS} + clp::string_utils + ystdlib::containers + ystdlib::error_handling + ZStd::ZStd + ) + # Put the built executable at the root of the build directory + set_target_properties( + clo + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}" + ) +endif() diff --git a/components/core/src/clp/clp/CMakeLists.txt b/components/core/src/clp/clp/CMakeLists.txt index d863aef750..c9782c509f 100644 --- a/components/core/src/clp/clp/CMakeLists.txt +++ b/components/core/src/clp/clp/CMakeLists.txt @@ -165,33 +165,35 @@ set( utils.hpp ) -add_executable(clp ${CLP_SOURCES}) -target_compile_features(clp PRIVATE cxx_std_20) -target_include_directories(clp - PRIVATE - "${CLP_SQLITE3_INCLUDE_DIRECTORY}" -) -target_link_libraries(clp - PRIVATE - Boost::filesystem Boost::program_options - date::date - fmt::fmt - log_surgeon::log_surgeon - spdlog::spdlog - ${sqlite_LIBRARY_DEPENDENCIES} - LibArchive::LibArchive - MariaDBClient::MariaDBClient - nlohmann_json::nlohmann_json - ${STD_FS_LIBS} - clp::string_utils - yaml-cpp - ystdlib::error_handling - ystdlib::containers - ZStd::ZStd -) -# Put the built executable at the root of the build directory -set_target_properties( - clp - PROPERTIES - RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}" -) +if(CLP_BUILD_EXECUTABLES) + add_executable(clp ${CLP_SOURCES}) + target_compile_features(clp PRIVATE cxx_std_20) + target_include_directories(clp + PRIVATE + "${CLP_SQLITE3_INCLUDE_DIRECTORY}" + ) + target_link_libraries(clp + PRIVATE + Boost::filesystem Boost::program_options + date::date + fmt::fmt + log_surgeon::log_surgeon + spdlog::spdlog + ${sqlite_LIBRARY_DEPENDENCIES} + LibArchive::LibArchive + MariaDBClient::MariaDBClient + nlohmann_json::nlohmann_json + ${STD_FS_LIBS} + clp::string_utils + yaml-cpp + ystdlib::containers + ystdlib::error_handling + ZStd::ZStd + ) + # Put the built executable at the root of the build directory + set_target_properties( + clp + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}" + ) +endif() diff --git a/components/core/src/clp/make_dictionaries_readable/CMakeLists.txt b/components/core/src/clp/make_dictionaries_readable/CMakeLists.txt index 01154bba7d..65bf33e03e 100644 --- a/components/core/src/clp/make_dictionaries_readable/CMakeLists.txt +++ b/components/core/src/clp/make_dictionaries_readable/CMakeLists.txt @@ -39,20 +39,22 @@ set( make-dictionaries-readable.cpp ) -add_executable(make-dictionaries-readable ${MAKE_DICTIONARIES_READABLE_SOURCES}) -target_compile_features(make-dictionaries-readable PRIVATE cxx_std_20) -target_link_libraries(make-dictionaries-readable - PRIVATE - Boost::filesystem Boost::program_options - log_surgeon::log_surgeon - spdlog::spdlog - clp::string_utils - ystdlib::containers - ZStd::ZStd -) -# Put the built executable at the root of the build directory -set_target_properties( - make-dictionaries-readable - PROPERTIES - RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}" -) +if(CLP_BUILD_EXECUTABLES) + add_executable(make-dictionaries-readable ${MAKE_DICTIONARIES_READABLE_SOURCES}) + target_compile_features(make-dictionaries-readable PRIVATE cxx_std_20) + target_link_libraries(make-dictionaries-readable + PRIVATE + Boost::filesystem Boost::program_options + log_surgeon::log_surgeon + spdlog::spdlog + clp::string_utils + ystdlib::containers + ZStd::ZStd + ) + # Put the built executable at the root of the build directory + set_target_properties( + make-dictionaries-readable + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}" + ) +endif() diff --git a/components/core/src/clp/regex_utils/CMakeLists.txt b/components/core/src/clp/regex_utils/CMakeLists.txt index 1f74c255e6..ecc3bc5553 100644 --- a/components/core/src/clp/regex_utils/CMakeLists.txt +++ b/components/core/src/clp/regex_utils/CMakeLists.txt @@ -5,21 +5,23 @@ set( "regex_translation_utils.hpp" "RegexToWildcardTranslatorConfig.hpp" ) -add_library( - regex_utils - ErrorCode.cpp - regex_translation_utils.cpp - ${REGEX_UTILS_HEADER_LIST} -) -add_library(clp::regex_utils ALIAS regex_utils) -target_include_directories(regex_utils - PUBLIC - ../ -) -target_link_libraries(regex_utils - PUBLIC - ystdlib::error_handling - PRIVATE - clp::string_utils -) -target_compile_features(regex_utils PRIVATE cxx_std_20) +if(CLP_BUILD_CLP_REGEX_UTILS) + add_library( + regex_utils + ErrorCode.cpp + regex_translation_utils.cpp + ${REGEX_UTILS_HEADER_LIST} + ) + add_library(clp::regex_utils ALIAS regex_utils) + target_include_directories(regex_utils + PUBLIC + ../ + ) + target_link_libraries(regex_utils + PUBLIC + ystdlib::error_handling + PRIVATE + clp::string_utils + ) + target_compile_features(regex_utils PRIVATE cxx_std_20) +endif() diff --git a/components/core/src/clp/string_utils/CMakeLists.txt b/components/core/src/clp/string_utils/CMakeLists.txt index 3759938e5e..2bc2e9be02 100644 --- a/components/core/src/clp/string_utils/CMakeLists.txt +++ b/components/core/src/clp/string_utils/CMakeLists.txt @@ -2,11 +2,13 @@ set( STRING_UTILS_HEADER_LIST "string_utils.hpp" ) -add_library( - string_utils - string_utils.cpp - ${STRING_UTILS_HEADER_LIST} -) -add_library(clp::string_utils ALIAS string_utils) -target_include_directories(string_utils PUBLIC ../) -target_compile_features(string_utils PRIVATE cxx_std_20) +if(CLP_BUILD_CLP_STRING_UTILS) + add_library( + string_utils + string_utils.cpp + ${STRING_UTILS_HEADER_LIST} + ) + add_library(clp::string_utils ALIAS string_utils) + target_include_directories(string_utils PUBLIC ../) + target_compile_features(string_utils PRIVATE cxx_std_20) +endif() diff --git a/components/core/src/clp_s/CMakeLists.txt b/components/core/src/clp_s/CMakeLists.txt index ecb8518374..9b4ad3daa9 100644 --- a/components/core/src/clp_s/CMakeLists.txt +++ b/components/core/src/clp_s/CMakeLists.txt @@ -81,27 +81,29 @@ set( ) # This library is intended as a temporary stand-in until clp has been packaged into libraries. -add_library( - clp_s_clp_dependencies - ${CLP_S_CLP_SOURCES} -) -add_library(clp_s::clp_dependencies ALIAS clp_s_clp_dependencies) -target_compile_features(clp_s_clp_dependencies PRIVATE cxx_std_20) -target_link_libraries( - clp_s_clp_dependencies - PUBLIC - clp::string_utils - ystdlib::containers - PRIVATE - Boost::regex - ${CURL_LIBRARIES} - fmt::fmt - spdlog::spdlog - nlohmann_json::nlohmann_json - OpenSSL::Crypto - ystdlib::error_handling - ZStd::ZStd -) +if(CLP_BUILD_CLP_S_CLP_DEPENDENCIES) + add_library( + clp_s_clp_dependencies + ${CLP_S_CLP_SOURCES} + ) + add_library(clp_s::clp_dependencies ALIAS clp_s_clp_dependencies) + target_compile_features(clp_s_clp_dependencies PRIVATE cxx_std_20) + target_link_libraries( + clp_s_clp_dependencies + PUBLIC + clp::string_utils + ystdlib::containers + PRIVATE + Boost::regex + ${CURL_LIBRARIES} + fmt::fmt + spdlog::spdlog + nlohmann_json::nlohmann_json + OpenSSL::Crypto + ystdlib::error_handling + ZStd::ZStd + ) +endif() set( CLP_S_REDUCER_SOURCES @@ -128,19 +130,21 @@ set( # This library is intended as a temporary stand-in until the reducer has been packaged into # libraries. -add_library( - clp_s_reducer_dependencies - ${CLP_S_REDUCER_SOURCES} -) -add_library(clp_s::reducer_dependencies ALIAS clp_s_reducer_dependencies) -target_compile_features(clp_s_reducer_dependencies PRIVATE cxx_std_20) -target_link_libraries( - clp_s_reducer_dependencies - PUBLIC - nlohmann_json::nlohmann_json - PRIVATE - clp_s::clp_dependencies -) +if(CLP_BUILD_CLP_S_REDUCER_DEPENDENCIES) + add_library( + clp_s_reducer_dependencies + ${CLP_S_REDUCER_SOURCES} + ) + add_library(clp_s::reducer_dependencies ALIAS clp_s_reducer_dependencies) + target_compile_features(clp_s_reducer_dependencies PRIVATE cxx_std_20) + target_link_libraries( + clp_s_reducer_dependencies + PUBLIC + nlohmann_json::nlohmann_json + PRIVATE + clp_s::clp_dependencies + ) +endif() set( CLP_S_IO_SOURCES @@ -162,22 +166,24 @@ set( ZstdDecompressor.hpp ) -add_library( - clp_s_io - ${CLP_S_IO_SOURCES} -) -add_library(clp_s::io ALIAS clp_s_io) -target_compile_features(clp_s_io PRIVATE cxx_std_20) -target_include_directories(clp_s_io PUBLIC ../) -target_link_libraries( - clp_s_io - PRIVATE - Boost::iostreams Boost::url - clp_s::clp_dependencies - fmt::fmt - spdlog::spdlog - ZStd::ZStd -) +if(CLP_BUILD_CLP_S_IO) + add_library( + clp_s_io + ${CLP_S_IO_SOURCES} + ) + add_library(clp_s::io ALIAS clp_s_io) + target_compile_features(clp_s_io PRIVATE cxx_std_20) + target_include_directories(clp_s_io PUBLIC ../) + target_link_libraries( + clp_s_io + PRIVATE + Boost::iostreams Boost::url + clp_s::clp_dependencies + fmt::fmt + spdlog::spdlog + ZStd::ZStd + ) +endif() set( CLP_S_ARCHIVE_WRITER_SOURCES @@ -220,29 +226,31 @@ set( VariableEncoder.hpp ) -add_library( - clp_s_archive_writer - ${CLP_S_ARCHIVE_WRITER_SOURCES} -) -add_library(clp_s::archive_writer ALIAS clp_s_archive_writer) -target_compile_features(clp_s_archive_writer PRIVATE cxx_std_20) -target_include_directories(clp_s_archive_writer PUBLIC ../) -target_link_libraries( - clp_s_archive_writer - PUBLIC - absl::flat_hash_map - clp_s::io - nlohmann_json::nlohmann_json - simdjson::simdjson - PRIVATE - Boost::url - clp_s::clp_dependencies - clp_s::timestamp_pattern - ${CURL_LIBRARIES} - fmt::fmt - msgpack-cxx - spdlog::spdlog -) +if(CLP_BUILD_CLP_S_ARCHIVEWRITER) + add_library( + clp_s_archive_writer + ${CLP_S_ARCHIVE_WRITER_SOURCES} + ) + add_library(clp_s::archive_writer ALIAS clp_s_archive_writer) + target_compile_features(clp_s_archive_writer PRIVATE cxx_std_20) + target_include_directories(clp_s_archive_writer PUBLIC ../) + target_link_libraries( + clp_s_archive_writer + PUBLIC + absl::flat_hash_map + clp_s::io + nlohmann_json::nlohmann_json + simdjson::simdjson + PRIVATE + Boost::url + clp_s::clp_dependencies + clp_s::timestamp_pattern + ${CURL_LIBRARIES} + fmt::fmt + msgpack-cxx + spdlog::spdlog + ) +endif() set( CLP_S_ARCHIVE_READER_SOURCES @@ -281,28 +289,30 @@ set( VariableDecoder.hpp ) -add_library( - clp_s_archive_reader - ${CLP_S_ARCHIVE_READER_SOURCES} -) -add_library(clp_s::archive_reader ALIAS clp_s_archive_reader) -target_compile_features(clp_s_archive_reader PRIVATE cxx_std_20) -target_include_directories(clp_s_archive_reader PUBLIC ../) -target_link_libraries( - clp_s_archive_reader - PUBLIC - absl::flat_hash_map - clp_s::io - nlohmann_json::nlohmann_json - PRIVATE - Boost::url - clp_s::clp_dependencies - clp_s::timestamp_pattern - ${CURL_LIBRARIES} - fmt::fmt - msgpack-cxx - spdlog::spdlog -) +if(CLP_BUILD_CLP_S_ARCHIVEREADER) + add_library( + clp_s_archive_reader + ${CLP_S_ARCHIVE_READER_SOURCES} + ) + add_library(clp_s::archive_reader ALIAS clp_s_archive_reader) + target_compile_features(clp_s_archive_reader PRIVATE cxx_std_20) + target_include_directories(clp_s_archive_reader PUBLIC ../) + target_link_libraries( + clp_s_archive_reader + PUBLIC + absl::flat_hash_map + clp_s::io + nlohmann_json::nlohmann_json + PRIVATE + Boost::url + clp_s::clp_dependencies + clp_s::timestamp_pattern + ${CURL_LIBRARIES} + fmt::fmt + msgpack-cxx + spdlog::spdlog + ) +endif() set( CLP_S_JSON_CONSTRUCTOR_SOURCES @@ -312,22 +322,24 @@ set( TraceableException.hpp ) -add_library( - clp_s_json_constructor - ${CLP_S_JSON_CONSTRUCTOR_SOURCES} -) -add_library(clp_s::json_constructor ALIAS clp_s_json_constructor) -target_compile_features(clp_s_json_constructor PRIVATE cxx_std_20) -target_include_directories(clp_s_json_constructor PUBLIC ../) -target_link_libraries( - clp_s_json_constructor - PUBLIC - clp_s::archive_reader - PRIVATE - fmt::fmt - ${MONGOCXX_TARGET} - spdlog::spdlog -) +if(CLP_BUILD_CLP_S_JSONCONSTRUCTOR) + add_library( + clp_s_json_constructor + ${CLP_S_JSON_CONSTRUCTOR_SOURCES} + ) + add_library(clp_s::json_constructor ALIAS clp_s_json_constructor) + target_compile_features(clp_s_json_constructor PRIVATE cxx_std_20) + target_include_directories(clp_s_json_constructor PUBLIC ../) + target_link_libraries( + clp_s_json_constructor + PUBLIC + clp_s::archive_reader + PRIVATE + fmt::fmt + ${MONGOCXX_TARGET} + spdlog::spdlog + ) +endif() set( CLP_S_TIMESTAMP_PATTERN_SOURCES @@ -338,20 +350,22 @@ set( TraceableException.hpp ) -add_library( - clp_s_timestamp_pattern - ${CLP_S_TIMESTAMP_PATTERN_SOURCES} -) -add_library(clp_s::timestamp_pattern ALIAS clp_s_timestamp_pattern) -target_compile_features(clp_s_timestamp_pattern PRIVATE cxx_std_20) -target_include_directories(clp_s_timestamp_pattern PUBLIC ../) -target_link_libraries( - clp_s_timestamp_pattern - PRIVATE - clp::string_utils - date::date - spdlog::spdlog -) +if(CLP_BUILD_CLP_S_TIMESTAMPPATTERN) + add_library( + clp_s_timestamp_pattern + ${CLP_S_TIMESTAMP_PATTERN_SOURCES} + ) + add_library(clp_s::timestamp_pattern ALIAS clp_s_timestamp_pattern) + target_compile_features(clp_s_timestamp_pattern PRIVATE cxx_std_20) + target_include_directories(clp_s_timestamp_pattern PUBLIC ../) + target_link_libraries( + clp_s_timestamp_pattern + PRIVATE + clp::string_utils + date::date + spdlog::spdlog + ) +endif() set( CLP_S_EXE_SOURCES @@ -365,32 +379,34 @@ set( TraceableException.hpp ) -add_executable( - clp-s - clp-s.cpp - ${CLP_S_EXE_SOURCES} -) -target_compile_features(clp-s PRIVATE cxx_std_20) -target_link_libraries( - clp-s - PRIVATE - Boost::program_options - clp_s::archive_reader - clp_s::archive_writer - clp_s::clp_dependencies - clp_s::io - clp_s::json_constructor - clp_s::reducer_dependencies - clp_s::search - clp_s::search::ast - clp_s::search::kql - ${MONGOCXX_TARGET} - msgpack-cxx - spdlog::spdlog - ystdlib::error_handling -) -set_target_properties( - clp-s - PROPERTIES - RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}" -) +if(CLP_BUILD_EXECUTABLES) + add_executable( + clp-s + clp-s.cpp + ${CLP_S_EXE_SOURCES} + ) + target_compile_features(clp-s PRIVATE cxx_std_20) + target_link_libraries( + clp-s + PRIVATE + Boost::program_options + clp_s::archive_reader + clp_s::archive_writer + clp_s::clp_dependencies + clp_s::io + clp_s::json_constructor + clp_s::reducer_dependencies + clp_s::search + clp_s::search::ast + clp_s::search::kql + ${MONGOCXX_TARGET} + msgpack-cxx + spdlog::spdlog + ystdlib::error_handling + ) + set_target_properties( + clp-s + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}" + ) +endif() diff --git a/components/core/src/clp_s/indexer/CMakeLists.txt b/components/core/src/clp_s/indexer/CMakeLists.txt index 5966764f27..20e9e9a1e0 100644 --- a/components/core/src/clp_s/indexer/CMakeLists.txt +++ b/components/core/src/clp_s/indexer/CMakeLists.txt @@ -80,27 +80,29 @@ set( MySQLIndexStorage.hpp ) -add_executable(indexer ${INDEXER_SOURCES}) -target_compile_features(indexer PRIVATE cxx_std_20) -target_link_libraries(indexer - PRIVATE - absl::flat_hash_map - Boost::iostreams Boost::program_options Boost::url - ${CURL_LIBRARIES} - clp::string_utils - date::date - MariaDBClient::MariaDBClient - nlohmann_json::nlohmann_json - OpenSSL::Crypto - simdjson::simdjson - spdlog::spdlog - yaml-cpp - ystdlib::containers - ZStd::ZStd -) -# Put the built executable at the root of the build directory -set_target_properties( - indexer - PROPERTIES - RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}" -) +if(CLP_BUILD_EXECUTABLES) + add_executable(indexer ${INDEXER_SOURCES}) + target_compile_features(indexer PRIVATE cxx_std_20) + target_link_libraries(indexer + PRIVATE + absl::flat_hash_map + Boost::iostreams Boost::program_options Boost::url + ${CURL_LIBRARIES} + clp::string_utils + date::date + MariaDBClient::MariaDBClient + nlohmann_json::nlohmann_json + OpenSSL::Crypto + simdjson::simdjson + spdlog::spdlog + yaml-cpp + ystdlib::containers + ZStd::ZStd + ) + # Put the built executable at the root of the build directory + set_target_properties( + indexer + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}" + ) +endif() diff --git a/components/core/src/clp_s/search/CMakeLists.txt b/components/core/src/clp_s/search/CMakeLists.txt index 8a32b3be9f..0fe3b6a895 100644 --- a/components/core/src/clp_s/search/CMakeLists.txt +++ b/components/core/src/clp_s/search/CMakeLists.txt @@ -30,21 +30,23 @@ set( SchemaMatch.hpp ) -add_library( - clp_s_search - ${CLP_S_SEARCH_SOURCES} -) -add_library(clp_s::search ALIAS clp_s_search) -target_compile_features(clp_s_search PRIVATE cxx_std_20) -target_include_directories(clp_s_search PUBLIC ../../) -target_link_libraries( - clp_s_search - PUBLIC - absl::flat_hash_map - clp_s::archive_reader - clp_s::search::ast - simdjson::simdjson - PRIVATE - clp_s::clp_dependencies - spdlog::spdlog -) +if(CLP_BUILD_CLP_S_SEARCH) + add_library( + clp_s_search + ${CLP_S_SEARCH_SOURCES} + ) + add_library(clp_s::search ALIAS clp_s_search) + target_compile_features(clp_s_search PRIVATE cxx_std_20) + target_include_directories(clp_s_search PUBLIC ../../) + target_link_libraries( + clp_s_search + PUBLIC + absl::flat_hash_map + clp_s::archive_reader + clp_s::search::ast + simdjson::simdjson + PRIVATE + clp_s::clp_dependencies + spdlog::spdlog + ) +endif() diff --git a/components/core/src/clp_s/search/ast/CMakeLists.txt b/components/core/src/clp_s/search/ast/CMakeLists.txt index 31afec5b01..eda1c26a3f 100644 --- a/components/core/src/clp_s/search/ast/CMakeLists.txt +++ b/components/core/src/clp_s/search/ast/CMakeLists.txt @@ -49,18 +49,20 @@ set( ../../TraceableException.hpp ) -add_library( - clp_s_search_ast - ${CLP_S_AST_SOURCES} - ${CLP_S_CORE_SOURCES} -) -add_library(clp_s::search::ast ALIAS clp_s_search_ast) -target_compile_features(clp_s_search_ast PRIVATE cxx_std_20) -target_include_directories(clp_s_search_ast PUBLIC ../../../) -target_link_libraries( - clp_s_search_ast - PUBLIC - clp_s::timestamp_pattern - PRIVATE - simdjson::simdjson -) +if(CLP_BUILD_CLP_S_SEARCH_AST) + add_library( + clp_s_search_ast + ${CLP_S_AST_SOURCES} + ${CLP_S_CORE_SOURCES} + ) + add_library(clp_s::search::ast ALIAS clp_s_search_ast) + target_compile_features(clp_s_search_ast PRIVATE cxx_std_20) + target_include_directories(clp_s_search_ast PUBLIC ../../../) + target_link_libraries( + clp_s_search_ast + PUBLIC + clp_s::timestamp_pattern + PRIVATE + simdjson::simdjson + ) +endif() diff --git a/components/core/src/clp_s/search/kql/CMakeLists.txt b/components/core/src/clp_s/search/kql/CMakeLists.txt index 7919201700..5fd7ecc58d 100644 --- a/components/core/src/clp_s/search/kql/CMakeLists.txt +++ b/components/core/src/clp_s/search/kql/CMakeLists.txt @@ -11,25 +11,27 @@ set(ANTLR_GENERATED_SOURCES ${ANTLR_GENERATED_SOURCE_DIR}/KqlVisitor.h ) -add_library( - clp_s_search_kql - ${ANTLR_GENERATED_SOURCES} - ../antlr_common/ErrorListener.hpp - kql.cpp - kql.hpp -) -add_library(clp_s::search::kql ALIAS clp_s_search_kql) -target_compile_features(clp_s_search_kql PRIVATE cxx_std_20) -target_include_directories(clp_s_search_kql - PRIVATE - ${ANTLR_GENERATED_SOURCE_DIR} -) +if(CLP_BUILD_CLP_S_SEARCH_KQL) + add_library( + clp_s_search_kql + ${ANTLR_GENERATED_SOURCES} + ../antlr_common/ErrorListener.hpp + kql.cpp + kql.hpp + ) + add_library(clp_s::search::kql ALIAS clp_s_search_kql) + target_compile_features(clp_s_search_kql PRIVATE cxx_std_20) + target_include_directories(clp_s_search_kql + PRIVATE + ${ANTLR_GENERATED_SOURCE_DIR} + ) -target_link_libraries( - clp_s_search_kql - PRIVATE - antlr4_static - clp::string_utils - clp_s::search::ast - spdlog::spdlog -) + target_link_libraries( + clp_s_search_kql + PRIVATE + antlr4_static + clp::string_utils + clp_s::search::ast + spdlog::spdlog + ) +endif() diff --git a/components/core/src/clp_s/search/sql/CMakeLists.txt b/components/core/src/clp_s/search/sql/CMakeLists.txt index 9e4ce19d5f..7e62d7d493 100644 --- a/components/core/src/clp_s/search/sql/CMakeLists.txt +++ b/components/core/src/clp_s/search/sql/CMakeLists.txt @@ -11,24 +11,26 @@ set(ANTLR_GENERATED_SOURCES ${ANTLR_GENERATED_SOURCE_DIR}/SqlVisitor.h ) -add_library( - clp_s_search_sql - ${ANTLR_GENERATED_SOURCES} - ../antlr_common/ErrorListener.hpp - sql.cpp - sql.hpp -) -add_library(clp_s::search::sql ALIAS clp_s_search_sql) -target_compile_features(clp_s_search_sql PRIVATE cxx_std_20) -target_include_directories(clp_s_search_sql - PRIVATE - ${ANTLR_GENERATED_SOURCE_DIR} -) +if(CLP_BUILD_CLP_S_SEARCH_SQL) + add_library( + clp_s_search_sql + ${ANTLR_GENERATED_SOURCES} + ../antlr_common/ErrorListener.hpp + sql.cpp + sql.hpp + ) + add_library(clp_s::search::sql ALIAS clp_s_search_sql) + target_compile_features(clp_s_search_sql PRIVATE cxx_std_20) + target_include_directories(clp_s_search_sql + PRIVATE + ${ANTLR_GENERATED_SOURCE_DIR} + ) -target_link_libraries( - clp_s_search_sql - PRIVATE - antlr4_static - clp_s::search::ast - spdlog::spdlog -) + target_link_libraries( + clp_s_search_sql + PRIVATE + antlr4_static + clp_s::search::ast + spdlog::spdlog + ) +endif() diff --git a/components/core/src/glt/glt/CMakeLists.txt b/components/core/src/glt/glt/CMakeLists.txt index e64ea60fac..8576f391f5 100644 --- a/components/core/src/glt/glt/CMakeLists.txt +++ b/components/core/src/glt/glt/CMakeLists.txt @@ -171,31 +171,33 @@ set( utils.hpp ) -add_executable(glt ${GLT_SOURCES}) -target_compile_features(glt PRIVATE cxx_std_20) -target_include_directories(glt - PRIVATE - "${CLP_SQLITE3_INCLUDE_DIRECTORY}" -) -target_link_libraries(glt - PRIVATE - Boost::filesystem Boost::iostreams Boost::program_options - date::date - fmt::fmt - spdlog::spdlog - ${sqlite_LIBRARY_DEPENDENCIES} - LibArchive::LibArchive - MariaDBClient::MariaDBClient - nlohmann_json::nlohmann_json - ${STD_FS_LIBS} - clp::string_utils - yaml-cpp - ystdlib::error_handling - ZStd::ZStd -) -# Put the built executable at the root of the build directory -set_target_properties( - glt - PROPERTIES - RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}" -) +if(CLP_BUILD_EXECUTABLES) + add_executable(glt ${GLT_SOURCES}) + target_compile_features(glt PRIVATE cxx_std_20) + target_include_directories(glt + PRIVATE + "${CLP_SQLITE3_INCLUDE_DIRECTORY}" + ) + target_link_libraries(glt + PRIVATE + Boost::filesystem Boost::iostreams Boost::program_options + date::date + fmt::fmt + spdlog::spdlog + ${sqlite_LIBRARY_DEPENDENCIES} + LibArchive::LibArchive + MariaDBClient::MariaDBClient + nlohmann_json::nlohmann_json + ${STD_FS_LIBS} + clp::string_utils + yaml-cpp + ystdlib::error_handling + ZStd::ZStd + ) + # Put the built executable at the root of the build directory + set_target_properties( + glt + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}" + ) +endif() diff --git a/components/core/src/reducer/CMakeLists.txt b/components/core/src/reducer/CMakeLists.txt index 72b4cf1a24..ec830624b8 100644 --- a/components/core/src/reducer/CMakeLists.txt +++ b/components/core/src/reducer/CMakeLists.txt @@ -38,22 +38,24 @@ set( types.hpp ) -add_executable(reducer-server ${REDUCER_SOURCES}) -target_compile_features(reducer-server PRIVATE cxx_std_20) -target_link_libraries(reducer-server - PRIVATE - Boost::program_options - Boost::system - clp::string_utils - fmt::fmt - ${MONGOCXX_TARGET} - msgpack-cxx - nlohmann_json::nlohmann_json - spdlog::spdlog -) -# Put the built executable at the root of the build directory -set_target_properties( - reducer-server - PROPERTIES - RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}" -) +if(CLP_BUILD_EXECUTABLES) + add_executable(reducer-server ${REDUCER_SOURCES}) + target_compile_features(reducer-server PRIVATE cxx_std_20) + target_link_libraries(reducer-server + PRIVATE + Boost::program_options + Boost::system + clp::string_utils + fmt::fmt + ${MONGOCXX_TARGET} + msgpack-cxx + nlohmann_json::nlohmann_json + spdlog::spdlog + ) + # Put the built executable at the root of the build directory + set_target_properties( + reducer-server + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}" + ) +endif()