diff --git a/CMakeLists.txt b/CMakeLists.txt index dc1f2ed1..0b703154 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -495,13 +495,19 @@ else() # Raw CMake Project if (Compadre_EXAMPLES AND Compadre_TESTS) if (NOT Trilinos_PREFIX) - if (NOT TARGET gtest) - # gtest from kokkos - add_library(gtest - kokkos/tpls/gtest/gtest/gtest-all.cc - ) - target_include_directories(gtest PUBLIC kokkos/tpls/gtest) - endif() + # gtest from kokkos + # based on kokkos-kernels/CMakeLists.txt + SET(GTEST_SOURCE_DIR ${PROJECT_SOURCE_DIR}/kokkos/tpls/gtest) + message(STATUS "GTEST:: ${GTEST_SOURCE_DIR}") + add_library(compadre_gtest + ${GTEST_SOURCE_DIR}/gtest/gtest-all.cc + ) + target_include_directories(compadre_gtest PUBLIC ${GTEST_SOURCE_DIR}/gtest) + # Disables pthreads, this is a problem for serial builds in Trilinos & Sierra if it's enabled. + TARGET_COMPILE_DEFINITIONS(compadre_gtest PUBLIC "-DGTEST_HAS_PTHREAD=0") + TARGET_INCLUDE_DIRECTORIES(compadre_gtest PUBLIC $) + #Gtest minimally requires C++11 + TARGET_COMPILE_FEATURES(compadre_gtest PUBLIC cxx_std_11) endif() endif() diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index a7d73fac..4c7ff27b 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -48,7 +48,7 @@ if (Compadre_EXAMPLES) ENDIF() else() add_exe_w_compadre(UnitTests Compadre_UnitTests.cpp) - TARGET_LINK_LIBRARIES(UnitTests PRIVATE gtest) + TARGET_LINK_LIBRARIES(UnitTests PRIVATE compadre_gtest) ADD_TEST(CompadreGtests UnitTests) endif() SET_TESTS_PROPERTIES(CompadreGtests PROPERTIES SKIP_REGULAR_EXPRESSION "MISSING_GTEST" LABELS "Gtest;UnitTest;unittest;Unit;unit")