Skip to content

Commit 3e8e88e

Browse files
author
Chris Bieneman
committed
[CMake] Add support for exposing runtime targets
This patch adds support to the runtimes build for exposing sub-project targets through the high-level configuration. This will enable exposing the build, check and install targets for sub-project components (i.e. asan, check-asan, install-asan...). This patch requires minor changes to the runtime projects to take advantage of it, and I'll phase those changes into Compiler-RT shortly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279776 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 6361cd1 commit 3e8e88e

File tree

2 files changed

+44
-11
lines changed

2 files changed

+44
-11
lines changed

runtimes/CMakeLists.txt

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ endforeach()
1919
# triggered by the external project call for the runtimes target below.
2020
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
2121

22+
function(runtime_register_component name)
23+
set_property(GLOBAL APPEND PROPERTY SUB_COMPONENTS ${name})
24+
endfunction()
25+
2226
cmake_minimum_required(VERSION 3.4.3)
2327

2428
# Add the root project's CMake modules, and the LLVM build's modules to the
@@ -71,19 +75,44 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
7175
list(APPEND RUNTIMES_LIT_EXTRA_ARGS ${LLVM_LIT_EXTRA_ARGS})
7276
endforeach()
7377

74-
# Add a global check rule now that all subdirectories have been traversed
75-
# and we know the total set of lit testsuites.
76-
77-
add_lit_target(check-runtimes
78-
"Running all regression tests"
79-
${RUNTIMES_LIT_TESTSUITES}
80-
PARAMS ${RUNTIMES_LIT_PARAMS}
81-
DEPENDS ${RUNTIMES_LIT_DEPENDS}
82-
ARGS ${RUNTIMES_LIT_EXTRA_ARGS}
83-
)
84-
add_custom_target(test-depends-runtimes DEPENDS ${RUNTIMES_LIT_DEPENDS})
78+
if(LLVM_INCLUDE_TESTS)
79+
# Add a global check rule now that all subdirectories have been traversed
80+
# and we know the total set of lit testsuites.
81+
82+
add_lit_target(check-runtimes
83+
"Running all regression tests"
84+
${RUNTIMES_LIT_TESTSUITES}
85+
PARAMS ${RUNTIMES_LIT_PARAMS}
86+
DEPENDS ${RUNTIMES_LIT_DEPENDS}
87+
ARGS ${RUNTIMES_LIT_EXTRA_ARGS}
88+
)
89+
add_custom_target(test-depends-runtimes DEPENDS ${RUNTIMES_LIT_DEPENDS})
90+
endif()
91+
92+
get_property(SUB_COMPONENTS GLOBAL PROPERTY SUB_COMPONENTS)
93+
list(REMOVE_DUPLICATES SUB_COMPONENTS)
94+
foreach(component ${SUB_COMPONENTS})
95+
if(NOT TARGET ${component})
96+
message(SEND_ERROR "Missing target for runtime component ${component}!")
97+
continue()
98+
endif()
99+
if(LLVM_INCLUDE_TESTS AND NOT TARGET check-${component})
100+
message(SEND_ERROR "Missing check target for runtime component ${component}!")
101+
continue()
102+
endif()
103+
104+
if(TARGET install-${component})
105+
list(APPEND SUB_INSTALL_TARGETS install-${component})
106+
endif()
107+
endforeach()
108+
109+
configure_file(
110+
${CMAKE_CURRENT_SOURCE_DIR}/Components.cmake.in
111+
${LLVM_BINARY_DIR}/runtimes/Components.cmake)
85112

86113
else() # if this is included from LLVM's CMake
114+
include(${LLVM_BINARY_DIR}/runtimes/Components.cmake OPTIONAL)
115+
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${LLVM_BINARY_DIR}/runtimes/Components.cmake)
87116
include(LLVMExternalProjectUtils)
88117

89118
# If compiler-rt is present we need to build the builtin libraries first. This
@@ -134,6 +163,8 @@ else() # if this is included from LLVM's CMake
134163
EXTRA_TARGETS ${extra_targets}
135164
test-depends-runtimes
136165
check-runtimes
166+
${SUB_COMPONENTS}
167+
${SUB_INSTALL_TARGETS}
137168
USE_TOOLCHAIN)
138169
set_property(GLOBAL APPEND PROPERTY LLVM_LIT_DEPENDS test-depends-runtimes)
139170

runtimes/Components.cmake.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
set(SUB_COMPONENTS @SUB_COMPONENTS@)
2+
set(SUB_INSTALL_TARGETS @SUB_INSTALL_TARGETS@)

0 commit comments

Comments
 (0)