Skip to content

Commit

Permalink
Fill NNG_PKGS to request nng dependencies from installed location. (n…
Browse files Browse the repository at this point in the history
…anomsg#1641)

Signed-off-by: Andrey Vostrikov <[email protected]>
Co-authored-by: Andrey Vostrikov <[email protected]>
  • Loading branch information
gdamore and avostrik authored Feb 5, 2023
1 parent e7a3e41 commit b6d2623
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cmake/FindmbedTLS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,5 @@ endif ()
string(REGEX REPLACE ".*MBEDTLS_VERSION_STRING[\t ]+\"(.*)\"" "\\1" MBEDTLS_VERSION ${_MBEDTLS_VERLINE})

find_package_handle_standard_args(mbedTLS
REQUIRED_VARS MBEDTLS_TLS_LIBRARY MBEDTLS_CRYPTO_LIBRARY MBEDTLS_X509_LIBRARY MBEDTLS_INCLUDE_DIR VERSION_VAR MBEDTLS_VERSION)
REQUIRED_VARS MBEDTLS_TLS_LIBRARY MBEDTLS_CRYPTO_LIBRARY MBEDTLS_X509_LIBRARY MBEDTLS_INCLUDE_DIR MBEDTLS_LIBRARIES VERSION_VAR MBEDTLS_VERSION)

10 changes: 9 additions & 1 deletion cmake/NNGHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ function(nng_defines)
target_compile_definitions(nng_private INTERFACE ${ARGN})
endfunction()

# nng_find_package looks up required package and adds dependency to the cmake config.
macro(nng_find_package PACKAGE_NAME)
find_package(${PACKAGE_NAME} REQUIRED)
list(APPEND NNG_PKGS ${PACKAGE_NAME})
list(REMOVE_DUPLICATES NNG_PKGS)
set(NNG_PKGS ${NNG_PKGS} CACHE INTERNAL "nng package dependencies" FORCE)
endmacro()

# nng_link_libraries adds link dependencies to the libraries.
function(nng_link_libraries)
target_link_libraries(nng PRIVATE ${ARGN})
Expand Down Expand Up @@ -156,4 +164,4 @@ endfunction(nng_check_struct_member)

macro(nng_directory DIR)
set(NNG_TEST_PREFIX ${NNG_TEST_PREFIX}.${DIR})
endmacro(nng_directory)
endmacro(nng_directory)
4 changes: 2 additions & 2 deletions src/platform/posix/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# the static library unless they also go into the dynamic.
if (NNG_PLATFORM_POSIX)

find_package(Threads REQUIRED)
nng_find_package(Threads)
nng_link_libraries(Threads::Threads)

# Unconditionally declare the following feature test macros. These are
Expand Down Expand Up @@ -108,4 +108,4 @@ if (NNG_PLATFORM_POSIX)

nng_test(posix_ipcwinsec_test)

endif ()
endif ()
2 changes: 1 addition & 1 deletion src/sp/transport/zerotier/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ if (NNG_TRANSPORT_ZEROTIER)
Consult a lawyer and the license files for details.
************************************************************")

find_package(zerotiercore REQUIRED)
nng_find_package(zerotiercore)

nng_link_libraries(zerotiercore::zerotiercore)
nng_defines(NNG_TRANSPORT_ZEROTIER)
Expand Down
2 changes: 1 addition & 1 deletion src/supplemental/tls/mbedtls/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ if (NNG_TLS_ENGINE STREQUAL "mbed")
if (TARGET mbedtls)
nng_link_libraries(mbedtls)
else()
find_package(mbedTLS REQUIRED)
nng_find_package(mbedTLS)
nng_link_libraries(${MBEDTLS_LIBRARIES})
nng_include_directories(${MBEDTLS_INCLUDE_DIR})
endif()
Expand Down

0 comments on commit b6d2623

Please sign in to comment.