add cmake flags

This commit is contained in:
Vladimir Makarov 2022-05-13 10:37:04 +00:00
parent b6fbf0da07
commit 5b69e4cc43
5 changed files with 26 additions and 4 deletions

View File

@ -91,7 +91,6 @@ add_contrib (protobuf-cmake protobuf)
add_contrib (openldap-cmake openldap) add_contrib (openldap-cmake openldap)
add_contrib (grpc-cmake grpc) add_contrib (grpc-cmake grpc)
add_contrib (msgpack-c-cmake msgpack-c) add_contrib (msgpack-c-cmake msgpack-c)
add_contrib (spotify-annoy-cmake spotify-annoy)
if (ENABLE_FUZZING) if (ENABLE_FUZZING)
add_contrib (libprotobuf-mutator-cmake libprotobuf-mutator) add_contrib (libprotobuf-mutator-cmake libprotobuf-mutator)
@ -151,6 +150,19 @@ endif()
add_contrib (sqlite-cmake sqlite-amalgamation) add_contrib (sqlite-cmake sqlite-amalgamation)
add_contrib (s2geometry-cmake s2geometry) add_contrib (s2geometry-cmake s2geometry)
set (ENABLE_ANNOY_DEFAULT ${ENABLE_LIBRARIES})
option(ENABLE_ANNOY "Enable Annoy index support" ${ENABLE_ANNOY_DEFAULT})
if (NOT CMAKE_SYSTEM_NAME MATCHES "Linux" OR NOT COMPILER_CLANG OR NOT CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 13.0.1)
message (WARNING "Annoy disabled. Supports only in Linux environment and Clang-13.0.1.")
set (ENABLE_ANNOY OFF PARENT_SCOPE)
set (ENABLE_ANNOY OFF)
endif ()
if (ENABLE_ANNOY)
message("Use Annoy library")
add_compile_definitions(ENABLE_ANNOY)
add_contrib (spotify-annoy-cmake spotify-annoy)
endif()
# Put all targets defined here and in subdirectories under "contrib/<immediate-subdir>" folders in GUI-based IDEs. # Put all targets defined here and in subdirectories under "contrib/<immediate-subdir>" folders in GUI-based IDEs.
# Some of third-party projects may override CMAKE_FOLDER or FOLDER property of their targets, so they would not appear # Some of third-party projects may override CMAKE_FOLDER or FOLDER property of their targets, so they would not appear
# in "contrib/..." as originally planned, so we workaround this by fixing FOLDER properties of all targets manually, # in "contrib/..." as originally planned, so we workaround this by fixing FOLDER properties of all targets manually,

View File

@ -530,7 +530,9 @@ if (TARGET ch_contrib::rapidjson)
endif() endif()
dbms_target_link_libraries(PUBLIC ch_contrib::consistent_hashing) dbms_target_link_libraries(PUBLIC ch_contrib::consistent_hashing)
dbms_target_link_libraries(PUBLIC ch_contrib::spotify-annoy) if (ENABLE_ANNOY)
dbms_target_link_libraries(PUBLIC ch_contrib::spotify-annoy)
endif()
include ("${ClickHouse_SOURCE_DIR}/cmake/add_check.cmake") include ("${ClickHouse_SOURCE_DIR}/cmake/add_check.cmake")

View File

@ -1,3 +1,5 @@
#ifdef ENABLE_ANNOY
#include <Storages/MergeTree/MergeTreeIndexAnnoy.h> #include <Storages/MergeTree/MergeTreeIndexAnnoy.h>
#include <IO/ReadHelpers.h> #include <IO/ReadHelpers.h>
#include <IO/WriteHelpers.h> #include <IO/WriteHelpers.h>
@ -257,3 +259,4 @@ void AnnoyIndexValidator(const IndexDescription & index, bool /* attach */)
} }
} }
#endif // ENABLE_ANNOY

View File

@ -1,5 +1,6 @@
#pragma once #pragma once
#ifdef ENABLE_ANNOY
#include <Storages/MergeTree/CommonANNIndexes.h> #include <Storages/MergeTree/CommonANNIndexes.h>
#include <Storages/MergeTree/MergeTreeIndices.h> #include <Storages/MergeTree/MergeTreeIndices.h>
@ -119,3 +120,5 @@ private:
} }
#endif // ENABLE_ANNOY

View File

@ -102,8 +102,10 @@ MergeTreeIndexFactory::MergeTreeIndexFactory()
registerCreator("hypothesis", hypothesisIndexCreator); registerCreator("hypothesis", hypothesisIndexCreator);
registerValidator("hypothesis", hypothesisIndexValidator); registerValidator("hypothesis", hypothesisIndexValidator);
registerCreator("annoy", AnnoyIndexCreator); #ifdef ENABLE_ANNOY
registerValidator("annoy", AnnoyIndexValidator); registerCreator("annoy", AnnoyIndexCreator);
registerValidator("annoy", AnnoyIndexValidator);
#endif
} }
MergeTreeIndexFactory & MergeTreeIndexFactory::instance() MergeTreeIndexFactory & MergeTreeIndexFactory::instance()