Skip to content

Commit 5d984de

Browse files
committed
[cmake] Instead of setting LLVM_TABLEGEN_EXE, use our own SWIFT_TABLEGEN_EXE variable.
This eliminates us setting an LLVM_ prefixed variable in a situation where there is a viable alternative. We want to eliminate as many of these as possible since they can cause conflicts with variables set in LLVMConfig.cmake. I also added some convenience tablegen functions in AddSwiftTableGen.cmake and changed all tblgen users to use that instead. rdar://26154980
1 parent d31247c commit 5d984de

File tree

4 files changed

+21
-8
lines changed

4 files changed

+21
-8
lines changed

cmake/modules/AddSwiftTableGen.cmake

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
include(TableGen)
2+
3+
# This needs to be a macro since tablegen (which is a function) needs to set
4+
# variables in its parent scope.
5+
macro(swift_tablegen)
6+
tablegen(SWIFT ${ARGN})
7+
endmacro()
8+
9+
# This needs to be a macro since add_public_tablegen_target (which is a
10+
# function) needs to set variables in its parent scope.
11+
macro(swift_add_public_tablegen_target target)
12+
add_public_tablegen_target(${target})
13+
endmacro()

cmake/modules/SwiftSharedCMakeConfig.cmake

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,19 +109,19 @@ macro(swift_common_standalone_build_config product is_cross_compiling)
109109
list(APPEND CMAKE_MODULE_PATH "${${product}_PATH_TO_LLVM_BUILD}/share/llvm/cmake")
110110

111111
if(${is_cross_compiling})
112-
find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" "${${product}_NATIVE_LLVM_TOOLS_PATH}"
112+
find_program(SWIFT_TABLEGEN_EXE "llvm-tblgen" "${${product}_NATIVE_LLVM_TOOLS_PATH}"
113113
NO_DEFAULT_PATH)
114-
if ("${LLVM_TABLEGEN_EXE}" STREQUAL "LLVM_TABLEGEN_EXE-NOTFOUND")
114+
if ("${SWIFT_TABLEGEN_EXE}" STREQUAL "SWIFT_TABLEGEN_EXE-NOTFOUND")
115115
message(FATAL_ERROR "Failed to find tablegen in ${${product}_NATIVE_LLVM_TOOLS_PATH}")
116116
endif()
117117
else()
118-
set(LLVM_TABLEGEN_EXE llvm-tblgen)
118+
set(SWIFT_TABLEGEN_EXE llvm-tblgen)
119119
set(${product}_NATIVE_LLVM_TOOLS_PATH "${PATH_TO_LLVM_TOOLS_BINARY_DIR}")
120120
set(${product}_NATIVE_CLANG_TOOLS_PATH "${PATH_TO_LLVM_TOOLS_BINARY_DIR}")
121121
endif()
122122

123123
include(AddLLVM)
124-
include(TableGen)
124+
include(AddSwiftTableGen) # This imports TableGen from LLVM.
125125
include(HandleLLVMOptions)
126126

127127
set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}")

include/swift/Option/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
set(LLVM_TARGET_DEFINITIONS Options.td)
2-
tablegen(LLVM Options.inc -gen-opt-parser-defs)
3-
add_public_tablegen_target(SwiftOptions)
2+
swift_tablegen(Options.inc -gen-opt-parser-defs)
3+
swift_add_public_tablegen_target(SwiftOptions)

tools/SourceKit/tools/sourcekitd-test/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
set(LLVM_TARGET_DEFINITIONS Options.td)
2-
tablegen(LLVM Options.inc -gen-opt-parser-defs)
3-
add_public_tablegen_target(sourcekitdTestOptionsTableGen)
2+
swift_tablegen(Options.inc -gen-opt-parser-defs)
3+
swift_add_public_tablegen_target(sourcekitdTestOptionsTableGen)
44

55
if(SWIFT_SOURCEKIT_USE_INPROC_LIBRARY)
66
set(SOURCEKITD_TEST_DEPEND sourcekitdInProc)

0 commit comments

Comments
 (0)