Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use external gtest by default when possible #3035

Merged
merged 1 commit into from
Feb 2, 2022
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/clang_linux/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -e
apt-get update -y
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
sudo autoconf automake libtool clang++-10 python3-clang-10 make cmake ccache pkg-config tar zip \
sqlite3 libsqlite3-dev libtiff-dev libcurl4-openssl-dev jq python3-pip nlohmann-json3-dev
sqlite3 libsqlite3-dev libtiff-dev libcurl4-openssl-dev jq python3-pip nlohmann-json3-dev libgtest-dev

python3 -m pip install --user jsonschema
export PATH=$HOME/.local/bin:$PATH
Expand Down
20 changes: 18 additions & 2 deletions test/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
# CMake configuration for PROJ unit tests

option(USE_EXTERNAL_GTEST "Compile against external GTest" OFF)
find_package(GTest 1.8.1)
if(GTest_FOUND)
option(USE_EXTERNAL_GTEST "Compile against external GTest" ON)
else()
option(USE_EXTERNAL_GTEST "Compile against external GTest" OFF)
endif()

if(USE_EXTERNAL_GTEST)

if(NOT GTest_FOUND)
message(FATAL_ERROR "External GTest >= 1.8.1 not found")
endif()
message(STATUS "Using external GTest")
find_package(GTest 1.8.1 CONFIG REQUIRED)

# CMake < 3.20.0 uses GTest::GTest
# CMake >= 3.20 uses GTest::gtest, and deprecates GTest::GTest
# so for older CMake, create an alias from GTest::GTest to GTest::gtest
if(NOT TARGET GTest::gtest)
add_library(GTest::gtest INTERFACE IMPORTED)
set_target_properties(GTest::gtest PROPERTIES
INTERFACE_LINK_LIBRARIES "GTest::GTest")
endif()

else()

Expand Down