Skip to content

Commit

Permalink
[CMake] Pass additional CMake tools to external projects
Browse files Browse the repository at this point in the history
This is needed when the external projects try to use other tools
besides just the compiler and the linker.

Differential Revision: https://reviews.llvm.org/D47833

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334136 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
petrhosek committed Jun 6, 2018
1 parent 4063bab commit 957e46d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
24 changes: 22 additions & 2 deletions cmake/modules/LLVMExternalProjectUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function(llvm_ExternalProject_Add name source_dir)
if(NOT ARG_TOOLCHAIN_TOOLS)
set(ARG_TOOLCHAIN_TOOLS clang lld)
if(NOT APPLE AND NOT WIN32)
list(APPEND ARG_TOOLCHAIN_TOOLS llvm-ar llvm-ranlib)
list(APPEND ARG_TOOLCHAIN_TOOLS llvm-ar llvm-ranlib llvm-nm llvm-objcopy llvm-objdump llvm-strip)
endif()
endif()
foreach(tool ${ARG_TOOLCHAIN_TOOLS})
Expand Down Expand Up @@ -107,12 +107,27 @@ function(llvm_ExternalProject_Add name source_dir)
set(compiler_args -DCMAKE_C_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
-DCMAKE_CXX_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++)
endif()
if(lld IN_LIST TOOLCHAIN_TOOLS)
list(APPEND compiler_args -DCMAKE_LINKER=${LLVM_RUNTIME_OUTPUT_INTDIR}/ld.lld)
endif()
if(llvm-ar IN_LIST TOOLCHAIN_TOOLS)
list(APPEND compiler_args -DCMAKE_AR=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ar)
endif()
if(llvm-ranlib IN_LIST TOOLCHAIN_TOOLS)
list(APPEND compiler_args -DCMAKE_RANLIB=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ranlib)
endif()
if(llvm-nm IN_LIST TOOLCHAIN_TOOLS)
list(APPEND compiler_args -DCMAKE_NM=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-nm)
endif()
if(llvm-objdump IN_LIST TOOLCHAIN_TOOLS)
list(APPEND compiler_args -DCMAKE_OBJDUMP=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-objdump)
endif()
if(llvm-objcopy IN_LIST TOOLCHAIN_TOOLS)
list(APPEND compiler_args -DCMAKE_OBJCOPY=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-objcopy)
endif()
if(llvm-strip IN_LIST TOOLCHAIN_TOOLS)
list(APPEND compiler_args -DCMAKE_STRIP=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-strip)
endif()
list(APPEND ARG_DEPENDS ${TOOLCHAIN_TOOLS})
endif()

Expand All @@ -139,8 +154,13 @@ function(llvm_ExternalProject_Add name source_dir)
if(CMAKE_CROSSCOMPILING)
set(compiler_args -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_LINKER=${CMAKE_LINKER}
-DCMAKE_AR=${CMAKE_AR}
-DCMAKE_RANLIB=${CMAKE_RANLIB})
-DCMAKE_RANLIB=${CMAKE_RANLIB}
-DCMAKE_NM=${CMAKE_NM}
-DCMAKE_OBJCOPY=${CMAKE_OBJCOPY}
-DCMAKE_OBJDUMP=${CMAKE_OBJDUMP}
-DCMAKE_STRIP=${CMAKE_STRIP})
set(llvm_config_path ${LLVM_CONFIG_PATH})
else()
set(llvm_config_path "$<TARGET_FILE:llvm-config>")
Expand Down
4 changes: 2 additions & 2 deletions runtimes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ else() # if this is included from LLVM's CMake
-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON
${${target}_extra_args}
PASSTHROUGH_PREFIXES CLANG_DEFAULT
TOOLCHAIN_TOOLS clang lld llvm-ar llvm-ranlib
TOOLCHAIN_TOOLS clang lld llvm-ar llvm-ranlib llvm-nm llvm-objcopy llvm-objdump llvm-strip
USE_TOOLCHAIN
${EXTRA_ARGS})
endfunction()
Expand Down Expand Up @@ -463,7 +463,7 @@ else() # if this is included from LLVM's CMake
${${name}_extra_args}
PASSTHROUGH_PREFIXES LLVM_ENABLE_RUNTIMES
CLANG_DEFAULT
TOOLCHAIN_TOOLS clang lld llvm-ar llvm-ranlib
TOOLCHAIN_TOOLS clang lld llvm-ar llvm-ranlib llvm-nm llvm-objcopy llvm-objdump llvm-strip
EXTRA_TARGETS ${${name}_extra_targets}
${${name}_test_targets}
USE_TOOLCHAIN
Expand Down

0 comments on commit 957e46d

Please sign in to comment.