Index: runtimes/CMakeLists.txt =================================================================== --- runtimes/CMakeLists.txt +++ runtimes/CMakeLists.txt @@ -45,7 +45,9 @@ endforeach() if(compiler_rt_path) list(REMOVE_ITEM runtimes ${compiler_rt_path}) - list(INSERT runtimes 0 ${compiler_rt_path}) + if(NOT LLVM_BUILD_COMPILER_RT) + list(INSERT runtimes 0 ${compiler_rt_path}) + endif() endif() # LLVMConfig.cmake contains a bunch of CMake variables from the LLVM build. @@ -87,6 +89,10 @@ set(CMAKE_REQUIRED_FLAGS ${SAFE_CMAKE_REQUIRED_FLAGS}) set(CMAKE_REQUIRED_LIBRARIES ${SAFE_CMAKE_REQUIRED_LIBRARIES}) + if(NOT LLVM_RUNTIMES_PREFIX) + set(LLVM_RUNTIMES_PREFIX "${LLVM_RUNTIMES_TARGET}") + endif() + foreach(entry ${runtimes}) get_filename_component(projName ${entry} NAME) @@ -98,7 +104,7 @@ if(LLVM_RUNTIMES_TARGET) if(NOT "${entry}" MATCHES "compiler-rt") - set(${canon_name}_INSTALL_PREFIX "lib/${LLVM_RUNTIMES_TARGET}/" CACHE STRING "" FORCE) + set(${canon_name}_INSTALL_PREFIX "lib/${LLVM_RUNTIMES_PREFIX}/" CACHE STRING "" FORCE) endif() endif() @@ -118,9 +124,9 @@ if(LLVM_RUNTIMES_TARGET) if(NOT "${entry}" MATCHES "compiler-rt") - set(LLVM_BINARY_DIR "${LLVM_LIBRARY_DIR}/${LLVM_RUNTIMES_TARGET}") - set(LLVM_LIBRARY_OUTPUT_INTDIR "${LLVM_LIBRARY_DIR}/${LLVM_RUNTIMES_TARGET}/lib") - set(LLVM_RUNTIME_OUTPUT_INTDIR "${LLVM_TOOLS_BINARY_DIR}/${LLVM_RUNTIMES_TARGET}") + set(LLVM_BINARY_DIR "${LLVM_LIBRARY_DIR}/${LLVM_RUNTIMES_PREFIX}") + set(LLVM_LIBRARY_OUTPUT_INTDIR "${LLVM_LIBRARY_DIR}/${LLVM_RUNTIMES_PREFIX}/lib") + set(LLVM_RUNTIME_OUTPUT_INTDIR "${LLVM_TOOLS_BINARY_DIR}/${LLVM_RUNTIMES_PREFIX}") endif() endif() @@ -282,7 +288,7 @@ # runtime_register_target(target) # Utility function to register external runtime target. - function(runtime_register_target target) + function(runtime_register_target target compiler_target) if(target STREQUAL LLVM_DEFAULT_TARGET_TRIPLE) include(${LLVM_BINARY_DIR}/runtimes/Components.cmake OPTIONAL) set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${LLVM_BINARY_DIR}/runtimes/Components.cmake) @@ -291,11 +297,9 @@ set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${LLVM_BINARY_DIR}/runtimes/${target}/Components.cmake) endif() - string(REPLACE "/" ";" target_list ${target_components}) - list(GET target_list 0 target) - list(LENGTH target_list target_list_len) - if(${target_list_len} GREATER 1) - list(GET target_list 1 target_variant) + set(${target}_deps ${deps}) + if(NOT target STREQUAL compiler_target) + list(APPEND ${target}_deps runtimes-${compiler_target}) endif() foreach(runtime_name ${runtime_names}) @@ -334,14 +338,14 @@ llvm_ExternalProject_Add(runtimes-${target} ${CMAKE_CURRENT_SOURCE_DIR} - DEPENDS ${deps} + DEPENDS ${${target}_deps} # Builtins were built separately above CMAKE_ARGS -DCOMPILER_RT_BUILD_BUILTINS=Off -DLLVM_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS} -DLLVM_LIBRARY_DIR=${LLVM_LIBRARY_DIR} - -DCMAKE_C_COMPILER_TARGET=${target} - -DCMAKE_CXX_COMPILER_TARGET=${target} - -DCMAKE_ASM_COMPILER_TARGET=${target} + -DCMAKE_C_COMPILER_TARGET=${compiler_target} + -DCMAKE_CXX_COMPILER_TARGET=${compiler_target} + -DCMAKE_ASM_COMPILER_TARGET=${compiler_target} -DCMAKE_C_COMPILER_WORKS=ON -DCMAKE_CXX_COMPILER_WORKS=ON -DCMAKE_ASM_COMPILER_WORKS=ON @@ -406,7 +410,15 @@ set(target ${LLVM_DEFAULT_TARGET_TRIPLE}) endif() - runtime_register_target(${target}) + set(compiler_target ${target}) + string(REPLACE "=" ";" target_list ${target}) + list(GET target_list 0 target) + list(LENGTH target_list target_list_len) + if(${target_list_len} GREATER 1) + list(GET target_list 1 compiler_target) + endif() + + runtime_register_target(${target} ${compiler_target}) add_dependencies(runtimes runtimes-${target}) add_dependencies(runtimes-configure runtimes-${target}-configure)