add pkgconfig file
Change-Id: I8948adf1e15a2baad3d67400d8940902807bf9ed
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b84dcfa..161d535 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -5,6 +5,10 @@
set(CMAKE_CXX_STANDARD_REQUIRED ON)
include(CTest)
include(GNUInstallDirs)
+set (prefix ${CMAKE_INSTALL_PREFIX})
+set (exec_prefix "\${prefix}")
+set (libdir "${CMAKE_INSTALL_FULL_LIBDIR}")
+set (includedir "${CMAKE_INSTALL_FULL_INCLUDEDIR}")
find_package (PkgConfig REQUIRED)
find_package(msgpack REQUIRED QUIET CONFIG NAMES msgpack msgpack-cxx)
@@ -39,12 +43,18 @@
$<INSTALL_INTERFACE:include>
)
target_compile_definitions(dhtnet PUBLIC PJ_AUTOCONF=1)
-
set_target_properties(dhtnet PROPERTIES PUBLIC_HEADER "${dhtnet_HEADERS}")
+
+configure_file(dhtnet.pc.in dhtnet.pc @ONLY)
+
install(TARGETS dhtnet
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dhtnet
)
+# Install targets
+install (DIRECTORY include DESTINATION ${CMAKE_INSTALL_PREFIX})
+install (FILES ${CMAKE_CURRENT_BINARY_DIR}/opendht.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
+
if (BUILD_TESTING AND NOT MSVC)
pkg_search_module(Cppunit REQUIRED IMPORTED_TARGET cppunit)
add_executable(tests_certstore tests/certstore.cpp)
@@ -62,4 +72,4 @@
#add_executable(tests_stringutils tests/testString_utils.cpp)
#target_link_libraries(tests_stringutils PRIVATE dhtnet fmt::fmt PkgConfig::Cppunit)
#add_test(NAME tests_stringutils COMMAND tests_stringutils)
-endif()
\ No newline at end of file
+endif()