I have a required dependency Bar. Even if Bar is not found, CMake finishes configuring without error.
CMakeLists.txt
cmake_minimum_required(VERSION 3.27)
project(Foo)
set(CMAKE_MODULE_PATH "${Foo_SOURCE_DIR}")
find_package(Bar REQUIRED)
message(NOTICE "${Bar_FOUND}")
FindBar.cmake
set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
message(NOTICE "Set Bar not found")
CMake output:
$ cmake --fresh .
-- The C compiler identification is GNU 11.4.0
-- The CXX compiler identification is GNU 11.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/local/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/local/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
Set Bar not found
FALSE
-- Configuring done (0.6s)
-- Generating done (0.0s)
-- Build files have been written to: /tmp/foo
Is this expected? Is FindPackageHandleStandardArgs
needed to check Bar_FOUND? Does this behavior differ between Find Modules and config files?