summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2014-02-19 10:04:29 +0000
committerAlexey Samsonov <samsonov@google.com>2014-02-19 10:04:29 +0000
commit9559f844f5b9ec092f344c3d13b87ba4b3deebfb (patch)
tree98e81c9285fee23e5f4a5694907deb9fcdd20a63 /CMakeLists.txt
parente6e7eeeb3f0cf7da5121106664ebd0c368c8c60d (diff)
[CMake] Add the way to run tests in standalone build.
1) Depend on llvm-config (configured in LLVM_CONFIG_PATH) to get necessary LLVM source/binary directories. 2) Add basic support for running lit tests (check-xsan commands). For now this "support" is far from what we want: * unit tests are not built currently. * lit tests use Clang/compiler-rt from LLVM build directory, not the host compiler or just-built compiler-rt libraries. We should make a choice on the way we intend ti run compiler-rt lit testsuite: a) use either Clang from LLVM build tree, or the host compiler. b) use either just-built runtimes, or the runtimes shipped with the host compiler. Using just-built runtimes is tricky - we have to know where to put them, so that Clang/GCC driver would pick them up (and not overwrite the existing runtimes). Using a host compiler instead of Clang from LLVM build tree will give us a chance to run lit tests under GCC (which already has support for several sanitizers). That is, I tend to make the following choice: if we're in a standalone compiler-rt build, use host compiler with its set of runtime libraries to run lit tests. This will effectively decouple "make compiler-rt" and "make check-compiler-rt" in a standalone build - the latter wouldn't invoke the former. Note that if we decide to fix LLVM/Clang/compiler-rt build system so that it would configure/build compiler-rt with just-built Clang (as we do in Makefile-based build), this will not be a problem - we can add a dependency to ensure that clang/compiler-rt are rebuilt before running compiler-rt tests. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@201656 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt47
1 files changed, 37 insertions, 10 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ec63259b7..c5420516a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -44,23 +44,50 @@ else()
"Path where built compiler-rt libraries should be stored.")
set(COMPILER_RT_INSTALL_PATH ${CMAKE_INSTALL_PREFIX} CACHE PATH
"Path where built compiler-rt libraries should be installed.")
- # FIXME: Rely on llvm-config instead.
- set(LLVM_BUILD_DIR "" CACHE PATH "Path to LLVM build tree.")
- if (NOT LLVM_BUILD_DIR)
- message(FATAL_ERROR "LLVM_BUILD_DIR must be specified.")
+
+ set(LLVM_CONFIG_PATH "" CACHE PATH "Path to llvm-config binary")
+ if (NOT LLVM_CONFIG_PATH)
+ find_program(LLVM_CONFIG_PATH "llvm-config")
+ if (NOT LLVM_CONFIG_PATH)
+ message(FATAL_ERROR "llvm-config not found: specify LLVM_CONFIG_PATH")
+ endif()
endif()
+ execute_process(
+ COMMAND ${LLVM_CONFIG_PATH} "--obj-root" "--bindir" "--libdir" "--src-root"
+ RESULT_VARIABLE HAD_ERROR
+ OUTPUT_VARIABLE CONFIG_OUTPUT)
+ if (HAD_ERROR)
+ message(FATAL_ERROR "llvm-config failed with status ${HAD_ERROR}")
+ endif()
+ string(REGEX REPLACE "[ \t]*[\r\n]+[ \t]*" ";" CONFIG_OUTPUT ${CONFIG_OUTPUT})
+ list(GET CONFIG_OUTPUT 0 LLVM_BINARY_DIR)
+ list(GET CONFIG_OUTPUT 1 LLVM_TOOLS_BINARY_DIR)
+ list(GET CONFIG_OUTPUT 2 LLVM_LIBRARY_DIR)
+ list(GET CONFIG_OUTPUT 3 LLVM_MAIN_SRC_DIR)
+
# Make use of LLVM CMake modules.
- set(LLVM_CMAKE_PATH "${LLVM_BUILD_DIR}/share/llvm/cmake")
+ set(LLVM_CMAKE_PATH "${LLVM_BINARY_DIR}/share/llvm/cmake")
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}")
# Get some LLVM variables from LLVMConfig.
include("${LLVM_CMAKE_PATH}/LLVMConfig.cmake")
- # Setup another LLVM variables.
- # FIXME: get the following paths from llvm-config instead.
- set(LLVM_TOOLS_BINARY_DIR "${LLVM_BUILD_DIR}/bin")
- set(LLVM_LIBRARY_DIR "${LLVM_BUILD_DIR}/lib")
-
set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib)
+
+ # Find Python interpreter.
+ set(Python_ADDITIONAL_VERSIONS 2.7 2.6 2.5)
+ include(FindPythonInterp)
+ if(NOT PYTHONINTERP_FOUND)
+ message(FATAL_ERROR "
+ Unable to find Python interpreter required testing. Please install Python
+ or specify the PYTHON_EXECUTABLE CMake variable.")
+ endif()
+
+ # Define default arguments to lit.
+ set(LIT_ARGS_DEFAULT "-sv")
+ if (MSVC OR XCODE)
+ set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar")
+ endif()
+ set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" CACHE STRING "Default options for lit")
endif()
string(TOLOWER ${CMAKE_SYSTEM_NAME} COMPILER_RT_OS_DIR)