From db468b6fae44698834288793700750a86e0649f1 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Mon, 17 Jan 2022 22:29:50 +0300 Subject: [PATCH] Remove unbundled simdjson support --- CMakeLists.txt | 1 - cmake/find/simdjson.cmake | 11 ----------- contrib/CMakeLists.txt | 4 +--- contrib/simdjson-cmake/CMakeLists.txt | 15 ++++++++++++--- src/CMakeLists.txt | 4 ++-- src/Functions/CMakeLists.txt | 4 ++-- src/configure_config.cmake | 3 +++ 7 files changed, 20 insertions(+), 22 deletions(-) delete mode 100644 cmake/find/simdjson.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c6dbdeb109..270c1a95217 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -505,7 +505,6 @@ include (cmake/find/curl.cmake) include (cmake/find/s3.cmake) include (cmake/find/blob_storage.cmake) include (cmake/find/base64.cmake) -include (cmake/find/simdjson.cmake) include (cmake/find/fast_float.cmake) include (cmake/find/rapidjson.cmake) include (cmake/find/fastops.cmake) diff --git a/cmake/find/simdjson.cmake b/cmake/find/simdjson.cmake deleted file mode 100644 index bf22a331f04..00000000000 --- a/cmake/find/simdjson.cmake +++ /dev/null @@ -1,11 +0,0 @@ -option (USE_SIMDJSON "Use simdjson" ${ENABLE_LIBRARIES}) - -if (NOT EXISTS "${ClickHouse_SOURCE_DIR}/contrib/simdjson/include/simdjson.h") - message (WARNING "submodule contrib/simdjson is missing. to fix try run: \n git submodule update --init") - if (USE_SIMDJSON) - message (${RECONFIGURE_MESSAGE_LEVEL} "Can't find internal simdjson library") - endif() - return() -endif () - -message(STATUS "Using simdjson=${USE_SIMDJSON}") diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index d4b5ea38bcd..1d88219accc 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -141,9 +141,7 @@ if (USE_BASE64) add_subdirectory (base64-cmake) endif() -if (USE_SIMDJSON) - add_subdirectory (simdjson-cmake) -endif() +add_subdirectory (simdjson-cmake) if (USE_FASTOPS) add_subdirectory (fastops-cmake) diff --git a/contrib/simdjson-cmake/CMakeLists.txt b/contrib/simdjson-cmake/CMakeLists.txt index bb9a5844def..ab2840f5b7f 100644 --- a/contrib/simdjson-cmake/CMakeLists.txt +++ b/contrib/simdjson-cmake/CMakeLists.txt @@ -1,11 +1,20 @@ +option (ENABLE_SIMDJSON "Use simdjson" ${ENABLE_LIBRARIES}) + +if (NOT ENABLE_SIMDJSON) + message(STATUS "Not using simdjson") + return() +endif() + set(SIMDJSON_INCLUDE_DIR "${ClickHouse_SOURCE_DIR}/contrib/simdjson/include") set(SIMDJSON_SRC_DIR "${ClickHouse_SOURCE_DIR}/contrib/simdjson/src") set(SIMDJSON_SRC "${SIMDJSON_SRC_DIR}/simdjson.cpp") -add_library(simdjson ${SIMDJSON_SRC}) -target_include_directories(simdjson SYSTEM PUBLIC "${SIMDJSON_INCLUDE_DIR}" PRIVATE "${SIMDJSON_SRC_DIR}") +add_library(_simdjson ${SIMDJSON_SRC}) +target_include_directories(_simdjson SYSTEM PUBLIC "${SIMDJSON_INCLUDE_DIR}" PRIVATE "${SIMDJSON_SRC_DIR}") # simdjson is using its own CPU dispatching and get confused if we enable AVX/AVX2 flags. if(ARCH_AMD64) - target_compile_options(simdjson PRIVATE -mno-avx -mno-avx2) + target_compile_options(_simdjson PRIVATE -mno-avx -mno-avx2) endif() + +add_library(ch_contrib::simdjson ALIAS _simdjson) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 166dd82ff0f..bbcb7c6c9e9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -504,8 +504,8 @@ if (TARGET ch_contrib::bzip2) target_link_libraries (clickhouse_common_io PRIVATE ch_contrib::bzip2) endif() -if(USE_SIMDJSON) - dbms_target_link_libraries(PRIVATE simdjson) +if (TARGET ch_contrib::simdjson) + dbms_target_link_libraries(PRIVATE ch_contrib::simdjson) endif() if(USE_RAPIDJSON) diff --git a/src/Functions/CMakeLists.txt b/src/Functions/CMakeLists.txt index 0fc43b65634..659c1215a9c 100644 --- a/src/Functions/CMakeLists.txt +++ b/src/Functions/CMakeLists.txt @@ -85,8 +85,8 @@ endif() target_link_libraries(clickhouse_functions PRIVATE hyperscan) -if(USE_SIMDJSON) - target_link_libraries(clickhouse_functions PRIVATE simdjson) +if (TARGET ch_contrib::simdjson) + target_link_libraries(clickhouse_functions PRIVATE ch_contrib::simdjson) endif() if(USE_RAPIDJSON) diff --git a/src/configure_config.cmake b/src/configure_config.cmake index d18a77d525b..56144a3ecf0 100644 --- a/src/configure_config.cmake +++ b/src/configure_config.cmake @@ -34,3 +34,6 @@ endif() if (TARGET ch_contrib::icu) set(USE_ICU 1) endif() +if (TARGET ch_contrib::simdjson) + set(USE_SIMDJSON 1) +endif()