diff --git a/README.md b/README.md index 5708529..fc1a8cf 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ First you need the dependencies * C++20 capable compiler * Tested with GCC 12.1 and Clang 14.0 * A installation of GNUnet 0.19 (or likely the latest version) -* libidn2 +* libidn (For examples) * CLI11 @@ -95,7 +95,7 @@ This project aims to create a easy to use wapper for the commonly used part of G - [ ] Port to C++ modules when CMake supports it - CMake - [x] Locate GNUnet installation path (currently use the expected path) - - [ ] Find libidn2 + - [x] Find libidn - DHT - [x] Basic operations (put/get) - [ ] Monitor diff --git a/cmake/FindGNUnet.cmake b/cmake/FindGNUnet.cmake index 71bd6ad..6193783 100644 --- a/cmake/FindGNUnet.cmake +++ b/cmake/FindGNUnet.cmake @@ -23,6 +23,9 @@ if (NOT all_libs_found) return() endif () +find_package(idn REQUIRED) +list(APPEND GNUnet_LIBRARIES idn::idn) + # HACK: CMake requires a library as the "target" of an imported library, so we # use a library we know will be present on the system. add_library(GNUnet::GNUnet IMPORTED UNKNOWN) diff --git a/cmake/Findidn.cmake b/cmake/Findidn.cmake new file mode 100644 index 0000000..565f686 --- /dev/null +++ b/cmake/Findidn.cmake @@ -0,0 +1,32 @@ +if(TARGET idn::idn) + return() +endif () + +find_library(IDN_LIBRARY NAMES idn) +if(NOT IDN_LIBRARY) + set(IDN_FOUND FALSE) + return() +endif() + +find_path(IDN_INCLUDE_DIR NAMES idna.h) +if(NOT IDN_INCLUDE_DIR) + set(IDN_FOUND FALSE) + return() +endif() + +set(IDN_FOUND TRUE) +set(IDN_LIBRARIES ${IDN_LIBRARY}) +set(IDN_INCLUDE_DIRS ${IDN_INCLUDE_DIR}) +mark_as_advanced(IDN_INCLUDE_DIRS IDN_LIBRARIES) + +add_library(idn::idn IMPORTED UNKNOWN) +set_target_properties(idn::idn PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${IDN_INCLUDE_DIRS}" + IMPORTED_LOCATION ${IDN_LIBRARIES} +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( + idn + REQUIRED_VARS IDN_LIBRARIES IDN_INCLUDE_DIRS +) \ No newline at end of file diff --git a/gnunetpp/CMakeLists.txt b/gnunetpp/CMakeLists.txt index 171f446..8f67fef 100644 --- a/gnunetpp/CMakeLists.txt +++ b/gnunetpp/CMakeLists.txt @@ -14,7 +14,7 @@ add_library(gnunetpp inner/Infra.cpp) target_include_directories(gnunetpp PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_precompile_headers(gnunetpp PRIVATE pch.hpp) -target_link_libraries(gnunetpp PUBLIC idn GNUnet::GNUnet) +target_link_libraries(gnunetpp PUBLIC GNUnet::GNUnet) # workaround for libintl.h conflicts target_compile_definitions(gnunetpp PUBLIC -DENABLE_NLS)