Skip to content

Commit

Permalink
Find IDN instead of using default path
Browse files Browse the repository at this point in the history
  • Loading branch information
marty1885 committed Jun 26, 2023
1 parent 1a3df87 commit 2375275
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions cmake/FindGNUnet.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
32 changes: 32 additions & 0 deletions cmake/Findidn.cmake
Original file line number Diff line number Diff line change
@@ -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
)
2 changes: 1 addition & 1 deletion gnunetpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 2375275

Please sign in to comment.