summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2022-02-06 19:23:49 -0500
committerJune McEnroe <june@causal.agency>2022-02-06 19:23:49 -0500
commit327eb1a1dc6e9ffd4680fe44ae1e5701e36d18ef (patch)
treebc262c49ff1ce705fc280d48e675bb0952ae5df9
parentdash: Stop this stat64 nonsense (diff)
downloaddash-327eb1a1dc6e9ffd4680fe44ae1e5701e36d18ef.tar.gz
dash-327eb1a1dc6e9ffd4680fe44ae1e5701e36d18ef.zip
dash: Link with editline via pkg-config
-rw-r--r--CMakeLists.txt24
1 files changed, 15 insertions, 9 deletions
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()