diff --git a/polly/CMakeLists.txt b/polly/CMakeLists.txt --- a/polly/CMakeLists.txt +++ b/polly/CMakeLists.txt @@ -27,35 +27,16 @@ set(POLLY_GTEST_AVAIL 0) set(UNITTEST_DIR ${LLVM_SOURCE_ROOT}/utils/unittest) if(EXISTS ${UNITTEST_DIR}/googletest/include/gtest/gtest.h) - # The build tree already exports the gtest target, which we can reuse - if (TARGET gtest) - # LLVM Doesn't export gtest's include directorys, so do that here - set_target_properties(gtest - PROPERTIES INTERFACE_INCLUDE_DIRECTORIES - "${UNITTEST_DIR}/googletest/include;${UNITTEST_DIR}/googlemock/include" - ) - set(POLLY_GTEST_AVAIL 1) - else() - add_library(gtest - ${UNITTEST_DIR}/googletest/src/gtest-all.cc - ${UNITTEST_DIR}/googlemock/src/gmock-all.cc - ) - target_include_directories(gtest - PUBLIC - "${UNITTEST_DIR}/googletest/include" - "${UNITTEST_DIR}/googlemock/include" - - PRIVATE - "${UNITTEST_DIR}/googletest" - "${UNITTEST_DIR}/googlemock" - ) - target_link_libraries(gtest PUBLIC -lpthread) - - add_library(gtest_main ${UNITTEST_DIR}/UnitTestMain/TestMain.cpp) - target_link_libraries(gtest_main PUBLIC gtest) - - set(POLLY_GTEST_AVAIL 1) + if (NOT TARGET gtest) + add_subdirectory(${UNITTEST_DIR} utils/unittest) endif() + + # LLVM Doesn't export gtest's include directorys, so do that here + set_target_properties(gtest + PROPERTIES INTERFACE_INCLUDE_DIRECTORIES + "${UNITTEST_DIR}/googletest/include;${UNITTEST_DIR}/googlemock/include" + ) + set(POLLY_GTEST_AVAIL 1) endif() # Make sure the isl c files are built as fPIC