• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1set(LLVM_SHLIBEXT "${CMAKE_SHARED_MODULE_SUFFIX}")
2
3add_custom_target(check-polly)
4set_target_properties(check-polly PROPERTIES FOLDER "Polly")
5
6if(NOT LLVM_MAIN_SRC_DIR)
7  find_program(LLVM_OPT NAMES opt HINTS ${LLVM_TOOLS_BINARY_DIR})
8  find_program(LLVM_FILECHECK NAMES FileCheck HINTS ${LLVM_TOOLS_BINARY_DIR})
9  find_program(LLVM_NOT NAMES not HINTS ${LLVM_TOOLS_BINARY_DIR})
10  if (NOT LLVM_OPT)
11    message(WARNING "LLVM's opt program could not be found. Please set LLVM_OPT.")
12  endif()
13  if (NOT LLVM_FILECHECK)
14    message(WARNING "LLVM's FileCheck program could not be found. "
15      "Please set LLVM_FILECHECK. Please set LLVM_FILECHECK.")
16  endif()
17  if (NOT LLVM_NOT)
18    message(WARNING "LLVM's not program could not be found. Please set LLVM_NOT.")
19  endif()
20  get_filename_component(EXTRA_PATHS ${LLVM_OPT} DIRECTORY)
21  list(APPEND POLLY_TEST_EXTRA_PATHS "${EXTRA_PATHS}")
22  get_filename_component(EXTRA_PATHS ${LLVM_FILECHECK} DIRECTORY)
23  list(APPEND POLLY_TEST_EXTRA_PATHS "${EXTRA_PATHS}")
24  get_filename_component(EXTRA_PATHS ${LLVM_NOT} DIRECTORY)
25  list(APPEND POLLY_TEST_EXTRA_PATHS "${EXTRA_PATHS}")
26  list(REMOVE_DUPLICATES POLLY_TEST_EXTRA_PATHS)
27  message(STATUS "Extra paths: ${POLLY_TEST_EXTRA_PATHS}")
28  if ("${POLLY_TEST_EXTRA_PATHS}" STREQUAL "${LLVM_TOOLS_BINARY_DIR}")
29    set(POLLY_TEST_EXTRA_PATHS "")
30  endif()
31  set(POLLY_TEST_DEPS LLVMPolly)
32else ()
33  set(LLVM_OPT "${LLVM_TOOLS_BINARY_DIR}/opt")
34  set(LLVM_FILECHECK "${LLVM_TOOLS_BINARY_DIR}/FileCheck")
35  set(LLVM_NOT "${LLVM_TOOLS_BINARY_DIR}/not")
36  set(POLLY_TEST_EXTRA_PATHS "")
37  set(POLLY_TEST_DEPS llvm-config opt LLVMPolly FileCheck not)
38endif()
39
40if (POLLY_BUNDLED_ISL)
41  list(APPEND POLLY_TEST_DEPS polly-isl-test)
42endif()
43if (POLLY_GTEST_AVAIL)
44  list(APPEND POLLY_TEST_DEPS PollyUnitTests)
45endif ()
46
47set(LLVM_BINARY_DIR "${LLVM_BINARY_DIR}")
48set(LLVM_TOOLS_DIR "${LLVM_TOOLS_BINARY_DIR}")
49set(LLVM_LIBS_DIR "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}")
50if (CMAKE_LIBRARY_OUTPUT_DIRECTORY)
51  set(POLLY_LIB_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
52else()
53  set(POLLY_LIB_DIR "${POLLY_BINARY_DIR}/lib")
54endif()
55
56configure_lit_site_cfg(
57  ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
58  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg)
59
60# Run regression and unit tests
61add_lit_testsuite(check-polly-tests "Running polly regression tests"
62  ${CMAKE_CURRENT_BINARY_DIR}
63  PARAMS polly_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
64  polly_unit_site_config=${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg
65  DEPENDS ${POLLY_TEST_DEPS}
66  )
67set_target_properties(check-polly-tests PROPERTIES FOLDER "Polly")
68add_dependencies(check-polly check-polly-tests)
69
70configure_lit_site_cfg(
71  ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in
72  ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg
73  )
74
75if (POLLY_GTEST_AVAIL)
76  # Run only unit tests
77  add_lit_testsuite(check-polly-unittests "Running polly unit tests only"
78    ${CMAKE_CURRENT_BINARY_DIR}/Unit
79    PARAMS polly_site_config=${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg
80    DEPENDS PollyUnitTests
81    )
82  set_target_properties(check-polly-unittests PROPERTIES FOLDER "Polly")
83endif ()
84
85configure_file(
86  ${CMAKE_CURRENT_SOURCE_DIR}/UnitIsl/lit.site.cfg.in
87  ${CMAKE_CURRENT_BINARY_DIR}/UnitIsl/lit.site.cfg)
88
89if (POLLY_BUNDLED_ISL)
90  add_lit_testsuite(check-polly-isl "Running isl unit tests only"
91    ${CMAKE_CURRENT_BINARY_DIR}/UnitIsl
92    PARAMS polly_site_config=${CMAKE_CURRENT_BINARY_DIR}/UnitIsl/lit.site.cfg
93    DEPENDS polly-isl-test
94    )
95  set_target_properties(check-polly-isl PROPERTIES FOLDER "Polly")
96endif (POLLY_BUNDLED_ISL)
97
98# Run polly-check-format as part of polly-check only if we are compiling with
99# clang, so clang-format is available.
100# if (TARGET clang-format) would be preferable, but this target is only added
101# after Polly, i.e. there is no such target yet at this point. The CMake cache
102# entry LLVM_TOOL_CLANG_BUILD will only be defined after clang has been
103# configured at least once, i.e. format will be checked only after a rerun of
104# CMake's configure.
105if (LLVM_TOOL_CLANG_BUILD)
106  add_dependencies(check-polly polly-check-format)
107endif ()
108
109configure_file(
110  ${CMAKE_CURRENT_SOURCE_DIR}/update_check.py
111  ${CMAKE_CURRENT_BINARY_DIR}/update_check.py)
112
113# Add a legacy target spelling: polly-test
114add_custom_target(polly-test)
115set_target_properties(polly-test PROPERTIES FOLDER "Polly")
116add_dependencies(polly-test check-polly)
117