When linking Editline, use 'pkg-config' to correctly find the link-time dependencies...
authorAndrew V. Jones <andrew.jones@vector.com>
Thu, 30 Jul 2020 15:51:42 +0000 (16:51 +0100)
committerGitHub <noreply@github.com>
Thu, 30 Jul 2020 15:51:42 +0000 (08:51 -0700)
Signed-off-by: Andrew V. Jones <andrew.jones@vector.com>
.github/workflows/ci.yml
cmake/FindEditline.cmake
src/main/CMakeLists.txt

index 74c65cfac778a9fe7ede58e98993c9552764522f..498146bdb842216585322abf83183a98b29884c9 100644 (file)
@@ -85,6 +85,7 @@ jobs:
           cxxtest \
           cln \
           gmp \
+          pkgconfig \
           swig
         python3 -m pip install toml
         python3 -m pip install setuptools
index fe40011734ac54a5410da94e65667e42f6a2ccf5..aa4b90d7ab02ff57ad315fe18b3f77fd1c8ea145 100644 (file)
@@ -1,20 +1,22 @@
 # Find Editline
 # Editline_FOUND - found Editline lib
-# Editline_INCLUDE_DIR - the Editline include directory
+# Editline_INCLUDE_DIRS - the Editline include directory
 # Editline_LIBRARIES - Libraries needed to use Editline
 # Editline_COMPENTRY_FUNC_RETURNS_CHARPTR - Indicates if compentry function
 #                                           returns a (char *)
 
-find_path(Editline_INCLUDE_DIR NAMES histedit.h)
-find_library(Editline_LIBRARIES NAMES edit libedit)
+# When finding libedit, use pkg-config to ensure we find all the required
+# linking flags for libedit
+find_package(PkgConfig REQUIRED)
+pkg_check_modules(Editline REQUIRED libedit)
 
-if(Editline_INCLUDE_DIR)
+if(Editline_INCLUDE_DIRS)
   # Check which standard of editline is installed on the system.
   # https://github.com/CVC4/CVC4/issues/702
   include(CheckCXXSourceCompiles)
   set(CMAKE_REQUIRED_QUIET TRUE)
   set(CMAKE_REQUIRED_LIBRARIES ${Editline_LIBRARIES})
-  set(CMAKE_REQUIRED_INCLUDES ${Editline_INCLUDE_DIR})
+  set(CMAKE_REQUIRED_INCLUDES ${Editline_INCLUDE_DIRS})
   check_cxx_source_compiles(
     "#include <stdio.h>
      #include <editline/readline.h>
@@ -29,9 +31,9 @@ endif()
 
 include(FindPackageHandleStandardArgs)
 find_package_handle_standard_args(Editline
-  DEFAULT_MSG Editline_INCLUDE_DIR Editline_LIBRARIES)
+  DEFAULT_MSG Editline_INCLUDE_DIRS Editline_LIBRARIES)
 mark_as_advanced(
-  Editline_INCLUDE_DIR
+  Editline_INCLUDE_DIRS
   Editline_LIBRARIES
   Editline_COMPENTRY_FUNC_RETURNS_CHARPTR
 )
index c168daeaaefef09219d8a29a3308360d6fbdd455..ae0f8015b2b5c989228277df971d0374a4c3b2a3 100644 (file)
@@ -71,7 +71,7 @@ endif()
 if(USE_EDITLINE)
   target_link_libraries(cvc4-bin ${Editline_LIBRARIES})
   target_link_libraries(main-test ${Editline_LIBRARIES})
-  target_include_directories(main PRIVATE ${Editline_INCLUDE_DIR})
+  target_include_directories(main PRIVATE ${Editline_INCLUDE_DIRS})
 endif()
 
 #-----------------------------------------------------------------------------#