Skip to content

Help: Add warnings about vars and options related to find_package()

Craig Scott requested to merge craig.scott/cmake:doc-find_package-advice into master

The CMAKE_REQUIRE_FIND_PACKAGE_<PackageName> and CMAKE_DISABLE_FIND_PACKAGE_<PackageName> variables have the potential to break projects in subtle ways. For simple cases, they can seem attractive, but there are common usage patterns for which these variables can yield unexpected results. Closely related is the case where the REQUIRED keyword is added after FIND_PACKAGE_ARGS in a FetchContent_Declare() call, leading to the same sort of problems as CMAKE_REQUIRE_FIND_PACKAGE_<PackageName>. Improve the documentation related to these cases.

The problems with the variables were raised in #23779. The changes here document specific cases that directly relate to that issue. The proposed changes in !8868 (closed) are also relevant. The changes in this MR absorb some of the proposed changes from !8868 (closed) which we want to keep. Other parts of !8868 (closed) will be left for separate discussion.

Merge request reports