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

CMake warning on nested find_package #1448

Open
MathiasMagnus opened this issue May 5, 2020 · 0 comments
Open

CMake warning on nested find_package #1448

MathiasMagnus opened this issue May 5, 2020 · 0 comments

Comments

@MathiasMagnus
Copy link

MathiasMagnus commented May 5, 2020

It has annoyed me to no ends how the configuration output of rocLIBRARIES are CMake warnings that may be suppressed using -Wno-dev, but I am infact the dev of these libraries, so I don't want to universally turn of CMake script dev warnings. The warnings can be traced back to the package config scripts of HCC.

Problem

https://github.com/RadeonOpenCompute/hcc/blob/1b4c92ba631e8a5080dc82f96b3309ec834f1b19/lib/hcc-config.cmake.in#L30

The line is seemingly unecessary, as it relays to a one-liner script:

include(FindPkgConfig)

Which in turn emits a find_package(PkgConfig) command, however nesting find_package commands will mess up reporting results via canonical variables (hence the warning).

[cmake] CMake Warning (dev) at /snap/cmake/340/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:272 (message):
[cmake]   The package name passed to `find_package_handle_standard_args` (PkgConfig)
[cmake]   does not match the name of the calling package (hcc).  This can lead to
[cmake]   problems in calling code that expects `find_package` result variables
[cmake]   (e.g., `_FOUND`) to follow a certain pattern.
[cmake] Call Stack (most recent call first):
[cmake]   /snap/cmake/340/share/cmake-3.17/Modules/FindPkgConfig.cmake:45 (find_package_handle_standard_args)
[cmake]   /opt/rocm/hcc/lib/cmake/hcc/ImportedTargets.cmake:1 (include)
[cmake]   /opt/rocm/hcc/lib/cmake/hcc/hcc-config.cmake:54 (include)
[cmake]   cmake/VerifyCompiler.cmake:54 (find_package)
[cmake]   CMakeLists.txt:47 (include)
[cmake] This warning is for project developers.  Use -Wno-dev to suppress it.
[cmake] 
[cmake] -- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1") 
[cmake] CMake Warning (dev) at /snap/cmake/340/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:272 (message):
[cmake]   The package name passed to `find_package_handle_standard_args` (PkgConfig)
[cmake]   does not match the name of the calling package (hcc).  This can lead to
[cmake]   problems in calling code that expects `find_package` result variables
[cmake]   (e.g., `_FOUND`) to follow a certain pattern.
[cmake] Call Stack (most recent call first):
[cmake]   /snap/cmake/340/share/cmake-3.17/Modules/FindPkgConfig.cmake:45 (find_package_handle_standard_args)
[cmake]   /opt/rocm/hcc/lib/cmake/hcc/ImportedTargets.cmake:1 (include)
[cmake]   /opt/rocm/hcc/lib/cmake/hcc/hcc-config.cmake:54 (include)
[cmake]   /snap/cmake/340/share/cmake-3.17/Modules/CMakeFindDependencyMacro.cmake:47 (find_package)
[cmake]   /opt/rocm/hip/lib/cmake/hip/hip-config.cmake:77 (find_dependency)
[cmake]   cmake/VerifyCompiler.cmake:58 (find_package)
[cmake]   CMakeLists.txt:47 (include)
[cmake] This warning is for project developers.  Use -Wno-dev to suppress it.

The offending code which spawns these warnings are ordinary find_package calls to hcc and hip.

https://github.com/ROCmSoftwarePlatform/rocPRIM/blob/develop/cmake/VerifyCompiler.cmake#L54-L58

The warnings actually do mangle up, as the second warning actually looks for hip, but the warning message still says hcc for both line 54 and 58.

Solution

Uncommenting this line causes no harm, as nothing after it actually makes use of PkgConfig, so why include it? If it has to leak to some external script, unrelated to hcc-config.cmake, include it there. If you really insist on keeping it, use find_dependency instead, which as per the docs was created for this very purpose:

It is designed to be used in a Package Configuration File (<PackageName>Config.cmake).

Please remove the inclusion of FindPkgConfig or change to find_dependency if need be.

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

No branches or pull requests

1 participant