Commit 0b084769 authored by webmanue's avatar webmanue
Browse files

Merge branch '113-simplify-gtest-find-module' into 'master'

Resolve "Simplify GTest find module"

Closes #113

See merge request mechanics-and-materials/ae108!102
parents b99bab12 19f4d303
Pipeline #137884 passed with stages
in 7 minutes and 55 seconds
# © 2021 ETH Zurich, Mechanics and Materials Lab
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
find_package(GTest 1.8.1 CONFIG)
if (NOT GTest_FOUND)
set(FETCHCONTENT_SOURCE_DIR_AE108_GOOGLETEST "/usr/src/googletest")
if (IS_DIRECTORY "${FETCHCONTENT_SOURCE_DIR_AE108_GOOGLETEST}")
message(STATUS
"GTest was not found, using source at ${FETCHCONTENT_SOURCE_DIR_AE108_GOOGLETEST} instead."
)
include(FetchContent)
FetchContent_Declare("ae108_googletest")
FetchContent_GetProperties(
ae108_googletest
SOURCE_DIR ae108_googletest_SOURCE_DIR
BINARY_DIR ae108_googletest_BINARY_DIR
POPULATED ae108_googletest_POPULATED
)
if (NOT ae108_googletest_POPULATED)
FetchContent_Populate("ae108_googletest")
add_subdirectory(
"${ae108_googletest_SOURCE_DIR}"
"${ae108_googletest_BINARY_DIR}"
EXCLUDE_FROM_ALL
)
endif()
foreach(LIBRARY_NAME gtest gmock gtest_main gmock_main)
add_library("GTest::${LIBRARY_NAME}" ALIAS "${LIBRARY_NAME}")
endforeach()
set(GTest_FOUND TRUE)
endif()
endif()
find_package_handle_standard_args(AE108_GTest
REQUIRED_VARS GTest_FOUND
)
......@@ -19,7 +19,7 @@ add_executable(${PROJECT_NAME}-CmdLineTests
./CommandLineOptionParser_Test.cc
)
find_package(AE108_GTest MODULE REQUIRED)
find_package(GTest 1.8.1 CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME}-CmdLineTests
PRIVATE ${PROJECT_NAME}::cmdline
PRIVATE GTest::gmock_main
......
......@@ -25,7 +25,7 @@ add_library(${PROJECT_NAME}::cppptest ALIAS ${PROJECT_NAME}-cppptest)
target_include_directories(${PROJECT_NAME}-cppptest PUBLIC include)
find_package(AE108_GTest MODULE REQUIRED)
find_package(GTest 1.8.1 CONFIG REQUIRED)
find_package(AE108_PETSc 3.12 MODULE REQUIRED)
target_link_libraries(${PROJECT_NAME}-cppptest
PRIVATE ${PROJECT_NAME}::external::petsc
......
......@@ -23,7 +23,7 @@ add_executable(${PROJECT_NAME}-CppSlepcTests
add_test(NAME ${PROJECT_NAME}-CppSlepcTests
COMMAND $<TARGET_FILE:${PROJECT_NAME}-CppSlepcTests>)
find_package(AE108_GTest MODULE REQUIRED)
find_package(GTest 1.8.1 CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME}-CppSlepcTests
PRIVATE ${PROJECT_NAME}::cppslepc
PRIVATE GTest::gmock
......
......@@ -25,16 +25,17 @@ RUN apt-get update && \
clang-format \
cmake \
g++ \
gdb \
git \
googletest \
libboost-program-options-dev \
libeigen3-dev \
libgmock-dev \
libgtest-dev \
librange-v3-dev \
libxrender1 \
ninja-build \
python3 python3-pip \
python3-scipy \
gdb
python3-scipy
RUN pip3 install \
mypy==0.931 \
......
......@@ -47,7 +47,7 @@ add_executable(${PROJECT_NAME}-ElementsTests
add_test(NAME ${PROJECT_NAME}-ElementsTests COMMAND $<TARGET_FILE:${PROJECT_NAME}-ElementsTests>)
find_package(AE108_GTest MODULE REQUIRED)
find_package(GTest 1.8.1 CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME}-ElementsTests PUBLIC
${PROJECT_NAME}-elements
GTest::gmock_main
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment