Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ jobs:
cmake -B build -G Ninja \
-DCMAKE_BUILD_TYPE=Debug \
-DBUILD_TZ_LIB=ON \
-DSUBSTRAIT_CPP_FIND_PROTOBUF_CONFIG=OFF \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache

Expand Down
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
[submodule "third_party/fmt"]
path = third_party/fmt
url = https://github.com/fmtlib/fmt
[submodule "third_party/abseil-cpp"]
path = third_party/abseil-cpp
url = https://github.com/abseil/abseil-cpp.git
[submodule "third_party/datetime"]
path = third_party/datetime
url = https://github.com/HowardHinnant/date.git
Expand Down
9 changes: 2 additions & 7 deletions scripts/setup-ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,10 @@ sudo --preserve-env apt install -y \
git \
wget \
clang-format-15 \
libprotobuf-dev \
protobuf-compiler \
uuid-dev \
default-jre \
libcurl4-openssl-dev

# Install the currently supported version of protobuf:
PB_REL="https://github.com/protocolbuffers/protobuf/releases"
PB_VER="28.2"
curl -LO $PB_REL/download/v$PB_VER/protoc-$PB_VER-linux-x86_64.zip
unzip protoc-$PB_VER-linux-x86_64.zip -d $HOME/.local
export PATH="$PATH:$HOME/.local/bin"

pip install cmake-format
48 changes: 4 additions & 44 deletions third_party/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,60 +3,20 @@
# Ensure `option()` in subdirectories honors normal variables set here.
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)

set(SUBSTRAIT_CPP_ABSL_DEFAULT_FETCH_TAG "20240116.2")
set(SUBSTRAIT_CPP_PROTOBUF_DEFAULT_FETCH_TAG "v29.3")
set(SUBSTRAIT_CPP_GTEST_DEFAULT_FETCH_TAG "v1.14.0")

include(gtest.cmake)
include(datetime.cmake)
include(protobuf.cmake)

set(ABSL_ENABLE_INSTALL ON)
if(NOT ${ABSL_INCLUDED_WITH_PROTOBUF})
set(ABSL_PROPAGATE_CXX_STD ON)
add_subdirectory(abseil-cpp)
include(abseil-cpp.cmake)
endif()

add_subdirectory(fmt)

if(WIN32)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt
ON
CACHE BOOL "" FORCE)
endif()

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()
if(MSVC)
# ------------------------------------------------------------------------------
# gtest MSVC fix
# ------------------------------------------------------------------------------
# For some reason, googletest has include path issues when built with MSVC.
# Specifically, this seems like some incorrect assumptions about include paths
# inside the gmock project.
# We can fix this by injecting the include paths here.
function(fix_gtest_include TARGET)
target_include_directories(
${TARGET}
PUBLIC $<BUILD_INTERFACE:${gtest_SOURCE_DIR}>
$<BUILD_INTERFACE:${gtest_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${gtest_SOURCE_DIR}/googletest>
$<BUILD_INTERFACE:${gtest_SOURCE_DIR}/googletest/include>
$<INSTALL_INTERFACE:include/${TARGET}>)
endfunction()
set(gtest_erroneous_targets gmock gmock_main)
foreach(target ${gtest_erroneous_targets})
fix_gtest_include(${target})
endforeach()
endif()

set(PROTOBUF_MATCHERS_BUILD_TESTING OFF)
add_subdirectory(protobuf-matchers)

Expand Down
1 change: 0 additions & 1 deletion third_party/abseil-cpp
Submodule abseil-cpp deleted from c2435f
56 changes: 56 additions & 0 deletions third_party/abseil-cpp.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# SPDX-License-Identifier: Apache-2.0

set(ABSL_ENABLE_INSTALL ON)

option(SUBSTRAIT_CPP_USE_SYSTEM_ABSL "Use system absl via find_package" ON)
option(SUBSTRAIT_CPP_FIND_ABSL_CONFIG
"Use CONFIG mode to find system absl via find_package" ON)
option(SUBSTRAIT_CPP_FETCH_ABSL "Download absl via FetchContent if not found"
ON)
set(SUBSTRAIT_CPP_ABSL_FETCH_TAG
${SUBSTRAIT_CPP_ABSL_DEFAULT_FETCH_TAG}
CACHE STRING "Git tag or commit to use for absl FetchContent")

# First use `find_package`. This allows downstream projects to inject their
# version with `FetchContent_Declare(... OVERRIDE_FIND_PACKAGE`.
if(SUBSTRAIT_CPP_USE_SYSTEM_ABSL)
if(SUBSTRAIT_CPP_FIND_ABSL_CONFIG)
find_package(absl CONFIG)
else()
find_package(absl)
endif()
endif()

# Now fall back to using `FetchContent`.
if(NOT absl_FOUND AND SUBSTRAIT_CPP_FETCH_ABSL)
message(STATUS "Fetching absl-cpp version ${SUBSTRAIT_CPP_ABSL_FETCH_TAG}")
include(FetchContent)
fetchcontent_declare(
absl-cpp
GIT_REPOSITORY https://github.com/abseil/abseil-cpp.git
GIT_TAG ${SUBSTRAIT_CPP_ABSL_FETCH_TAG}
SYSTEM OVERRIDE_FIND_PACKAGE CMAKE_ARGS
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER})
if(MSVC)
add_compile_options("/W0")
else()
add_compile_options("-w")
endif()
set(ABSL_PROPAGATE_CXX_STD ON)
fetchcontent_makeavailable(absl-cpp)
fetchcontent_getproperties(absl-cpp SOURCE_DIR absl_SOURCE_DIR)
if(TARGET status AND NOT TARGET absl::status)
add_library(absl::status ALIAS status)
endif()
if(TARGET statusor AND NOT TARGET absl::statusor)
add_library(absl::statusor ALIAS statusor)
endif()
if(TARGET strings AND NOT TARGET absl::strings)
add_library(absl::strings ALIAS strings)
endif()
endif()

