etc/services - sync with NetBSD-8
[minix.git] / external / bsd / llvm / dist / clang / runtime / CMakeLists.txt
blobad383f6cf7e0319a0c2448cc44be994f83609b50
1 # TODO: Set the install directory.
3 include(ExternalProject)
5 set(known_subdirs
6   "libcxx"
7   )
9 foreach (dir ${known_subdirs})
10   if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${dir}/CMakeLists.txt)
11     add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${dir})
12   endif()
13 endforeach()
15 function(get_ext_project_build_command out_var target)
16   if (CMAKE_GENERATOR MATCHES "Make")
17     # Use special command for Makefiles to support parallelism.
18     set(${out_var} "$(MAKE)" "${target}" PARENT_SCOPE)
19   else()
20     set(${out_var} ${CMAKE_COMMAND} --build . --target ${target}
21                                     --config $<CONFIGURATION> PARENT_SCOPE)
22   endif()
23 endfunction()
25 set(COMPILER_RT_SRC_ROOT ${LLVM_MAIN_SRC_DIR}/projects/compiler-rt)
26 if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND EXISTS ${COMPILER_RT_SRC_ROOT}/)
27   if(CMAKE_GENERATOR MATCHES "Ninja")
28     message(FATAL_ERROR
29             "Ninja generator can't build compiler-rt as ExternalProject."
30             "Unset LLVM_BUILD_EXTERNAL_COMPILER_RT, or don't use Ninja."
31             "See http://www.cmake.org/Bug/view.php?id=14771")
32   endif()
34   # Add compiler-rt as an external project.
35   set(COMPILER_RT_PREFIX ${CMAKE_BINARY_DIR}/projects/compiler-rt)
36   
37   ExternalProject_Add(compiler-rt
38     PREFIX ${COMPILER_RT_PREFIX}
39     SOURCE_DIR ${COMPILER_RT_SRC_ROOT}
40     CMAKE_ARGS -DCMAKE_C_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
41                -DCMAKE_CXX_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++
42                -DCMAKE_BUILD_TYPE=Release
43                -DLLVM_CONFIG_PATH=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-config
44                -DCOMPILER_RT_OUTPUT_DIR=${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}
45                -DCOMPILER_RT_EXEC_OUTPUT_DIR=${LLVM_RUNTIME_OUTPUT_INTDIR}
46                -DCOMPILER_RT_INSTALL_PATH=lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}
47                -DCOMPILER_RT_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
48                -DCOMPILER_RT_ENABLE_WERROR=ON
49     INSTALL_COMMAND ""
50     STEP_TARGETS configure build
51     )
52   # Due to a bug, DEPENDS in ExternalProject_Add doesn't work
53   # in CMake 2.8.9 and 2.8.10.
54   add_dependencies(compiler-rt llvm-config clang)
56   # Add a custom step to always re-configure compiler-rt (in case some of its
57   # sources have changed).
58   ExternalProject_Add_Step(compiler-rt force-reconfigure
59     DEPENDERS configure
60     ALWAYS 1
61     )
63   ExternalProject_Add_Step(compiler-rt clobber
64     COMMAND ${CMAKE_COMMAND} -E remove_directory <BINARY_DIR>
65     COMMAND ${CMAKE_COMMAND} -E make_directory <BINARY_DIR>
66     COMMENT "Clobberring compiler-rt build directory..."
67     DEPENDERS configure
68     DEPENDS ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
69   )
71   ExternalProject_Get_Property(compiler-rt BINARY_DIR)
72   set(COMPILER_RT_BINARY_DIR ${BINARY_DIR})
74   # Add top-level targets that build specific compiler-rt runtimes.
75   set(COMPILER_RT_RUNTIMES asan builtins dfsan lsan msan profile tsan ubsan)
76   foreach(runtime ${COMPILER_RT_RUNTIMES})
77     get_ext_project_build_command(build_runtime_cmd ${runtime})
78     add_custom_target(${runtime}
79       COMMAND ${build_runtime_cmd}
80       DEPENDS compiler-rt-configure
81       WORKING_DIRECTORY ${COMPILER_RT_BINARY_DIR}
82       VERBATIM)
83   endforeach()
85   # Add binaries that compiler-rt tests depend on.
86   set(COMPILER_RT_TEST_DEPENDENCIES
87     FileCheck count not llvm-nm llvm-symbolizer)
89   # Add top-level targets for various compiler-rt test suites.
90   set(COMPILER_RT_TEST_SUITES check-asan check-asan-dynamic check-dfsan
91     check-lsan check-msan check-sanitizer check-tsan check-ubsan)
92   foreach(test_suite ${COMPILER_RT_TEST_SUITES})
93     get_ext_project_build_command(run_test_suite ${test_suite})
94     add_custom_target(${test_suite}
95       COMMAND ${run_test_suite}
96       DEPENDS compiler-rt-build ${COMPILER_RT_TEST_DEPENDENCIES}
97       WORKING_DIRECTORY ${COMPILER_RT_BINARY_DIR}
98       VERBATIM)
99   endforeach()
101   # Add special target to run all compiler-rt test suites.
102   get_ext_project_build_command(run_check_compiler_rt check-all)
103   add_custom_target(check-compiler-rt
104     COMMAND ${run_check_compiler_rt}
105     DEPENDS compiler-rt-build ${COMPILER_RT_TEST_DEPENDENCIES}
106     WORKING_DIRECTORY ${COMPILER_RT_BINARY_DIR}
107     VERBATIM)
108 endif()