From: Philip Pfaffe Date: Tue, 11 Jul 2017 11:24:25 +0000 (+0000) Subject: [Polly][CMake] Use the CMake Package instead of llvm-config in out-of-tree builds X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d99c406e3d39b747566f6a5b4bd30f71cf46759a;p=platform%2Fupstream%2Fllvm.git [Polly][CMake] Use the CMake Package instead of llvm-config in out-of-tree builds Summary: As of now, Polly uses llvm-config to set up LLVM dependencies in an out-of-tree build. This is problematic for two reasons: 1) Right now, in-tree and out-of-tree builds in fact do different things. E.g., in an in-tree build, libPolly depends on a handful of LLVM libraries, while in an out-of-tree build it depends on all of them. This means that we often need to treat both paths seperately. 2) I'm specifically unhappy with the way libPolly is linked right now, because it just blindly links against all the LLVM libs. That doesn't make a lot of sense. For instance, one of these libs is LLVMTableGen, which contains a command line definition of a -o option. This means that I can not link an out-of-tree libPolly into a tool which might want to offer a -o option as well. This patch (mostly) drop the use of llvm-config in favor of LLVMs exported cmake package. However, building Polly with unittests requires access to the gtest sources (in the LLVM source tree). If we're building against an LLVM installation, this source tree is unavailable and must specified. I'm using llvm-config to provide a default in this case. Reviewers: Meinersbur, grosser Reviewed By: grosser Subscribers: tstellar, bollu, chapuni, mgorny, pollydev, llvm-commits Differential Revision: https://reviews.llvm.org/D33299 llvm-svn: 307650 --- diff --git a/polly/CMakeLists.txt b/polly/CMakeLists.txt index be075c5..8fee92e 100644 --- a/polly/CMakeLists.txt +++ b/polly/CMakeLists.txt @@ -4,112 +4,57 @@ if (NOT DEFINED LLVM_MAIN_SRC_DIR) cmake_minimum_required(VERSION 3.4.3) # Where is LLVM installed? - set(LLVM_INSTALL_ROOT "" CACHE PATH "Root of LLVM install.") - # Check if the LLVM_INSTALL_ROOT valid. - if( NOT EXISTS ${LLVM_INSTALL_ROOT}/include/llvm ) - message(FATAL_ERROR "LLVM_INSTALL_ROOT (${LLVM_INSTALL_ROOT}) is not a valid LLVM installation.") - endif(NOT EXISTS ${LLVM_INSTALL_ROOT}/include/llvm) - # FileCheck, not and llvm-lit are not install by default, warn the user to copy them. - if( NOT EXISTS ${LLVM_INSTALL_ROOT}/bin/FileCheck - OR NOT EXISTS ${LLVM_INSTALL_ROOT}/bin/not - OR NOT EXISTS ${LLVM_INSTALL_ROOT}/bin/llvm-lit ) - message(WARNING "'FileCheck', 'not' and 'llvm-lit' are required by running regress tests, " - "but they are not installed! Please copy them to " - "${LLVM_INSTALL_ROOT}/bin.") - endif() + find_package(LLVM CONFIG REQUIRED) + set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${LLVM_CMAKE_DIR}) + include(HandleLLVMOptions) + include(AddLLVM) + # Add the llvm header path. - include_directories(${LLVM_INSTALL_ROOT}/include/) - - # Get LLVM's own libraries. - execute_process(COMMAND "${LLVM_INSTALL_ROOT}/bin/llvm-config" --libs - OUTPUT_VARIABLE LLVM_LIBS - OUTPUT_STRIP_TRAILING_WHITESPACE) - - # Get the system librarys that will link into LLVM. - execute_process(COMMAND "${LLVM_INSTALL_ROOT}/bin/llvm-config" --system-libs - OUTPUT_VARIABLE LLVM_SYSTEM_LIBS - OUTPUT_STRIP_TRAILING_WHITESPACE) - message(STATUS "System libs required by LLVM: ${LLVM_SYSTEM_LIBS}") - - # Determine where LLVM stores its libraries. - execute_process(COMMAND "${LLVM_INSTALL_ROOT}/bin/llvm-config" --libdir - OUTPUT_VARIABLE LLVM_LIBRARY_DIR - OUTPUT_STRIP_TRAILING_WHITESPACE) - link_directories("${LLVM_LIBRARY_DIR}") - - # Now set the header paths. - execute_process(COMMAND "${LLVM_INSTALL_ROOT}/bin/llvm-config" --includedir - OUTPUT_VARIABLE LLVM_INCLUDE_DIR - OUTPUT_STRIP_TRAILING_WHITESPACE) - include_directories( ${LLVM_INCLUDE_DIR} ) - - # Get the TARGET_TRIPLE - execute_process(COMMAND "${LLVM_INSTALL_ROOT}/bin/llvm-config" --host-target - OUTPUT_VARIABLE TARGET_TRIPLE - OUTPUT_STRIP_TRAILING_WHITESPACE) - - # And then set the cxx flags. - execute_process(COMMAND "${LLVM_INSTALL_ROOT}/bin/llvm-config" --cxxflags - OUTPUT_VARIABLE LLVM_CXX_FLAGS - OUTPUT_STRIP_TRAILING_WHITESPACE) - set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${LLVM_CXX_FLAGS}) - - # Check LLVM_ENABLE_ASSERTIONS - execute_process(COMMAND "${LLVM_INSTALL_ROOT}/bin/llvm-config" --assertion-mode - OUTPUT_VARIABLE LLVM_ENABLE_ASSERTIONS - OUTPUT_STRIP_TRAILING_WHITESPACE) - # Copied from LLVM's HandleLLVMOptions.cmake - if( LLVM_ENABLE_ASSERTIONS ) - # MSVC doesn't like _DEBUG on release builds. See PR 4379. - if( NOT MSVC ) - add_definitions( -D_DEBUG ) - endif() - # On non-Debug builds cmake automatically defines NDEBUG, so we - # explicitly undefine it: - if( NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" ) - add_definitions( -UNDEBUG ) - # Also remove /D NDEBUG to avoid MSVC warnings about conflicting defines. - foreach (flags_var_to_scrub - CMAKE_CXX_FLAGS_RELEASE - CMAKE_CXX_FLAGS_RELWITHDEBINFO - CMAKE_CXX_FLAGS_MINSIZEREL - CMAKE_C_FLAGS_RELEASE - CMAKE_C_FLAGS_RELWITHDEBINFO - CMAKE_C_FLAGS_MINSIZEREL) - string (REGEX REPLACE "(^| )[/-]D *NDEBUG($| )" " " - "${flags_var_to_scrub}" "${${flags_var_to_scrub}}") - endforeach() - endif() - endif() + include_directories(${LLVM_INCLUDE_DIRS}) # Sources available, too? - execute_process(COMMAND "${LLVM_INSTALL_ROOT}/bin/llvm-config" --src-root - OUTPUT_VARIABLE MAIN_SRC_DIR - OUTPUT_STRIP_TRAILING_WHITESPACE) - set(LLVM_SOURCE_ROOT ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree") + if (LLVM_BUILD_MAIN_SRC_DIR) + set(LLVM_SOURCE_ROOT ${LLVM_BUILD_MAIN_SRC_DIR} CACHE PATH + "Path to LLVM source tree") + else() + execute_process(COMMAND "${LLVM_TOOLS_BINARY_DIR}/llvm-config" --src-root + OUTPUT_VARIABLE MAIN_SRC_DIR + OUTPUT_STRIP_TRAILING_WHITESPACE) + set(LLVM_SOURCE_ROOT ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree") + endif() # Enable unit tests if available. set(UNITTEST_DIR ${LLVM_SOURCE_ROOT}/utils/unittest) if(EXISTS ${UNITTEST_DIR}/googletest/include/gtest/gtest.h) - 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 -lpthread) - - add_library(gtest_main ${UNITTEST_DIR}/UnitTestMain/TestMain.cpp) - target_link_libraries(gtest_main gtest) - - set(POLLY_GTEST_AVAIL 1) + # 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 -lpthread) + + add_library(gtest_main ${UNITTEST_DIR}/UnitTestMain/TestMain.cpp) + target_link_libraries(gtest_main gtest) + + set(POLLY_GTEST_AVAIL 1) + endif() endif() # Make sure the isl c files are built as fPIC diff --git a/polly/cmake/CMakeLists.txt b/polly/cmake/CMakeLists.txt index 62693f3..969292c 100644 --- a/polly/cmake/CMakeLists.txt +++ b/polly/cmake/CMakeLists.txt @@ -1,9 +1,4 @@ # Keep this in sync with llvm/cmake/CMakeLists.txt! -if (LLVM_INSTALL_ROOT) - # this simplifies things down the road, by not requiring to distinguish - # between in-tree and out of tree builds - set(LLVM_BINARY_DIR ${LLVM_INSTALL_ROOT}) -endif() set(LLVM_INSTALL_PACKAGE_DIR "lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm") set(POLLY_INSTALL_PACKAGE_DIR "lib${LLVM_LIBDIR_SUFFIX}/cmake/polly") diff --git a/polly/lib/CMakeLists.txt b/polly/lib/CMakeLists.txt index 751c9b4..1141de5 100644 --- a/polly/lib/CMakeLists.txt +++ b/polly/lib/CMakeLists.txt @@ -79,59 +79,42 @@ if (GPU_CODEGEN) target_link_libraries(Polly PollyPPCG) endif () -# Add Polly's LLVM dependencies. -# When built inside the LLVM source tree, these are CMake targets that will -# depend on their dependencies and CMake ensures they are added in the right -# order. -# If Polly is built independently, just add all LLVM libraries. LLVM_ROOT_DIR -# might have been configured to compile to individual libraries or a single -# libLLVM.so (called dylib), reported by llvm-config, so there is no fixed list -# of required libraries. -if (DEFINED LLVM_MAIN_SRC_DIR) - # Polly-ACC requires the NVPTX backend to work. Ask LLVM about its libraries. - set(nvptx_libs) - if (GPU_CODEGEN) - # This call emits an error if they NVPTX backend is not enable. - llvm_map_components_to_libnames(nvptx_libs NVPTX) - endif () +# Polly-ACC requires the NVPTX backend to work. Ask LLVM about its libraries. +set(nvptx_libs) +if (GPU_CODEGEN) + # This call emits an error if they NVPTX backend is not enable. + llvm_map_components_to_libnames(nvptx_libs NVPTX) +endif () - if (LLVM_LINK_LLVM_DYLIB) - # The shlib/dylib contains all the LLVM components - # (including NVPTX is enabled) already. Adding them to target_link_libraries - # would cause them being twice in the address space - # (their LLVM*.a/so and their copies in libLLVM.so) - # which results in errors when the two instances try to register the same - # command-line switches. - target_link_libraries(Polly LLVM) - else () - target_link_libraries(Polly - LLVMSupport - LLVMCore - LLVMScalarOpts - LLVMInstCombine - LLVMTransformUtils - LLVMAnalysis - LLVMipo - LLVMMC - LLVMPasses - ${nvptx_libs} -# The libraries below are required for darwin: http://PR26392 - LLVMBitReader - LLVMMCParser - LLVMObject - LLVMProfileData - LLVMTarget - LLVMVectorize - ) - endif () +if (LLVM_LINK_LLVM_DYLIB) + # The shlib/dylib contains all the LLVM components + # (including NVPTX is enabled) already. Adding them to target_link_libraries + # would cause them being twice in the address space + # (their LLVM*.a/so and their copies in libLLVM.so) + # which results in errors when the two instances try to register the same + # command-line switches. + target_link_libraries(Polly LLVM) else () - # When Polly-ACC is enabled, we assume that the host LLVM was also built with - # the NVPTX target enabled. target_link_libraries(Polly - ${LLVM_LIBS} - ${LLVM_SYSTEM_LIBS} - ) + LLVMSupport + LLVMCore + LLVMScalarOpts + LLVMInstCombine + LLVMTransformUtils + LLVMAnalysis + LLVMipo + LLVMMC + LLVMPasses + ${nvptx_libs} + # The libraries below are required for darwin: http://PR26392 + LLVMBitReader + LLVMMCParser + LLVMObject + LLVMProfileData + LLVMTarget + LLVMVectorize + ) endif () # Create a loadable module Polly.so that can be loaded using diff --git a/polly/test/CMakeLists.txt b/polly/test/CMakeLists.txt index 1ddde6b..4843d01 100644 --- a/polly/test/CMakeLists.txt +++ b/polly/test/CMakeLists.txt @@ -1,178 +1,109 @@ -set(POLLY_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..") -set(POLLY_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/..") set(LLVM_SHLIBEXT "${CMAKE_SHARED_MODULE_SUFFIX}") add_custom_target(check-polly) set_target_properties(check-polly PROPERTIES FOLDER "Polly") -if (NOT DEFINED LLVM_MAIN_SRC_DIR) - - # We are building polly out of tree, adjust the settings. - # FIXME: FileCheck is not available in llvm install directory at the moment. - set(LLVM_LIT ${LLVM_INSTALL_ROOT}/bin/llvm-lit) - if (POLLY_BUNDLED_ISL) - set(POLLY_TEST_DEPS LLVMPolly polly-isl-test) - endif (POLLY_BUNDLED_ISL) - if (POLLY_GTEST_AVAIL) - list(APPEND POLLY_TEST_DEPS PollyUnitTests) - endif () - - set(LLVM_BINARY_DIR "${LLVM_INSTALL_ROOT}") - set(LLVM_TOOLS_DIR "${LLVM_INSTALL_ROOT}/bin") - set(LLVM_LIBS_DIR "${LLVM_INSTALL_ROOT}/lib") - set(POLLY_LIB_DIR "${POLLY_BINARY_DIR}/lib") - - include(FindPythonInterp) - if(PYTHONINTERP_FOUND) - option(POLLY_TEST_DISABLE_BAR "Run Polly tests with --no-progress-bar" OFF) - set(POLLY_TEST_EXTRA_ARGS) - if (MSVC OR XCODE OR POLLY_TEST_DISABLE_BAR) - set(POLLY_TEST_EXTRA_ARGS "--no-progress-bar") - endif() - - option(POLLY_TEST_USE_VG "Run Polly tests under Valgrind" OFF) - if(POLLY_TEST_USE_VG) - set(POLLY_TEST_EXTRA_ARGS ${POLLY_TEST_EXTRA_ARGS} "--vg") - endif () - - # Parameters required for lit.site.cfg.in - set(LLVM_SOURCE_DIR ${LLVM_SOURCE_ROOT}) - if (CMAKE_CFG_INTDIR STREQUAL ".") - set(LLVM_BUILD_MODE ".") - else () - set(LLVM_BUILD_MODE "%(build_mode)s") - endif () - set(ENABLE_SHARED "1") - set(SHLIBDIR "${LLVM_BINARY_DIR}/bin") - set(LINK_POLLY_INTO_TOOLS "OFF") - - configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg) - - add_custom_target(check-polly-tests - COMMAND ${LLVM_LIT} - --param polly_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg - --param polly_unit_site_config=${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg - --param build_config=${CMAKE_CFG_INTDIR} - -sv ${POLLY_TEST_EXTRA_ARGS} - ${CMAKE_CURRENT_BINARY_DIR} - DEPENDS ${POLLY_TEST_DEPS} - COMMENT "Running Polly regression/unit tests") - set_target_properties(check-polly-tests PROPERTIES FOLDER "Polly") - add_dependencies(check-polly check-polly-tests) - - if (POLLY_GTEST_AVAIL) - configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg) - - add_custom_target(check-polly-unittests - COMMAND ${LLVM_LIT} - --param polly_site_config=${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg - --param build_config=${CMAKE_CFG_INTDIR} - -sv ${POLLY_TEST_EXTRA_ARGS} - ${CMAKE_CURRENT_BINARY_DIR}/Unit - DEPENDS PollyUnitTests - COMMENT "Running Polly unit tests") - set_target_properties(check-polly-unittests PROPERTIES FOLDER "Polly") - endif () - configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/UnitIsl/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/UnitIsl/lit.site.cfg) - - - if (POLLY_BUNDLED_ISL) - add_custom_target(check-polly-isl - command ${LLVM_LIT} - --param polly_site_config=${CMAKE_CURRENT_BINARY_DIR}/UnitIsl/lit.site.cfg - --param build_config=${CMAKE_CFG_INTDIR} - -sv ${POLLY_TEST_EXTRA_ARGS} - ${CMAKE_CURRENT_BINARY_DIR} - DEPENDS polly-isl-test - COMMENT "Running isl unit tests") - set_target_properties(check-polly-isl PROPERTIES FOLDER "Polly") - endif (POLLY_BUNDLED_ISL) +if(NOT LLVM_MAIN_SRC_DIR) + find_program(LLVM_OPT NAMES opt HINTS ${LLVM_TOOLS_BINARY_DIR}) + find_program(LLVM_FILECHECK NAMES FileCheck HINTS ${LLVM_TOOLS_BINARY_DIR}) + find_program(LLVM_NOT NAMES not HINTS ${LLVM_TOOLS_BINARY_DIR}) + if (NOT LLVM_OPT) + message(WARNING "LLVM's opt program could not be found. Please set LLVM_OPT.") endif() - -else (NOT DEFINED LLVM_MAIN_SRC_DIR) - - set(LLVM_LIT ${LLVM_TOOLS_BINARY_DIR}/llvm-lit) - set(POLLY_TEST_DEPS llvm-config opt LLVMPolly FileCheck not) - if (POLLY_BUNDLED_ISL) - list(APPEND POLLY_TEST_DEPS polly-isl-test) + if (NOT LLVM_FILECHECK) + message(WARNING "LLVM's FileCheck program could not be found. " + "Please set LLVM_FILECHECK. Please set LLVM_FILECHECK.") endif() - if (POLLY_GTEST_AVAIL) - list(APPEND POLLY_TEST_DEPS PollyUnitTests) - endif () - - set(LLVM_BINARY_DIR "${LLVM_BINARY_DIR}") - set(LLVM_TOOLS_DIR "${LLVM_TOOLS_BINARY_DIR}") - set(LLVM_LIBS_DIR "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}") - set(POLLY_LIB_DIR "${LLVM_LIBS_DIR}") - + if (NOT LLVM_NOT) + message(WARNING "LLVM's not program could not be found. Please set LLVM_NOT.") + endif() + get_filename_component(EXTRA_PATHS ${LLVM_OPT} DIRECTORY) + list(APPEND POLLY_TEST_EXTRA_PATHS "${EXTRA_PATHS}") + get_filename_component(EXTRA_PATHS ${LLVM_FILECHECK} DIRECTORY) + list(APPEND POLLY_TEST_EXTRA_PATHS "${EXTRA_PATHS}") + get_filename_component(EXTRA_PATHS ${LLVM_NOT} DIRECTORY) + list(APPEND POLLY_TEST_EXTRA_PATHS "${EXTRA_PATHS}") + list(REMOVE_DUPLICATES POLLY_TEST_EXTRA_PATHS) + message(STATUS "Extra paths: ${POLLY_TEST_EXTRA_PATHS}") + if ("${POLLY_TEST_EXTRA_PATHS}" STREQUAL "${LLVM_TOOLS_BINARY_DIR}") + set(POLLY_TEST_EXTRA_PATHS "") + endif() +else () + set(LLVM_OPT "${LLVM_TOOLS_BINARY_DIR}/opt") + set(LLVM_FILECHECK "${LLVM_TOOLS_BINARY_DIR}/FileCheck") + set(LLVM_NOT "${LLVM_TOOLS_BINARY_DIR}/not") + set(POLLY_TEST_EXTRA_PATHS "") +endif() + +set(POLLY_TEST_DEPS LLVMPolly) +if (POLLY_BUNDLED_ISL) + list(APPEND POLLY_TEST_DEPS polly-isl-test) +endif() +if (POLLY_GTEST_AVAIL) + list(APPEND POLLY_TEST_DEPS PollyUnitTests) +endif () + +set(LLVM_BINARY_DIR "${LLVM_BINARY_DIR}") +set(LLVM_TOOLS_DIR "${LLVM_TOOLS_BINARY_DIR}") +set(LLVM_LIBS_DIR "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}") +set(POLLY_LIB_DIR "${POLLY_BINARY_DIR}/lib") + +configure_lit_site_cfg( + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in + ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg) + +# Run regression and unit tests +add_lit_testsuite(check-polly-tests "Running polly regression tests" + ${CMAKE_CURRENT_BINARY_DIR} + PARAMS polly_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg + polly_unit_site_config=${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg + DEPENDS ${POLLY_TEST_DEPS} + ) +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}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg) - - # Run regression and unit tests - add_lit_testsuite(check-polly-tests "Running polly regression tests" - ${CMAKE_CURRENT_BINARY_DIR} - PARAMS polly_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg - polly_unit_site_config=${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg - DEPENDS ${POLLY_TEST_DEPS} + ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in + ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg ) - 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 + # Run only unit tests + add_lit_testsuite(check-polly-unittests "Running polly unit tests only" + ${CMAKE_CURRENT_BINARY_DIR}/Unit + PARAMS polly_site_config=${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg + DEPENDS PollyUnitTests ) + set_target_properties(check-polly-unittests PROPERTIES FOLDER "Polly") +endif () - # Run only unit tests - add_lit_testsuite(check-polly-unittests "Running polly unit tests only" - ${CMAKE_CURRENT_BINARY_DIR}/Unit - PARAMS polly_site_config=${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg - DEPENDS PollyUnitTests - ) - set_target_properties(check-polly-unittests PROPERTIES FOLDER "Polly") - endif () - - configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/UnitIsl/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/UnitIsl/lit.site.cfg) - - if (POLLY_BUNDLED_ISL) - add_lit_testsuite(check-polly-isl "Running isl unit tests only" - ${CMAKE_CURRENT_BINARY_DIR}/UnitIsl - PARAMS polly_site_config=${CMAKE_CURRENT_BINARY_DIR}/UnitIsl/lit.site.cfg - DEPENDS polly-isl-test - ) - set_target_properties(check-polly-isl PROPERTIES FOLDER "Polly") - endif (POLLY_BUNDLED_ISL) - - # Run polly-check-format as part of polly-check only if we are compiling with - # clang, so clang-format is available. - # if (TARGET clang-format) would be preferable, but this target is only added - # after Polly, i.e. there is no such target yet at this point. The CMake cache - # entry LLVM_TOOL_CLANG_BUILD will only be defined after clang has been - # configured at least once, i.e. format will be checked only after a rerun of - # CMake's configure. - if (LLVM_TOOL_CLANG_BUILD) - add_dependencies(check-polly polly-check-format) - endif () - -endif (NOT DEFINED LLVM_MAIN_SRC_DIR) +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/UnitIsl/lit.site.cfg.in + ${CMAKE_CURRENT_BINARY_DIR}/UnitIsl/lit.site.cfg) + +if (POLLY_BUNDLED_ISL) + add_lit_testsuite(check-polly-isl "Running isl unit tests only" + ${CMAKE_CURRENT_BINARY_DIR}/UnitIsl + PARAMS polly_site_config=${CMAKE_CURRENT_BINARY_DIR}/UnitIsl/lit.site.cfg + DEPENDS polly-isl-test + ) + set_target_properties(check-polly-isl PROPERTIES FOLDER "Polly") +endif (POLLY_BUNDLED_ISL) + +# Run polly-check-format as part of polly-check only if we are compiling with +# clang, so clang-format is available. +# if (TARGET clang-format) would be preferable, but this target is only added +# after Polly, i.e. there is no such target yet at this point. The CMake cache +# entry LLVM_TOOL_CLANG_BUILD will only be defined after clang has been +# configured at least once, i.e. format will be checked only after a rerun of +# CMake's configure. +if (LLVM_TOOL_CLANG_BUILD) + add_dependencies(check-polly polly-check-format) +endif () configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/update_check.py ${CMAKE_CURRENT_BINARY_DIR}/update_check.py) -file(COPY ${CMAKE_CURRENT_BINARY_DIR}/update_check.py - DESTINATION ${LLVM_TOOLS_DIR} - FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ - GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) # Add a legacy target spelling: polly-test add_custom_target(polly-test) diff --git a/polly/test/lit.cfg b/polly/test/lit.cfg index 45d774f..dc98292 100644 --- a/polly/test/lit.cfg +++ b/polly/test/lit.cfg @@ -39,7 +39,9 @@ if polly_obj_root is not None: llvm_tools_dir = getattr(config, 'llvm_tools_dir', None) if not llvm_tools_dir: lit_config.fatal('No LLVM tools dir set!') - path = os.path.pathsep.join((llvm_tools_dir, config.environment['PATH'])) + extra_paths = getattr(config, 'extra_paths', []) + base_paths = [llvm_tools_dir, config.environment['PATH']] + path = os.path.pathsep.join(base_paths + extra_paths) config.environment['PATH'] = path llvm_libs_dir = getattr(config, 'llvm_libs_dir', None) diff --git a/polly/test/lit.site.cfg.in b/polly/test/lit.site.cfg.in index c64641a..2ffef28 100644 --- a/polly/test/lit.site.cfg.in +++ b/polly/test/lit.site.cfg.in @@ -10,6 +10,7 @@ config.target_triple = "@TARGET_TRIPLE@" config.enable_gpgpu_codegen = "@GPU_CODEGEN@" config.link_polly_into_tools = "@LINK_POLLY_INTO_TOOLS@" config.targets_to_build = "@TARGETS_TO_BUILD@" +config.extra_paths = "@POLLY_TEST_EXTRA_PATHS@".split(";") ## Check the current platform with regex import re