How to fix CMake Could NOT find LibEdit (missing: LibEdit_INCLUDE_DIRS LibEdit_LIBRARIES)

Problem

When building your project using cmake ., you see the following warning or error message:

-- Could NOT find LibEdit (missing: LibEdit_INCLUDE_DIRS LibEdit_LIBRARIES)

Solution

This error indicates that CMake is unable to find the LibEdit library, which is a common library for command-line editing and history.

To resolve this issue, install it using

sudo apt install libedit-dev

Then, re-run cmake . and the error should be resolved.