Skip to content

Commit d8be0e0

Browse files
committed
[cmake] When not cross compiling, instead of searching for llvm-tblgen, just use the real native cmake target.
This fixes part of the Xcode build by allowing us to avoid having to use cmake variables with an unexpanded CMAKE_CFG_INTDIR. Since those variables are not expanded, they point to a non-existant path like: .../$(CONFIGURATION)$(...)/lib So finding tablegen fails. In the cross compile case, we still try to find the native tablegen. rdar://26154980
1 parent 73d0e86 commit d8be0e0

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

cmake/modules/SwiftSharedCMakeConfig.cmake

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,6 @@ macro(swift_common_standalone_build_config product is_cross_compiling)
2626

2727
precondition_translate_flag(${product}_PATH_TO_LLVM_SOURCE PATH_TO_LLVM_SOURCE)
2828
precondition_translate_flag(${product}_PATH_TO_LLVM_BUILD PATH_TO_LLVM_BUILD)
29-
set(PATH_TO_LLVM_TOOLS_BINARY_DIR "${PATH_TO_LLVM_BUILD}/bin")
30-
31-
if(NOT ${is_cross_compiling})
32-
set(${product}_NATIVE_LLVM_TOOLS_PATH "${PATH_TO_LLVM_TOOLS_BINARY_DIR}")
33-
set(${product}_NATIVE_CLANG_TOOLS_PATH "${PATH_TO_LLVM_TOOLS_BINARY_DIR}")
34-
endif()
35-
36-
find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" "${${product}_NATIVE_LLVM_TOOLS_PATH}"
37-
NO_DEFAULT_PATH)
3829

3930
set(LLVM_CMAKE_PATHS
4031
"${PATH_TO_LLVM_BUILD}/share/llvm/cmake"
@@ -126,6 +117,18 @@ macro(swift_common_standalone_build_config product is_cross_compiling)
126117

127118
list(APPEND CMAKE_MODULE_PATH "${${product}_PATH_TO_LLVM_BUILD}/share/llvm/cmake")
128119

120+
if(${is_cross_compiling})
121+
find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" "${${product}_NATIVE_LLVM_TOOLS_PATH}"
122+
NO_DEFAULT_PATH)
123+
if ("${LLVM_TABLEGEN_EXE}" STREQUAL "LLVM_TABLEGEN_EXE-NOTFOUND")
124+
message(FATAL_ERROR "Failed to find tablegen in ${${product}_NATIVE_LLVM_TOOLS_PATH}")
125+
endif()
126+
else()
127+
set(LLVM_TABLEGEN_EXE llvm-tblgen)
128+
set(${product}_NATIVE_LLVM_TOOLS_PATH "${PATH_TO_LLVM_TOOLS_BINARY_DIR}")
129+
set(${product}_NATIVE_CLANG_TOOLS_PATH "${PATH_TO_LLVM_TOOLS_BINARY_DIR}")
130+
endif()
131+
129132
include(AddLLVM)
130133
include(TableGen)
131134
include(HandleLLVMOptions)

0 commit comments

Comments
 (0)