CMAKE_FIND_DEBUG_MODE for modules does not show considered paths in case the module is successfully or unsuccessfully found
Sample project:
cmake_minimum_required(VERSION 3.17)
project(proj)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
set(CMAKE_FIND_DEBUG_MODE TRUE)
find_package(MyModuleUnsuccessful MODULE)
find_package(MyModuleExisting MODULE)
find_package(MyModuleMissing MODULE)
set(CMAKE_FIND_DEBUG_MODE FALSE)
# $ cat FindMyModuleExisting.cmake
message(STATUS ">>> This is a message from inside MyModuleExisting")
set(MyModuleExisting_FOUND TRUE)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MyModuleExisting
REQUIRED_VARS MyModuleExisting_FOUND)
# $ cat FindMyModuleUnsuccessful.cmake
message(STATUS ">>> This is a message from inside MyModuleUnsuccessful")
set(MyModuleUnsuccessful_FOUND FALSE)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MyModuleUnsuccessful
REQUIRED_VARS MyModuleUnsuccessful_FOUND)
Configure output:
$ cmake ..
-- >>> This is a message from inside MyModuleUnsuccessful
-- Could NOT find MyModuleUnsuccessful (missing: MyModuleUnsuccessful_FOUND)
-- >>> This is a message from inside MyModuleExisting
-- Found MyModuleExisting: TRUE
CMake Debug Log at CMakeLists.txt:9 (find_package):
find_package considered the following paths for MyModuleMissing.cmake
/Volumes/T3/Dev/projects/cmake/general/find_package_module_debug/FindMyModuleMissing.cmake
/Users/alex/Dev/cmake/Modules/FindMyModuleMissing.cmake
The file was not found.
CMake Warning at CMakeLists.txt:9 (find_package):
No "FindMyModuleMissing.cmake" found in CMAKE_MODULE_PATH.
CMake Warning (dev) at CMakeLists.txt:9 (find_package):
FindMyModuleMissing.cmake must either be part of this project itself, in
this case adjust CMAKE_MODULE_PATH so that it points to the correct
location inside its source tree.
Or it must be installed by a package which has already been found via
find_package(). In this case make sure that package has indeed been found
and adjust CMAKE_MODULE_PATH to contain the location where that package has
installed FindMyModuleMissing.cmake. This must be a location provided by
that package. This error in general means that the buildsystem of this
project is relying on a Find-module without ensuring that it is actually
available.
This warning is for project developers. Use -Wno-dev to suppress it.
-- Configuring done
-- Generating done
Notice how the considered paths are shown for a find module file that was not found because there is no file on the file system.
For the case where the file was found, but the _FOUND
variable was set to FALSE, the considered paths are not shown.
Same for the case when the Find module is successfully found.
This is different from find_package(Foo CONFIG)
mode, where the considered file paths are always shown.
Edited by alcroito