Skip to content

Commit

Permalink
Merge pull request #1192 from holmes1412/master
Browse files Browse the repository at this point in the history
UnitTest: Add checking Gtest_VERSION for cmake 3.26.0
  • Loading branch information
Barenboim authored Feb 23, 2023
2 parents 4d43882 + d8b59aa commit 4097211
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,19 @@ enable_testing()
set(CXX_STD "c++11")

find_package(GTest REQUIRED)
get_filename_component(GTEST_PATH ${GTEST_LIBRARY} DIRECTORY)
execute_process(COMMAND grep Version "${GTEST_PATH}/pkgconfig/gtest.pc"
RESULT_VARIABLE GTEST_VERSION_RESULT
OUTPUT_VARIABLE GTEST_VERSION_OUTPUT)
if (${GTEST_VERSION_RESULT} EQUAL "0")
string(REPLACE " " ";" GTEST_VERSION_STR ${GTEST_VERSION_OUTPUT})
list(GET GTEST_VERSION_STR 1 GTEST_VERSION)

if (${GTEST_VERSION} VERSION_GREATER_EQUAL "1.13.0")
set(CXX_STD "c++14")
if (GTest_VERSION VERSION_GREATER_EQUAL "1.13.0")
set(CXX_STD "c++14")
else ()
get_filename_component(GTEST_PATH ${GTEST_LIBRARY} DIRECTORY ABSOLUTE)
execute_process(COMMAND grep Version "${GTEST_PATH}/pkgconfig/gtest.pc"
RESULT_VARIABLE GTEST_VERSION_RESULT
OUTPUT_VARIABLE GTEST_VERSION_OUTPUT)
if (${GTEST_VERSION_RESULT} EQUAL "0")
string(REPLACE " " ";" GTEST_VERSION_STR ${GTEST_VERSION_OUTPUT})
list(GET GTEST_VERSION_STR 1 GTEST_VERSION)
if (${GTEST_VERSION} VERSION_GREATER_EQUAL "1.13.0")
set(CXX_STD "c++14")
endif ()
endif ()
endif ()

Expand Down

0 comments on commit 4097211

Please sign in to comment.