[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. llvm-svn: 279776
This commit is contained in:
parent
3ed7dc705a
commit
d658f2fdb1
|
@ -19,6 +19,10 @@ endforeach()
|
||||||
# triggered by the external project call for the runtimes target below.
|
# triggered by the external project call for the runtimes target below.
|
||||||
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
|
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
|
||||||
|
function(runtime_register_component name)
|
||||||
|
set_property(GLOBAL APPEND PROPERTY SUB_COMPONENTS ${name})
|
||||||
|
endfunction()
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.4.3)
|
cmake_minimum_required(VERSION 3.4.3)
|
||||||
|
|
||||||
# Add the root project's CMake modules, and the LLVM build's modules to the
|
# 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})
|
||||||
list(APPEND RUNTIMES_LIT_EXTRA_ARGS ${LLVM_LIT_EXTRA_ARGS})
|
list(APPEND RUNTIMES_LIT_EXTRA_ARGS ${LLVM_LIT_EXTRA_ARGS})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
# Add a global check rule now that all subdirectories have been traversed
|
if(LLVM_INCLUDE_TESTS)
|
||||||
# and we know the total set of lit testsuites.
|
# Add a global check rule now that all subdirectories have been traversed
|
||||||
|
# and we know the total set of lit testsuites.
|
||||||
add_lit_target(check-runtimes
|
|
||||||
"Running all regression tests"
|
add_lit_target(check-runtimes
|
||||||
${RUNTIMES_LIT_TESTSUITES}
|
"Running all regression tests"
|
||||||
PARAMS ${RUNTIMES_LIT_PARAMS}
|
${RUNTIMES_LIT_TESTSUITES}
|
||||||
DEPENDS ${RUNTIMES_LIT_DEPENDS}
|
PARAMS ${RUNTIMES_LIT_PARAMS}
|
||||||
ARGS ${RUNTIMES_LIT_EXTRA_ARGS}
|
DEPENDS ${RUNTIMES_LIT_DEPENDS}
|
||||||
)
|
ARGS ${RUNTIMES_LIT_EXTRA_ARGS}
|
||||||
add_custom_target(test-depends-runtimes DEPENDS ${RUNTIMES_LIT_DEPENDS})
|
)
|
||||||
|
add_custom_target(test-depends-runtimes DEPENDS ${RUNTIMES_LIT_DEPENDS})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
get_property(SUB_COMPONENTS GLOBAL PROPERTY SUB_COMPONENTS)
|
||||||
|
list(REMOVE_DUPLICATES SUB_COMPONENTS)
|
||||||
|
foreach(component ${SUB_COMPONENTS})
|
||||||
|
if(NOT TARGET ${component})
|
||||||
|
message(SEND_ERROR "Missing target for runtime component ${component}!")
|
||||||
|
continue()
|
||||||
|
endif()
|
||||||
|
if(LLVM_INCLUDE_TESTS AND NOT TARGET check-${component})
|
||||||
|
message(SEND_ERROR "Missing check target for runtime component ${component}!")
|
||||||
|
continue()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(TARGET install-${component})
|
||||||
|
list(APPEND SUB_INSTALL_TARGETS install-${component})
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
configure_file(
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/Components.cmake.in
|
||||||
|
${LLVM_BINARY_DIR}/runtimes/Components.cmake)
|
||||||
|
|
||||||
else() # if this is included from LLVM's CMake
|
else() # if this is included from LLVM's CMake
|
||||||
|
include(${LLVM_BINARY_DIR}/runtimes/Components.cmake OPTIONAL)
|
||||||
|
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${LLVM_BINARY_DIR}/runtimes/Components.cmake)
|
||||||
include(LLVMExternalProjectUtils)
|
include(LLVMExternalProjectUtils)
|
||||||
|
|
||||||
# If compiler-rt is present we need to build the builtin libraries first. This
|
# 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
|
||||||
EXTRA_TARGETS ${extra_targets}
|
EXTRA_TARGETS ${extra_targets}
|
||||||
test-depends-runtimes
|
test-depends-runtimes
|
||||||
check-runtimes
|
check-runtimes
|
||||||
|
${SUB_COMPONENTS}
|
||||||
|
${SUB_INSTALL_TARGETS}
|
||||||
USE_TOOLCHAIN)
|
USE_TOOLCHAIN)
|
||||||
set_property(GLOBAL APPEND PROPERTY LLVM_LIT_DEPENDS test-depends-runtimes)
|
set_property(GLOBAL APPEND PROPERTY LLVM_LIT_DEPENDS test-depends-runtimes)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
set(SUB_COMPONENTS @SUB_COMPONENTS@)
|
||||||
|
set(SUB_INSTALL_TARGETS @SUB_INSTALL_TARGETS@)
|
Loading…
Reference in New Issue