From 327eb1a1dc6e9ffd4680fe44ae1e5701e36d18ef Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Sun, 6 Feb 2022 19:23:49 -0500 Subject: dash: Link with editline via pkg-config --- CMakeLists.txt | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index 4871b35..9009ccd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,7 @@ include(CheckLibraryExists) include(CheckStructHasMember) include(CheckSymbolExists) include(CheckTypeSize) +include(FindPkgConfig) include(GNUInstallDirs) check_c_source_compiles([[ @@ -121,17 +122,22 @@ check_struct_has_member( option(WITH_LIBEDIT "Compile with libedit support") if(WITH_LIBEDIT) - check_include_file("histedit.h" HAVE_HISTEDIT_H) - check_library_exists(edit history_init /usr/lib LIBEDIT_FOUND) - if(HAVE_HISTEDIT_H AND LIBEDIT_FOUND) - link_libraries(edit) + pkg_check_modules(LIBEDIT IMPORTED_TARGET libedit) + if(LIBEDIT_FOUND) + link_libraries(PkgConfig::LIBEDIT) else() - message(SEND_ERROR "Can't find libedit.") + check_include_file("histedit.h" HAVE_HISTEDIT_H) + check_library_exists(edit history_init /usr/lib LIBEDIT_FOUND) + if(HAVE_HISTEDIT_H AND LIBEDIT_FOUND) + link_libraries(edit) + else() + message(SEND_ERROR "Can't find libedit.") + endif() + set(CMAKE_REQUIRED_LIBRARIES edit) + check_symbol_exists( + _el_fn_sh_complete "histedit.h" HAVE__EL_FN_SH_COMPLETE + ) endif() - set(CMAKE_REQUIRED_LIBRARIES edit) - check_symbol_exists( - _el_fn_sh_complete "histedit.h" HAVE__EL_FN_SH_COMPLETE - ) else() add_compile_definitions(SMALL) endif() -- cgit 1.4.1