[clang] c04eab8 - [Flang] Use find_program() to find clang-tblgen

Nikita Popov via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 29 02:09:39 PDT 2022


Author: Nikita Popov
Date: 2022-08-29T11:09:25+02:00
New Revision: c04eab8c78e517210c7641551ec008b09bfe20d0

URL: https://github.com/llvm/llvm-project/commit/c04eab8c78e517210c7641551ec008b09bfe20d0
DIFF: https://github.com/llvm/llvm-project/commit/c04eab8c78e517210c7641551ec008b09bfe20d0.diff

LOG: [Flang] Use find_program() to find clang-tblgen

There are two scenarios here:

1. Standalone flang build, where we use an installed clang-tblgen
   binary. We need to use find_package() to find it.
2. Combined build of clang and flang, where we want to use the
   path specified in CLANG_TABLEGEN_EXE during the clang build --
   however, this variable was previously not exported.

The new implementation matches what is done for mlir-tblgen.

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

Added: 
    

Modified: 
    clang/CMakeLists.txt
    flang/docs/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 2b1e968da3960..1064cfd0a35a3 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -484,6 +484,9 @@ option(CLANG_INCLUDE_TESTS
 
 add_subdirectory(utils/TableGen)
 
+# Export CLANG_TABLEGEN_EXE for use by flang docs.
+set(CLANG_TABLEGEN_EXE "${CLANG_TABLEGEN_EXE}" CACHE INTERNAL "")
+
 add_subdirectory(include)
 
 # All targets below may depend on all tablegen'd files.

diff  --git a/flang/docs/CMakeLists.txt b/flang/docs/CMakeLists.txt
index 770343cd29b80..3414b8e3acc46 100644
--- a/flang/docs/CMakeLists.txt
+++ b/flang/docs/CMakeLists.txt
@@ -126,7 +126,7 @@ if (LLVM_ENABLE_SPHINX)
         ARGS ${CMAKE_CURRENT_BINARY_DIR}/Source/FIR/CreateFIRLangRef.py)
 
       # CLANG_TABLEGEN_EXE variable needs to be set for clang_tablegen to run without error
-      set(CLANG_TABLEGEN_EXE clang-tblgen)
+      find_program(CLANG_TABLEGEN_EXE "clang-tblgen" ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH)
       gen_rst_file_from_td(FlangCommandLineReference.rst -gen-opt-docs FlangOptionsDocs.td docs-flang-html)
     endif()
     if (${SPHINX_OUTPUT_MAN})


        


More information about the cfe-commits mailing list