[llvm] [cmake] Allow multiple LibEdit_LIBRARIES (PR #93896)
Daniel Thornburgh via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 13 10:33:29 PDT 2024
mysterymath wrote:
> In my case with a statically linked libedit (& ncurses/libtinfo) pkg-config (in static mode, with `--static`) is aware of the `-ltinfo` dependency. I was able to make my build work, without forcing `LibEdit_LIBRARIES` to any value, with a patch like this:
>
> ```
> Author: Romain Geissler <romain.geissler at amadeus.com>
> Date: Tue Aug 13 02:22:31 2024 +0000
>
> Use include and libraries from libedit's pkg-config, which can be a list.
>
> diff --git a/llvm/cmake/modules/FindLibEdit.cmake b/llvm/cmake/modules/FindLibEdit.cmake
> index b3f49e1477f0..06266d05a24d 100644
> --- a/llvm/cmake/modules/FindLibEdit.cmake
> +++ b/llvm/cmake/modules/FindLibEdit.cmake
> @@ -54,12 +54,16 @@ find_package_handle_standard_args(LibEdit
> REQUIRED_VARS
> LibEdit_INCLUDE_DIRS
> LibEdit_LIBRARIES
> + PC_LIBEDIT_LIBRARIES
> + PC_LIBEDIT_LIBDIR
> + PC_LIBEDIT_INCLUDE_DIRS
> VERSION_VAR
> LibEdit_VERSION_STRING)
> mark_as_advanced(LibEdit_INCLUDE_DIRS LibEdit_LIBRARIES)
>
> if (LibEdit_FOUND AND NOT TARGET LibEdit::LibEdit)
> add_library(LibEdit::LibEdit INTERFACE IMPORTED)
> - target_link_libraries(LibEdit::LibEdit INTERFACE ${LibEdit_LIBRARIES})
> - target_include_directories(LibEdit::LibEdit INTERFACE ${LibEdit_INCLUDE_DIRS})
> + target_link_libraries(LibEdit::LibEdit INTERFACE ${PC_LIBEDIT_LIBRARIES})
> + target_link_directories(LibEdit::LibEdit INTERFACE ${PC_LIBEDIT_LIBDIR})
> + target_include_directories(LibEdit::LibEdit INTERFACE ${PC_LIBEDIT_INCLUDE_DIRS})
> endif()
> ```
>
> However if I understand correctly your usage (forcing manually `LibEdit_LIBRARIES`) it would break you if something like was merged. I wonder what to do here (I don't really like the idea of manually providing `LibEdit_LIBRARIES` myself while it seems at least in some cases pkg-config is good enough to find the necessary libraries.
Would it be possible to set `LibEdit_LIBRARIES` using the information from pkg-config?
https://github.com/llvm/llvm-project/pull/93896
More information about the llvm-commits
mailing list