Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use FindPkgConfig to search for modules before doing manual search #488

Merged
merged 4 commits into from
Aug 10, 2022

Conversation

madebr
Copy link
Contributor

@madebr madebr commented Sep 18, 2020

  • Look for libraries and include directories using FindPkgConfig first, before doing a manual search using find_library and find_path
  • FindLibidn.cmake is not available, so remove all references and usages of LibIdn_xxx variables or Libidn::Libidn target

Fixes #487
Used in conan-io/conan-center-index#2903

@madebr
Copy link
Contributor Author

madebr commented Sep 18, 2020

Tests are failing because of #490

@wtoorop
Copy link
Contributor

wtoorop commented May 26, 2021

@banburybill can you review this? Thanks!

@wtoorop
Copy link
Contributor

wtoorop commented May 27, 2021

@madebr I took this for a spin, but cmake gave errors with me:

CMake Warning (dev) at /usr/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:273 (message):
  The package name passed to `find_package_handle_standard_args` (PkgConfig)
  does not match the name of the calling package (Libidn2).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  /usr/share/cmake-3.18/Modules/FindPkgConfig.cmake:59 (find_package_handle_standard_args)
  cmake/modules/FindLibidn2.cmake:31 (include)
  CMakeLists.txt:400 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.2") 
-- Checking for module 'libidn2'
--   Found libidn2, version 2.3.0
CMake Error at /usr/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:165 (message):
  Could NOT find Libidn2 (missing: LIBIDN2_INCLUDE_DIR) (found suitable
  version "2.3.0", minimum required is "2.0.0")
Call Stack (most recent call first):
  /usr/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:458 (_FPHSA_FAILURE_MESSAGE)
  cmake/modules/FindLibidn2.cmake:76 (find_package_handle_standard_args)
  CMakeLists.txt:400 (find_package)


-- Configuring incomplete, errors occurred!
See also "/home/willem/repos/getdns/build/CMakeFiles/CMakeOutput.log".
See also "/home/willem/repos/getdns/build/CMakeFiles/CMakeError.log".

(tried on Ubuntu 21.04)

It would be really nice to have this though, so if you can fix this, that would be highly appreciated and welcomed!

@madebr madebr force-pushed the cmake_pkgconfig branch from e1fd90c to 6eb1a67 Compare May 28, 2021 14:05
@madebr
Copy link
Contributor Author

madebr commented May 28, 2021

The issue was that pkg_check_modules returns an empty PkgLibIdn2_INCLUDE_DIRS variable.
This causes find_package_handle_standard_args to fail because LIBIDN2_INCLUDE_DIR is a required variable.
Fix this by only calling find_package_handle_standard_args when not using pkg-config.

@wtoorop wtoorop merged commit 1a1e796 into getdnsapi:develop Aug 10, 2022
@wtoorop
Copy link
Contributor

wtoorop commented Aug 10, 2022

Thanks! Worked like a charm (at least for me ;))

@madebr madebr deleted the cmake_pkgconfig branch August 10, 2022 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use FindPkgConfig module to look for dependencies
2 participants