package components and NOTFOUND_MESSAGE vs NOT_FOUND_MESSAGE
There is a mismatch between the cmake documentation on package components and the package code in cmFindPackageCommand.cxx. The documentation uses "NOTFOUND_MESSAGE" but the source code uses "NOT_FOUND_MESSAGE".
Details: The documentation says: https://cmake.org/cmake/help/v3.7/manual/cmake-packages.7.html
"Here, the ClimbingStats_NOTFOUND_MESSAGE is set to a diagnosis that the package could not be found because an invalid component was specified. This message variable can be set for any case where the _FOUND variable is set to False, and will be displayed to the user."
But the current code in cmake git for Source/cmFindPackageCommand.cxx uses "NOT_FOUND" (note underline) instead of NOTFOUND:
bool cmFindPackageCommand::HandlePackageMode()
...
std::string foundVar = this->Name;
foundVar += "_FOUND";
std::string notFoundMessageVar = this->Name;
notFoundMessageVar += "_NOT_FOUND_MESSAGE";
std::string notFoundMessage;
...
if (configFileSetFOUNDFalse) {
/* clang-format off */
e << "Found package configuration file:\n"
" " << this->FileFound << "\n"
"but it set " << foundVar << " to FALSE so package \"" <<
this->Name << "\" is considered to be NOT FOUND.";
/* clang-format on */
if (!notFoundMessage.empty()) {
e << " Reason given by package: \n" << notFoundMessage << "\n";
}
}
I verified this by putting the following in a config file:
foreach (comp ${pdlfs-common_FIND_COMPONENTS})
if (NOT ";${PDLFS_ALL_COMPONENTS};" MATCHES ";${comp};")
set(pdlfs-common_FOUND False)
set(pdlfs-common_NOT_FOUND_MESSAGE
"[NOT_FOUND] Specified unsupported component: ${comp}")
set(pdlfs-common_NOTFOUND_MESSAGE
"[NOTFOUND] Specified unsupported component: ${comp}")
endif()
endforeach()
and then ran cmake with a missing component "test":
% grep find_pack ../CMakeLists.txt
find_package(pdlfs-common REQUIRED COMPONENTS test CONFIG)
% cmake ..
CMake Error at CMakeLists.txt:3 (find_package):
Found package configuration file:
/tmp/xccc/share/cmake/pdlfs-common/pdlfs-common-config.cmake
but it set pdlfs-common_FOUND to FALSE so package "pdlfs-common" is
considered to be NOT FOUND. Reason given by package:
[NOT_FOUND] Specified unsupported component: test
-- Configuring incomplete, errors occurred!
See also "/tmp/try3/b/CMakeFiles/CMakeOutput.log".
%
Which form is the correct one? "NOTFOUND" or "NOT_FOUND"?