if(NOT TARGET absl::status)
message(FATAL_ERROR "absl-cpp is required but was not found or fetched.")
endif()
62 changes: 49 additions & 13 deletions third_party/gtest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,54 @@

include_guard(GLOBAL)

include(FetchContent)
fetchcontent_declare(
GTest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.14.0
OVERRIDE_FIND_PACKAGE)
option(SUBSTRAIT_CPP_USE_SYSTEM_GTEST "Use system GTest via find_package" ON)
option(SUBSTRAIT_CPP_FIND_GTEST_CONFIG
"Use CONFIG mode to find system GTest via find_package" ON)
option(SUBSTRAIT_CPP_FETCH_GTEST "Download GTest via FetchContent if not found"
ON)
set(SUBSTRAIT_CPP_GTEST_FETCH_TAG
${SUBSTRAIT_CPP_GTEST_DEFAULT_FETCH_TAG}
CACHE STRING "Git tag or commit to use for GTest FetchContent")

# Disable warnings for dependency targets.
if(MSVC)
set(gtest_force_shared_crt ON)
add_compile_options("/W0")
else()
add_compile_options("-w")
# First use `find_package`. This allows downstream projects to inject their
# version with `FetchContent_Declare(... OVERRIDE_FIND_PACKAGE`.
if(SUBSTRAIT_CPP_USE_SYSTEM_GTEST)
if(SUBSTRAIT_CPP_FIND_GTEST_CONFIG)
find_package(GTest CONFIG)
else()
find_package(GTest)
endif()
endif()

# Now fall back to using `FetchContent`.
if(NOT GTest_FOUND AND SUBSTRAIT_CPP_FETCH_GTEST)
message(STATUS "Fetching googletest version ${SUBSTRAIT_CPP_GTEST_FETCH_TAG}")
include(FetchContent)
fetchcontent_declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG ${SUBSTRAIT_CPP_GTEST_FETCH_TAG}
SYSTEM OVERRIDE_FIND_PACKAGE CMAKE_ARGS
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER})
if(MSVC)
set(gtest_force_shared_crt
ON
CACHE BOOL "" FORCE)
add_compile_options("/W0")
else()
add_compile_options("-w")
endif()
fetchcontent_makeavailable(googletest)
fetchcontent_getproperties(googletest SOURCE_DIR GTest_SOURCE_DIR)
if(TARGET gmock AND NOT TARGET GTest::gmock)
add_library(GTest::gmock ALIAS gmock)
endif()
if(TARGET gmock_main AND NOT TARGET GTest::gmock_main)
add_library(GTest::gmock_main ALIAS gmock_main)
endif()
endif()

if(NOT TARGET GTest::gmock)
message(FATAL_ERROR "GTest is required but was not found or fetched.")
endif()
fetchcontent_makeavailable(GTest)
Loading