Is there a way to have a specific target that is still able to build even if find_package fails? For instance, I have a target that just compiles the code documentation and naturally has no hard requirements/dependencies, but cmake won't even finish configuration in case there is a missing dependency.
CodePudding user response:
Did you read this part of documentation:
find_package — CMake 3.23.0-rc2 Documentation
Regardless of the mode used, a
<PackageName>_FOUNDvariable will be set to indicate whether the package was found. When the package is found, package-specific information may be provided through other variables and Imported Targets documented by the package itself. TheQUIEToption disables informational messages, including those indicating that the package cannot be found if it is notREQUIRED. TheREQUIREDoption stops processing with an error message if the package cannot be found.A package-specific list of required components may be listed after the
COMPONENTSkeyword. If any of these components are not able to be satisfied, the package overall is considered to be not found. If theREQUIREDoption is also present, this is treated as a fatal error, otherwise execution still continues. As a form of shorthand, if theREQUIREDoption is present, theCOMPONENTSkeyword can be omitted and the required components can be listed directly afterREQUIRED.Additional optional components may be listed after
OPTIONAL_COMPONENTS. If these cannot be satisfied, the package overall can still be considered found, as long as all required components are satisfied.
Note keywords: QUIET REQUIRED OPTIONAL_COMPONENTS
You can alter behavior of you cmake code by using <PackageName>_FOUND to handle failure.
