Index: CMakeLists.txt =================================================================== --- CMakeLists.txt +++ CMakeLists.txt @@ -24,6 +24,7 @@ endif() # Enable unit tests if available. + 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 Index: test/CMakeLists.txt =================================================================== --- test/CMakeLists.txt +++ test/CMakeLists.txt @@ -62,12 +62,12 @@ set_target_properties(check-polly-tests PROPERTIES FOLDER "Polly") add_dependencies(check-polly check-polly-tests) -if (POLLY_GTEST_AVAIL) - configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg - ) +configure_lit_site_cfg( + ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in + ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg + ) +if (POLLY_GTEST_AVAIL) # Run only unit tests add_lit_testsuite(check-polly-unittests "Running polly unit tests only" ${CMAKE_CURRENT_BINARY_DIR}/Unit Index: test/Unit/lit.cfg =================================================================== --- test/Unit/lit.cfg +++ test/Unit/lit.cfg @@ -11,6 +11,9 @@ # name: The name of this test suite. config.name = 'Polly-Unit' +if not config.has_unittests: + raise SystemExit + # suffixes: A list of file extensions to treat as test files. config.suffixes = [] Index: test/Unit/lit.site.cfg.in =================================================================== --- test/Unit/lit.site.cfg.in +++ test/Unit/lit.site.cfg.in @@ -14,6 +14,7 @@ config.target_triple = "@TARGET_TRIPLE@" config.enable_gpgpu_codegen = "@GPU_CODEGEN@" config.link_polly_into_tools = "@LINK_POLLY_INTO_TOOLS@" +config.has_unittests = @POLLY_GTEST_AVAIL@ # Support substitution of the tools_dir, libs_dirs, and build_mode with user # parameters. This is used when we can't determine the tool dir at