From bd09c995b546a9cc733a0622bc3b0327fb1c4f67 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com>
Date: Wed, 20 Sep 2023 11:55:37 -0400
Subject: [PATCH] build: find/link readline for upnpctrl

Change-Id: I8a3adaea1827e79340955a4859ce76f621367888
---
 CMakeLists.txt | 6 ++++++
 Dockerfile     | 3 ++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 900be4e..5268775 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -231,6 +231,12 @@ if (BUILD_TOOLS AND NOT MSVC)
     target_include_directories(dnc PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tools)
     install(TARGETS dsh RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
 
+    find_library(READLINE_LIBRARIES readline)
+    find_path(READLINE_INCLUDE_DIR readline/readline.h)
+    add_library(readline STATIC IMPORTED)
+    set_target_properties(readline PROPERTIES
+        IMPORTED_LOCATION "${READLINE_LIBRARIES}"
+        INTERFACE_INCLUDE_DIRECTORIES "${READLINE_INCLUDE_DIR}")
     add_executable(upnpctrl
         tools/upnp/upnpctrl.cpp)
     target_link_libraries(upnpctrl PRIVATE dhtnet fmt::fmt readline)
diff --git a/Dockerfile b/Dockerfile
index b18078a..e11cc36 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -5,7 +5,8 @@ RUN apk add --no-cache \
 		nettle-dev \
         cppunit-dev gnutls-dev jsoncpp-dev \
         argon2-dev openssl-dev fmt-dev \
-        http-parser-dev asio-dev msgpack-cxx-dev
+        http-parser-dev asio-dev msgpack-cxx-dev \
+        readline-dev
 
 # Build restinio
 RUN mkdir restinio && cd restinio \
-- 
GitLab