find_package: add a variable to request QUIET by default
Hello,
Use case:
bar
creates a library bar::bar
(both in its export(EXPORT barTargets NAMESPACE bar::)
and via add_library(bar::bar ALIAS bar)
. This makes it compatible with add_subdirectory()
and find_package()
Project foo
has decided to use bar
via find_package(bar)
.
We (project
) have decided to use them via add_subdirectory(bar)
and add_subdirectory(foo)
.
We are able to build successful, but there are a lot of CMake warnings since there is no barConfig.cmake
available during configuration time (they are created at installation as I have learned).
Log:
CMake Warning at /home/dev/project/CMakeLists.txt:18 (find_package):
By not providing "Findbar.cmake" in CMAKE_MODULE_PATH this project
has asked CMake to find a package configuration file provided by
"bar", but CMake did not find one.
Could not find a package configuration file provided by "bar" with
any of the following names:
barConfig.cmake
bar-config.cmake
Add the installation prefix of "bar" to CMAKE_PREFIX_PATH or set
"bar_DIR" to a directory containing one of the above files. If
"bar" provides a separate development package or SDK, be sure it
has been installed.
Do you have any solution how to make find_package()
find the EXPORT
of an add_subdirectory()
?
Alternatively I would like to make those warnings at least quiet.
I would welcome a variable CMAKE_FIND_PACKAGE_TARGETS_QUIET
in order to enable the QUIET
option for all find_package()
calls by default (analogue to CMAKE_FIND_PACKAGE_TARGETS_GLOBAL
). Maybe even a variable CMAKE_FIND_PACKAGE_IGNORE_REQUIRED
would be needed in case foo
uses find_package(bar REQUIRED)
.
My only concern with this approach is: What happens if foo
explicitly disables this via set(CMAKE_FIND_PACKAGE_TARGETS_QUIET OFF)
?