[llvm] 8f555a5 - [cmake] Fix tablegen exports
Sylvestre Ledru via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 16 05:17:47 PDT 2022
Author: Nikita Popov
Date: 2022-08-16T14:17:23+02:00
New Revision: 8f555a52e033ceec4c4508eb800c9a186acec87f
URL: https://github.com/llvm/llvm-project/commit/8f555a52e033ceec4c4508eb800c9a186acec87f
DIFF: https://github.com/llvm/llvm-project/commit/8f555a52e033ceec4c4508eb800c9a186acec87f.diff
LOG: [cmake] Fix tablegen exports
This fixes some fallout from D131282. Currently, add_tablegen() will add the tablegen target to LLVM_EXPORTS and associates the install with LLVMExports. For non-standalone builds, this means that you end up with mlir-tblgen and clang-tblgen in LLVMExports.
However, these projects should instead be using MLIR_EXPORTS/MLIRTargets and CLANG_EXPORTS/ClangTargets. To fix this, add an extra EXPORT option and make use of get_target_export_arg() to create the correct export argument.
Reviewed By: ashay-github
Differential Revision: https://reviews.llvm.org/D131565
Added:
Modified:
clang/utils/TableGen/CMakeLists.txt
llvm/cmake/modules/TableGen.cmake
llvm/utils/TableGen/CMakeLists.txt
mlir/tools/mlir-pdll/CMakeLists.txt
mlir/tools/mlir-tblgen/CMakeLists.txt
Removed:
################################################################################
diff --git a/clang/utils/TableGen/CMakeLists.txt b/clang/utils/TableGen/CMakeLists.txt
index d2cb29dd23a30..4666d4d7aa5ce 100644
--- a/clang/utils/TableGen/CMakeLists.txt
+++ b/clang/utils/TableGen/CMakeLists.txt
@@ -1,6 +1,8 @@
set(LLVM_LINK_COMPONENTS Support)
-add_tablegen(clang-tblgen CLANG DESTINATION "${CLANG_TOOLS_INSTALL_DIR}"
+add_tablegen(clang-tblgen CLANG
+ DESTINATION "${CLANG_TOOLS_INSTALL_DIR}"
+ EXPORT Clang
ASTTableGen.cpp
ClangASTNodesEmitter.cpp
ClangASTPropertiesEmitter.cpp
diff --git a/llvm/cmake/modules/TableGen.cmake b/llvm/cmake/modules/TableGen.cmake
index 172621d377485..59f6a1466078f 100644
--- a/llvm/cmake/modules/TableGen.cmake
+++ b/llvm/cmake/modules/TableGen.cmake
@@ -2,6 +2,7 @@
# while LLVM_TARGET_DEPENDS may contain additional file dependencies.
# Extra parameters for `tblgen' may come after `ofn' parameter.
# Adds the name of the generated file to TABLEGEN_OUTPUT.
+include(LLVMDistributionSupport)
function(tablegen project ofn)
cmake_parse_arguments(ARG "" "" "DEPENDS;EXTRA_INCLUDES" ${ARGN})
@@ -140,7 +141,7 @@ function(add_public_tablegen_target target)
endfunction()
macro(add_tablegen target project)
- cmake_parse_arguments(ADD_TABLEGEN "" "DESTINATION" "" ${ARGN})
+ cmake_parse_arguments(ADD_TABLEGEN "" "DESTINATION;EXPORT" "" ${ARGN})
set(${target}_OLD_LLVM_LINK_COMPONENTS ${LLVM_LINK_COMPONENTS})
set(LLVM_LINK_COMPONENTS ${LLVM_LINK_COMPONENTS} TableGen)
@@ -190,14 +191,12 @@ macro(add_tablegen target project)
endif()
if (ADD_TABLEGEN_DESTINATION AND NOT LLVM_INSTALL_TOOLCHAIN_ONLY AND LLVM_BUILD_UTILS)
- set(export_to_llvmexports)
- if(${target} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
- NOT LLVM_DISTRIBUTION_COMPONENTS)
- set(export_to_llvmexports EXPORT LLVMExports)
+ set(export_arg)
+ if(ADD_TABLEGEN_EXPORT)
+ get_target_export_arg(${target} ${ADD_TABLEGEN_EXPORT} export_arg)
endif()
-
install(TARGETS ${target}
- ${export_to_llvmexports}
+ ${export_arg}
COMPONENT ${target}
RUNTIME DESTINATION "${ADD_TABLEGEN_DESTINATION}")
if(NOT LLVM_ENABLE_IDE)
@@ -206,5 +205,8 @@ macro(add_tablegen target project)
COMPONENT ${target})
endif()
endif()
- set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${target})
+ if(ADD_TABLEGEN_EXPORT)
+ string(TOUPPER ${ADD_TABLEGEN_EXPORT} export_upper)
+ set_property(GLOBAL APPEND PROPERTY ${export_upper}_EXPORTS ${target})
+ endif()
endmacro()
diff --git a/llvm/utils/TableGen/CMakeLists.txt b/llvm/utils/TableGen/CMakeLists.txt
index bf4d51b8dca44..56035bd0e4e0b 100644
--- a/llvm/utils/TableGen/CMakeLists.txt
+++ b/llvm/utils/TableGen/CMakeLists.txt
@@ -2,7 +2,9 @@ add_subdirectory(GlobalISel)
set(LLVM_LINK_COMPONENTS Support)
-add_tablegen(llvm-tblgen LLVM DESTINATION "${LLVM_TOOLS_INSTALL_DIR}"
+add_tablegen(llvm-tblgen LLVM
+ DESTINATION "${LLVM_TOOLS_INSTALL_DIR}"
+ EXPORT LLVM
AsmMatcherEmitter.cpp
AsmWriterEmitter.cpp
AsmWriterInst.cpp
diff --git a/mlir/tools/mlir-pdll/CMakeLists.txt b/mlir/tools/mlir-pdll/CMakeLists.txt
index 6acee39e875cd..67b65d7ad5723 100644
--- a/mlir/tools/mlir-pdll/CMakeLists.txt
+++ b/mlir/tools/mlir-pdll/CMakeLists.txt
@@ -12,7 +12,9 @@ set(LIBS
MLIRPDLLParser
)
-add_tablegen(mlir-pdll MLIR_PDLL DESTINATION "${MLIR_TOOLS_INSTALL_DIR}"
+add_tablegen(mlir-pdll MLIR_PDLL
+ DESTINATION "${MLIR_TOOLS_INSTALL_DIR}"
+ EXPORT MLIR
mlir-pdll.cpp
DEPENDS
diff --git a/mlir/tools/mlir-tblgen/CMakeLists.txt b/mlir/tools/mlir-tblgen/CMakeLists.txt
index 85f9207f723b1..afc3ab1853986 100644
--- a/mlir/tools/mlir-tblgen/CMakeLists.txt
+++ b/mlir/tools/mlir-tblgen/CMakeLists.txt
@@ -4,7 +4,9 @@ set(LLVM_LINK_COMPONENTS
TableGen
)
-add_tablegen(mlir-tblgen MLIR DESTINATION "${MLIR_TOOLS_INSTALL_DIR}"
+add_tablegen(mlir-tblgen MLIR
+ DESTINATION "${MLIR_TOOLS_INSTALL_DIR}"
+ EXPORT MLIR
AttrOrTypeDefGen.cpp
AttrOrTypeFormatGen.cpp
CodeGenHelpers.cpp
More information about the llvm-commits
mailing list