diff --git a/CMakeLists.txt b/CMakeLists.txt index 16716e91d86..7a453071b86 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -509,7 +509,6 @@ include (cmake/find/libpqxx.cmake) include (cmake/find/yaml-cpp.cmake) include (cmake/find/nlp.cmake) include (cmake/find/filelog.cmake) -include (cmake/find/msgpack.cmake) include (cmake/find/sentry.cmake) include (cmake/find/datasketches.cmake) diff --git a/cmake/find/msgpack.cmake b/cmake/find/msgpack.cmake deleted file mode 100644 index ac52740c774..00000000000 --- a/cmake/find/msgpack.cmake +++ /dev/null @@ -1,37 +0,0 @@ -option (ENABLE_MSGPACK "Enable msgpack library" ${ENABLE_LIBRARIES}) - -if(NOT ENABLE_MSGPACK) - if(USE_INTERNAL_MSGPACK_LIBRARY) - message (${RECONFIGURE_MESSAGE_LEVEL} "Cannot use internal msgpack with ENABLE_MSGPACK=OFF") - endif() - return() -endif() - -option (USE_INTERNAL_MSGPACK_LIBRARY "Set to FALSE to use system msgpack library instead of bundled" ON) - -if(NOT EXISTS "${ClickHouse_SOURCE_DIR}/contrib/msgpack-c/include/msgpack.hpp") - if(USE_INTERNAL_MSGPACK_LIBRARY) - message(WARNING "Submodule contrib/msgpack-c is missing. To fix try run: \n git submodule update --init") - message (${RECONFIGURE_MESSAGE_LEVEL} "Cannot use internal msgpack") - set(USE_INTERNAL_MSGPACK_LIBRARY 0) - endif() - set(MISSING_INTERNAL_MSGPACK_LIBRARY 1) -endif() - -if(NOT USE_INTERNAL_MSGPACK_LIBRARY) - find_path(MSGPACK_INCLUDE_DIR NAMES msgpack.hpp PATHS ${MSGPACK_INCLUDE_PATHS}) - if(NOT MSGPACK_INCLUDE_DIR) - message (${RECONFIGURE_MESSAGE_LEVEL} "Can't find system msgpack") - endif() -endif() - -if(NOT MSGPACK_INCLUDE_DIR AND NOT MISSING_INTERNAL_MSGPACK_LIBRARY) - set(MSGPACK_INCLUDE_DIR "${ClickHouse_SOURCE_DIR}/contrib/msgpack-c/include") - set(USE_INTERNAL_MSGPACK_LIBRARY 1) -endif() - -if (MSGPACK_INCLUDE_DIR) - set(USE_MSGPACK 1) -endif() - -message(STATUS "Using msgpack=${USE_MSGPACK}: ${MSGPACK_INCLUDE_DIR}") diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index 2b19dad672b..0a3179620fd 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -70,6 +70,7 @@ add_subdirectory (openldap-cmake) add_subdirectory (grpc-cmake) add_subdirectory (protobuf-cmake) add_subdirectory (libhdfs3-cmake) # requires: protobuf +add_subdirectory (msgpack-c-cmake) if (ENABLE_FUZZING) add_subdirectory (libprotobuf-mutator-cmake) diff --git a/contrib/msgpack-c-cmake/CMakeLists.txt b/contrib/msgpack-c-cmake/CMakeLists.txt new file mode 100644 index 00000000000..3232b0a9534 --- /dev/null +++ b/contrib/msgpack-c-cmake/CMakeLists.txt @@ -0,0 +1,10 @@ +option (ENABLE_MSGPACK "Enable msgpack library" ${ENABLE_LIBRARIES}) + +if(NOT ENABLE_MSGPACK) + message(STATUS "Not using msgpack") + return() +endif() + +add_library(_msgpack INTERFACE) +target_include_directories(_msgpack SYSTEM BEFORE INTERFACE "${ClickHouse_SOURCE_DIR}/contrib/msgpack-c/include") +add_library(ch_contrib::msgpack ALIAS _msgpack) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6353a6dee72..612a998c70b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -468,8 +468,8 @@ if (USE_CASSANDRA) dbms_target_include_directories (SYSTEM BEFORE PUBLIC ${CASS_INCLUDE_DIR}) endif() -if (USE_MSGPACK) - target_include_directories (clickhouse_common_io SYSTEM BEFORE PUBLIC ${MSGPACK_INCLUDE_DIR}) +if (TARGET ch_contrib::msgpack) + target_link_libraries (clickhouse_common_io PUBLIC ch_contrib::msgpack) endif() target_link_libraries (clickhouse_common_io PUBLIC ${FAST_FLOAT_LIBRARY}) diff --git a/src/Formats/CMakeLists.txt b/src/Formats/CMakeLists.txt index 1aa79e98476..f3a5a8a6025 100644 --- a/src/Formats/CMakeLists.txt +++ b/src/Formats/CMakeLists.txt @@ -12,4 +12,7 @@ endif() if (TARGET ch_contrib::protobuf) set(USE_PROTOBUF 1) endif() +if (TARGET ch_contrib::msgpack) + set(USE_MSGPACK 1) +endif() configure_file(config_formats.h.in ${ConfigIncludePath}/config_formats.h)