diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 62ac9de462..311842635c 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -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 ()