From 7d89e6c1c0a01c959beddab643e39d2bc4c2c97d Mon Sep 17 00:00:00 2001 From: Petr Hosek Date: Fri, 21 Apr 2023 22:34:11 +0000 Subject: [PATCH] [CMake] Add missing find_package for LibEdit After building and installing LLVM with LibEdit as a dependency, it is necessary to find it again when LLVM is consumed by another CMake project, otherwise CMake will report an error about a missing target. Note that the FindLibEdit.cmake file is in the "LLVM Common CMake Utils" directory, outside of the LLVM sub-project source directory, so the installed LLVMConfig.cmake relies on the user having installed the LLVM common CMake modules or make available their own Find module. Also note that the controlling HAVE_LIBEDIT CMake variable in LLVMConfig.cmake.in has a different naming convention compared to other similar variables like 'LLVM_ENABLE_TERMINFO'. Refactoring this name would involve touching additional files and should be a follow-up commit. Patch By: ekilmer Differential Revision: https://reviews.llvm.org/D147153 --- llvm/cmake/config-ix.cmake | 10 ++++++++-- llvm/cmake/modules/LLVMConfig.cmake.in | 5 +++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake index 752ca33..2c81543 100644 --- a/llvm/cmake/config-ix.cmake +++ b/llvm/cmake/config-ix.cmake @@ -220,8 +220,12 @@ if(NOT LLVM_USE_SANITIZER MATCHES "Memory.*") if (NOT PURE_WINDOWS) # Skip libedit if using ASan as it contains memory leaks. if (LLVM_ENABLE_LIBEDIT AND NOT LLVM_USE_SANITIZER MATCHES ".*Address.*") - find_package(LibEdit) - set(HAVE_LIBEDIT ${LibEdit_FOUND}) + if(LLVM_ENABLE_LIBEDIT STREQUAL FORCE_ON) + find_package(LibEdit REQUIRED) + else() + find_package(LibEdit) + endif() + set(HAVE_LIBEDIT "${LibEdit_FOUND}") else() set(HAVE_LIBEDIT 0) endif() @@ -234,9 +238,11 @@ if(NOT LLVM_USE_SANITIZER MATCHES "Memory.*") set(LLVM_ENABLE_TERMINFO "${Terminfo_FOUND}") endif() else() + set(HAVE_LIBEDIT 0) set(LLVM_ENABLE_TERMINFO 0) endif() else() + set(HAVE_LIBEDIT 0) set(LLVM_ENABLE_TERMINFO 0) endif() diff --git a/llvm/cmake/modules/LLVMConfig.cmake.in b/llvm/cmake/modules/LLVMConfig.cmake.in index 2d90512..42dfd60 100644 --- a/llvm/cmake/modules/LLVMConfig.cmake.in +++ b/llvm/cmake/modules/LLVMConfig.cmake.in @@ -58,6 +58,11 @@ endif() set(LLVM_ENABLE_RTTI @LLVM_ENABLE_RTTI@) +set(LLVM_ENABLE_LIBEDIT @HAVE_LIBEDIT@) +if(LLVM_ENABLE_LIBEDIT) + find_package(LibEdit) +endif() + set(LLVM_ENABLE_TERMINFO @LLVM_ENABLE_TERMINFO@) if(LLVM_ENABLE_TERMINFO) find_package(Terminfo) -- 2.7.4