blob: a32b9943c2a685017b6a3e7ccc557926e88c611c [file] [log] [blame]
Douglas Gregor79865192009-06-05 23:57:17 +00001set(CLANG_TEST_DIRECTORIES
2 "Analysis"
Douglas Gregor81b747b2009-09-17 21:32:03 +00003 "CodeCompletion"
Douglas Gregor79865192009-06-05 23:57:17 +00004 "CodeGen"
5 "CodeGenCXX"
6 "CodeGenObjC"
Peter Collingbournef315fa82011-02-14 01:42:53 +00007 "CodeGenOpenCL"
Douglas Gregor79865192009-06-05 23:57:17 +00008 "Coverage"
Douglas Gregorebfc1802009-06-16 20:13:51 +00009 "CXX"
Douglas Gregor79865192009-06-05 23:57:17 +000010 "Driver"
11 "FixIt"
12 "Frontend"
Ted Kremenekf7507f22010-03-08 23:38:27 +000013 "Headers"
Douglas Gregor2e222532009-07-02 17:08:52 +000014 "Index"
Douglas Gregor79865192009-06-05 23:57:17 +000015 "Lexer"
16 "Misc"
17 "PCH"
18 "Parser"
19 "Preprocessor"
20 "Rewriter"
21 "Sema"
Peter Collingbourneced76712010-12-01 03:15:31 +000022 "SemaCUDA"
Douglas Gregor79865192009-06-05 23:57:17 +000023 "SemaCXX"
24 "SemaObjC"
25 "SemaObjCXX"
Peter Collingbourne39d3e7a2011-02-15 19:46:23 +000026 "SemaOpenCL"
Douglas Gregor79865192009-06-05 23:57:17 +000027 "SemaTemplate")
Douglas Gregoreb357b62009-06-05 16:00:31 +000028
Daniel Dunbar1e634922009-11-07 23:53:32 +000029set(LLVM_SOURCE_DIR "${LLVM_MAIN_SRC_DIR}")
30set(LLVM_BINARY_DIR "${LLVM_BINARY_DIR}")
Jeffrey Yasskin718b01d2011-02-15 07:54:28 +000031set(LLVM_BUILD_MODE "%(build_mode)s")
Daniel Dunbar30eb0552009-11-08 09:46:39 +000032set(LLVM_TOOLS_DIR "${LLVM_TOOLS_BINARY_DIR}/%(build_config)s")
33set(LLVM_LIBS_DIR "${LLVM_BINARY_DIR}/lib/%(build_config)s")
Daniel Dunbar1e634922009-11-07 23:53:32 +000034set(CLANG_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..")
35set(CLANG_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/..")
NAKAMURA Takumic3189e92011-02-03 09:01:12 +000036if(BUILD_SHARED_LIBS)
37 set(ENABLE_SHARED 1)
38else()
39 set(ENABLE_SHARED 0)
40endif(BUILD_SHARED_LIBS)
Daniel Dunbar1e634922009-11-07 23:53:32 +000041
42configure_file(
43 ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
44 ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg)
45
NAKAMURA Takumic3189e92011-02-03 09:01:12 +000046configure_file(
47 ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in
48 ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg
49 @ONLY)
50
Douglas Gregor79865192009-06-05 23:57:17 +000051include(FindPythonInterp)
52if(PYTHONINTERP_FOUND)
Oscar Fuentes57ca32b2011-02-05 19:08:56 +000053 if( LLVM_MAIN_SRC_DIR )
54 set(LIT "${LLVM_SOURCE_DIR}/utils/lit/lit.py")
55 else()
Oscar Fuentesba43a4d2011-02-05 21:37:51 +000056 set(LIT "${PATH_TO_LLVM_BUILD}/bin/${CMAKE_CFG_INTDIR}/llvm-lit")
Oscar Fuentes57ca32b2011-02-05 19:08:56 +000057 endif()
58
Oscar Fuentesba43a4d2011-02-05 21:37:51 +000059 if( PATH_TO_LLVM_BUILD )
60 set(CLANG_TEST_EXTRA_ARGS "--path=${CLANG_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}")
61 endif()
Douglas Gregor79865192009-06-05 23:57:17 +000062
Daniel Dunbare33f82f2009-11-22 21:55:22 +000063 option(CLANG_TEST_USE_VG "Run Clang tests under Valgrind" OFF)
64 if(CLANG_TEST_USE_VG)
65 set(CLANG_TEST_EXTRA_ARGS ${CLANG_TEST_EXTRA_ARGS} "--vg")
66 endif ()
67
NAKAMURA Takumic84aca42010-11-11 04:09:51 +000068 set(LIT_ARGS "${CLANG_TEST_EXTRA_ARGS} ${LLVM_LIT_ARGS}")
69 separate_arguments(LIT_ARGS)
70
Jeffrey Yasskin718b01d2011-02-15 07:54:28 +000071 add_custom_target(clang-test.deps)
72
Daniel Dunbar7af18d32009-09-17 19:55:53 +000073 foreach(testdir ${CLANG_TEST_DIRECTORIES})
Daniel Dunbare9a73232009-11-03 07:25:53 +000074 add_custom_target(clang-test-${testdir}
Daniel Dunbare9a73232009-11-03 07:25:53 +000075 COMMAND ${PYTHON_EXECUTABLE}
Oscar Fuentes57ca32b2011-02-05 19:08:56 +000076 ${LIT}
Daniel Dunbarb258d8f2009-11-05 16:36:19 +000077 --param clang_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
Daniel Dunbar1e634922009-11-07 23:53:32 +000078 --param build_config=${CMAKE_CFG_INTDIR}
NAKAMURA Takumic84aca42010-11-11 04:09:51 +000079 ${LIT_ARGS}
Daniel Dunbar7af18d32009-09-17 19:55:53 +000080 ${CMAKE_CURRENT_BINARY_DIR}/${testdir}
Daniel Dunbar2b1acd42010-07-29 22:57:17 +000081 DEPENDS clang c-index-test FileCheck not count
Daniel Dunbar7af18d32009-09-17 19:55:53 +000082 COMMENT "Running Clang regression tests in ${testdir}")
Douglas Gregorf5dba382009-06-05 16:26:18 +000083 endforeach()
Douglas Gregoreb357b62009-06-05 16:00:31 +000084
Douglas Gregor79865192009-06-05 23:57:17 +000085 add_custom_target(clang-test
Daniel Dunbare9a73232009-11-03 07:25:53 +000086 COMMAND ${PYTHON_EXECUTABLE}
Oscar Fuentes57ca32b2011-02-05 19:08:56 +000087 ${LIT}
Daniel Dunbarb258d8f2009-11-05 16:36:19 +000088 --param clang_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
Jeffrey Yasskin718b01d2011-02-15 07:54:28 +000089 --param clang_unit_site_config=${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg
Daniel Dunbar1e634922009-11-07 23:53:32 +000090 --param build_config=${CMAKE_CFG_INTDIR}
Jeffrey Yasskin718b01d2011-02-15 07:54:28 +000091 --param build_mode=${RUNTIME_BUILD_MODE}
NAKAMURA Takumic84aca42010-11-11 04:09:51 +000092 ${LIT_ARGS}
Daniel Dunbar7af18d32009-09-17 19:55:53 +000093 ${CMAKE_CURRENT_BINARY_DIR}
Daniel Dunbar7af18d32009-09-17 19:55:53 +000094 COMMENT "Running Clang regression tests")
Daniel Dunbarcceef8b2009-09-22 10:07:55 +000095
96 add_custom_target(clang-c++tests
Daniel Dunbare9a73232009-11-03 07:25:53 +000097 COMMAND ${PYTHON_EXECUTABLE}
Oscar Fuentes57ca32b2011-02-05 19:08:56 +000098 ${LIT}
Daniel Dunbarb258d8f2009-11-05 16:36:19 +000099 --param clang_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
Daniel Dunbar1e634922009-11-07 23:53:32 +0000100 --param build_config=${CMAKE_CFG_INTDIR}
NAKAMURA Takumic84aca42010-11-11 04:09:51 +0000101 ${LIT_ARGS}
Daniel Dunbarcceef8b2009-09-22 10:07:55 +0000102 ${CMAKE_CURRENT_SOURCE_DIR}/../utils/C++Tests
Daniel Dunbar2b1acd42010-07-29 22:57:17 +0000103 DEPENDS clang c-index-test FileCheck not count
Daniel Dunbarcceef8b2009-09-22 10:07:55 +0000104 COMMENT "Running Clang regression tests")
NAKAMURA Takumi3aa8c642010-11-29 01:18:56 +0000105
Jeffrey Yasskin718b01d2011-02-15 07:54:28 +0000106 if( NOT CLANG_BUILT_STANDALONE )
107 add_custom_target(check-all
108 COMMAND ${PYTHON_EXECUTABLE}
Oscar Fuentes57ca32b2011-02-05 19:08:56 +0000109 ${LIT}
NAKAMURA Takumi3aa8c642010-11-29 01:18:56 +0000110 --param build_config=${CMAKE_CFG_INTDIR}
111 --param build_mode=${RUNTIME_BUILD_MODE}
112 ${LIT_ARGS}
113 ${LLVM_BINARY_DIR}/test
114 ${CMAKE_CURRENT_BINARY_DIR}
115 COMMENT "Running Clang and LLVM regression tests")
Jeffrey Yasskin718b01d2011-02-15 07:54:28 +0000116 add_dependencies(check-all check.deps clang-test.deps)
NAKAMURA Takumi652f1ef2011-02-16 03:07:10 +0000117 add_dependencies(clang-test.deps
118 ClangUnitTests
119 llvm-dis opt
120 FileCheck count not
121 )
122
Jeffrey Yasskin718b01d2011-02-15 07:54:28 +0000123 endif()
NAKAMURA Takumif0d9d8b2010-12-10 02:58:03 +0000124
125 add_dependencies(clang-test clang-test.deps)
126 add_dependencies(clang-test.deps
127 clang clang-headers c-index-test
NAKAMURA Takumi652f1ef2011-02-16 03:07:10 +0000128 )
NAKAMURA Takumif0d9d8b2010-12-10 02:58:03 +0000129
Daniel Dunbare9a73232009-11-03 07:25:53 +0000130endif()