[llvm] a8648b4 - Add cmake_parse_arguments() to `tablegen()` CMake function
Mehdi Amini via llvm-commits
llvm-commits at lists.llvm.org
Sun Mar 13 23:56:38 PDT 2022
Author: Mehdi Amini
Date: 2022-03-14T06:56:11Z
New Revision: a8648b454ea05dc82b3c8c7b8354d0f035edbc7e
URL: https://github.com/llvm/llvm-project/commit/a8648b454ea05dc82b3c8c7b8354d0f035edbc7e
DIFF: https://github.com/llvm/llvm-project/commit/a8648b454ea05dc82b3c8c7b8354d0f035edbc7e.diff
LOG: Add cmake_parse_arguments() to `tablegen()` CMake function
This support "DEPENDS" and "EXTRA_INCLUDES", allowing in particular
to inject include paths to a tablegen targets without forcing to go
through the global INCLUDE_DIRECTORIES property.
Differential Revision: https://reviews.llvm.org/D121568
Added:
Modified:
llvm/cmake/modules/TableGen.cmake
Removed:
################################################################################
diff --git a/llvm/cmake/modules/TableGen.cmake b/llvm/cmake/modules/TableGen.cmake
index 59fd0d3b07336..5e58cbf6a72c9 100644
--- a/llvm/cmake/modules/TableGen.cmake
+++ b/llvm/cmake/modules/TableGen.cmake
@@ -4,6 +4,7 @@
# Adds the name of the generated file to TABLEGEN_OUTPUT.
function(tablegen project ofn)
+ cmake_parse_arguments(ARG "" "" "DEPENDS;EXTRA_INCLUDES" ${ARGN})
# Validate calling context.
if(NOT ${project}_TABLEGEN_EXE)
message(FATAL_ERROR "${project}_TABLEGEN_EXE not set")
@@ -91,13 +92,16 @@ function(tablegen project ofn)
# ("${${project}_TABLEGEN_TARGET}" STREQUAL "${${project}_TABLEGEN_EXE}")
# but lets us having smaller and cleaner code here.
get_directory_property(tblgen_includes INCLUDE_DIRECTORIES)
+ list(APPEND tblgen_includes ${ARG_EXTRA_INCLUDES})
+ # Filter out empty items before prepending each entry with -I
+ list(REMOVE_ITEM tblgen_includes "")
list(TRANSFORM tblgen_includes PREPEND -I)
set(tablegen_exe ${${project}_TABLEGEN_EXE})
set(tablegen_depends ${${project}_TABLEGEN_TARGET} ${tablegen_exe})
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${ofn}
- COMMAND ${tablegen_exe} ${ARGN} -I ${CMAKE_CURRENT_SOURCE_DIR}
+ COMMAND ${tablegen_exe} ${ARG_UNPARSED_ARGUMENTS} -I ${CMAKE_CURRENT_SOURCE_DIR}
${tblgen_includes}
${LLVM_TABLEGEN_FLAGS}
${LLVM_TARGET_DEFINITIONS_ABSOLUTE}
@@ -106,7 +110,7 @@ function(tablegen project ofn)
# The file in LLVM_TARGET_DEFINITIONS may be not in the current
# directory and local_tds may not contain it, so we must
# explicitly list it here:
- DEPENDS ${tablegen_depends}
+ DEPENDS ${ARG_DEPENDS} ${tablegen_depends}
${local_tds} ${global_tds}
${LLVM_TARGET_DEFINITIONS_ABSOLUTE}
${LLVM_TARGET_DEPENDS}
More information about the llvm-commits
mailing list