[llvm] [CMake] Use correct exports file for MLIR tools (PR #120079)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 16 05:51:15 PST 2024


https://github.com/nikic created https://github.com/llvm/llvm-project/pull/120079

llvm_add_tool() currently does not respect the passed project and puts all tools into LLVMExports.cmake. This means that we end up with binaries like mlir-opt in LLVMExports.cmake instead of MLIRTargets.cmake, where they should be.

Adjust llvm_add_tool() to take the project into account.

>From b443e55162861125a50048ae9bc521e98058b273 Mon Sep 17 00:00:00 2001
From: Nikita Popov <npopov at redhat.com>
Date: Mon, 16 Dec 2024 14:44:43 +0100
Subject: [PATCH] [CMake] Use correct exports file for MLIR tools

llvm_add_tool() currently does not respect the passed project and
puts all tools into LLVMExports.cmake. This means that we end up
with binaries like mlir-opt in LLVMExports.cmake instead of
MLIRTargets.cmake, where they should be.

Adjust llvm_add_tool() to take the project into account.
---
 llvm/cmake/modules/AddLLVM.cmake | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 006dfb6de3a199..6cf0ee1a54dbdb 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -1483,7 +1483,7 @@ macro(llvm_add_tool project name)
 
     if ( ${name} IN_LIST LLVM_TOOLCHAIN_TOOLS OR NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
       if( LLVM_BUILD_TOOLS )
-        get_target_export_arg(${name} LLVM export_to_llvmexports)
+        get_target_export_arg(${name} ${project} export_to_llvmexports)
         install(TARGETS ${name}
                 ${export_to_llvmexports}
                 RUNTIME DESTINATION ${${project}_TOOLS_INSTALL_DIR}
@@ -1497,7 +1497,8 @@ macro(llvm_add_tool project name)
       endif()
     endif()
     if( LLVM_BUILD_TOOLS )
-      set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name})
+      string(TOUPPER "${project}" project_upper)
+      set_property(GLOBAL APPEND PROPERTY ${project_upper}_EXPORTS ${name})
     endif()
   endif()
   get_subproject_title(subproject_title)



More information about the llvm-commits mailing list