Draft
Fix non-portable opendhtConfig.cmake: use proper targets and find_dependency#860
Conversation
Replace non-portable target references in exported CMake config:
- Use GnuTLS::GnuTLS target instead of ${GNUTLS_LIBRARIES} (absolute paths)
- Use JsonCpp::JsonCpp instead of plain 'jsoncpp' library name
- Create opendhtConfig.cmake.in template with find_dependency() calls
to re-find all dependencies (PkgConfig::*, nettle_lib, etc.)
- Export targets to opendhtTargets.cmake, generate config from template
- Handles MSVC, pkgconfig, and non-pkgconfig Unix paths
Agent-Logs-Url: https://github.com/savoirfairelinux/opendht/sessions/d7522535-0905-41ec-a84e-b590d9613291
Co-authored-by: aberaud <101827+aberaud@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix portability issues in opendhtConfig.cmake
Fix non-portable opendhtConfig.cmake: use proper targets and find_dependency
May 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The exported
opendhtConfig.cmakecontained non-portable references: absolute build paths for GnuTLS (D:/projects/.../gnutls.lib), locally-created imported targets (nettle_lib,hogweed_lib,tasn1_lib), a barejsoncpplibrary name, andPkgConfig::*targets that don't exist for consumers.Changes
Replace non-portable link targets in
CMakeLists.txt${GNUTLS_LIBRARIES}(absolute paths) →GnuTLS::GnuTLS(available since CMake 3.16, we require 3.21+)jsoncpp(bare name) →JsonCpp::JsonCpp(already found viafind_package(jsoncpp CONFIG))Split export into two-file pattern
install(EXPORT ... FILE opendhtConfig.cmake)→FILE opendhtTargets.cmakeopendhtConfig.cmake.intemplate generates a proper config viaconfigure_package_config_file()New
opendhtConfig.cmake.inre-finds all dependencies before including targets:find_dependency()for GnuTLS/jsoncpp/fmt/simdutf/msgpack-cxx; recreatesnettle_lib/hogweed_lib/tasn1_libviafind_library()for static buildspkg_search_module()for eachPkgConfig::*targetfind_dependency()for GnuTLS, jsoncpp, fmtBuild options (
OPENDHT_HTTP,OPENDHT_TOOLS, etc.) are baked into the generated config so only the relevantfind_dependencycalls are emitted.