Score:0

How to force cmake search already installed readline in Ubuntu?

gb flag

04 64bit and trying to compile something and in my sources is this macro:

if( UNIX )
  # find Readline (terminal input library) includes and library
  #
  # READLINE_INCLUDE_DIR - where the directory containing the READLINE headers can be found
  # READLINE_LIBRARY     - full path to the READLINE library
  find_path(READLINE_INCLUDE_DIR readline/readline.h)
  find_library(READLINE_LIBRARY NAMES readline)

  message(STATUS "Found Readline library: ${READLINE_LIBRARY}")
  message(STATUS "Include dir is: ${READLINE_INCLUDE_DIR}")

  if (NOT READLINE_INCLUDE_DIR OR NOT READLINE_LIBRARY)
    message(FATAL_ERROR "** Readline library not found!\n** Your distro may provide a binary for Readline e.g. for ubuntu try apt-get install libreadline5-dev")
  endif ()

  add_library(readline SHARED IMPORTED GLOBAL)

  set_target_properties(readline
    PROPERTIES
      IMPORTED_LOCATION
        "${READLINE_LIBRARY}"
      INTERFACE_INCLUDE_DIRECTORIES
        "${READLINE_INCLUDE_DIR}")

else()
  # Provide a dummy target
  add_library(readline INTERFACE)
endif()

But there is an error:

-- Found Readline library: READLINE_LIBRARY-NOTFOUND
-- Include dir is: /usr/include
CMake Error at dep/readline/CMakeLists.txt:23 (message):
  ** Readline library not found!

-- Configuring incomplete, errors occurred!

But I have it installed:

libreadline-dev is already the newest version (8.0-4).

How can I force CMake use already installed readline? Is there something like this?

cmake ../ -DReadline_LIBRARY=/usr/lib/x86_64-linux-gnu -DReadline_INCLUDE_DIR=/usr/include/readline

It didnt work for me.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.