diff --git a/.gitmodules b/.gitmodules index 6da52c17..6a09c571 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,6 @@ [submodule "third_party/yaml-cpp"] path = third_party/yaml-cpp url = https://github.com/jbeder/yaml-cpp.git -[submodule "third_party/googletest"] - path = third_party/googletest - url = https://github.com/google/googletest.git [submodule "third_party/substrait"] path = third_party/substrait url = https://github.com/substrait-io/substrait.git diff --git a/CMakeLists.txt b/CMakeLists.txt index b4644b23..2c977ce3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ # SPDX-License-Identifier: Apache-2.0 -cmake_minimum_required(VERSION 3.20) +cmake_minimum_required(VERSION 3.24) # set the project name project(substrait-cpp) @@ -39,11 +39,19 @@ include_directories(src) # available otherwise we fallback to the older protobuf method. find_package(Protobuf QUIET CONFIG) if(${Protobuf_FOUND}) + message(STATUS "Modern protobuf library located.") set(ABSL_INCLUDED_WITH_PROTOBUF ON) else() - find_package(Protobuf REQUIRED) - include_directories(${Protobuf_INCLUDE_DIRS}) - set(ABSL_INCLUDED_WITH_PROTOBUF OFF) + find_package(Protobuf QUIET) + if(${Protobuf_FOUND}) + message(STATUS "Legacy protobuf library located.") + include_directories(${Protobuf_INCLUDE_DIRS}) + set(ABSL_INCLUDED_WITH_PROTOBUF OFF) + else() + message(STATUS "Fetching external protobuf library.") + include(third_party/protobuf.cmake) + set(ABSL_INCLUDED_WITH_PROTOBUF ON) + endif() endif() add_subdirectory(third_party) diff --git a/export/planloader/CMakeLists.txt b/export/planloader/CMakeLists.txt index 13eceabe..2294572c 100644 --- a/export/planloader/CMakeLists.txt +++ b/export/planloader/CMakeLists.txt @@ -1,9 +1,9 @@ # SPDX-License-Identifier: Apache-2.0 -if(NOT BUILD_SUBDIR_NAME EQUAL "release") +if(CMAKE_BUILD_TYPE MATCHES Debug) message( - SEND_ERROR, - "The planloader library does not work in Debug mode due to its dependencies." + WARNING + "The planloader library does not work well in Debug mode due to bundled heap checking." ) endif() diff --git a/src/substrait/proto/CMakeLists.txt b/src/substrait/proto/CMakeLists.txt index 26198013..d0f8bd92 100644 --- a/src/substrait/proto/CMakeLists.txt +++ b/src/substrait/proto/CMakeLists.txt @@ -65,8 +65,10 @@ foreach(PROTO_FILE IN LISTS PROTOBUF_FILELIST) set(PROTO_SRC ${PROTO_OUTPUT_PARENT_DIR}/proto/${RELATIVE_PROTO_PATH}.pb.cc) add_custom_command( OUTPUT ${PROTO_SRC} ${PROTO_HDR} - COMMAND protobuf::protoc "--proto_path=${GENERATED_PROTO_TOPLEVEL_DIR}" - "--cpp_out=${PROTO_OUTPUT_MIDLEVEL_DIR}" ${GENERATED_PROTO_FILE} + COMMAND + protobuf::protoc + "--proto_path=${GENERATED_PROTO_TOPLEVEL_DIR}:${protobuf_SOURCE_DIR}/src" + "--cpp_out=${PROTO_OUTPUT_MIDLEVEL_DIR}" ${GENERATED_PROTO_FILE} DEPENDS ${GENERATED_PROTOBUF_LIST} protobuf::protoc COMMENT "Generated C++ protobuf module for ${PROTO_FILE}" VERBATIM) diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt index 2124c76d..fb340296 100644 --- a/third_party/CMakeLists.txt +++ b/third_party/CMakeLists.txt @@ -8,9 +8,23 @@ endif() include(datetime.cmake) add_subdirectory(fmt) -add_subdirectory(googletest) +find_package(GTest QUIET) +if(NOT ${GTEST_FOUND}) + message(STATUS "Retrieving external GoogleTest library.") + include(FetchContent) + fetchcontent_declare( + GTest + GIT_REPOSITORY https://github.com/google/googletest.git + GIT_TAG v1.14.0 + OVERRIDE_FIND_PACKAGE) + fetchcontent_makeavailable(GTest) +endif() + +set(PREVIOUS_BUILD_TESTING ${BUILD_TESTING}) +set(BUILD_TESTING OFF) add_subdirectory(protobuf-matchers) +set(BUILD_TESTING ${PREVIOUS_BUILD_TESTING}) set(YAML_CPP_BUILD_TESTS OFF diff --git a/third_party/googletest b/third_party/googletest deleted file mode 160000 index d9251171..00000000 --- a/third_party/googletest +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d9251171f5a42eaf993395e7ef127546af5814b0 diff --git a/third_party/protobuf-matchers b/third_party/protobuf-matchers index 5917378d..a76296f5 160000 --- a/third_party/protobuf-matchers +++ b/third_party/protobuf-matchers @@ -1 +1 @@ -Subproject commit 5917378dcacf16c363b80c24a0d3c750f583b2b7 +Subproject commit a76296f5d5369d57f44126acf59c290a397490c6 diff --git a/third_party/protobuf.cmake b/third_party/protobuf.cmake new file mode 100644 index 00000000..e7942cf3 --- /dev/null +++ b/third_party/protobuf.cmake @@ -0,0 +1,19 @@ +# SPDX-License-Identifier: Apache-2.0 + +include_guard(GLOBAL) + +set(ABSL_PROPAGATE_CXX_STD ON) + +include(FetchContent) +FetchContent_Declare(GTest + GIT_REPOSITORY https://github.com/google/googletest.git + GIT_TAG v1.14.0 + OVERRIDE_FIND_PACKAGE +) +FetchContent_Declare(Protobuf + GIT_REPOSITORY https://github.com/protocolbuffers/protobuf.git + GIT_TAG v23.4 + OVERRIDE_FIND_PACKAGE +) +set(protobuf_BUILD_TESTS OFF CACHE INTERNAL "") +FetchContent_MakeAvailable(Protobuf GTest)