Send error for required but disabled packages.

When using CMAKE_DISABLE_FIND_PACKAGE_<name>=ON for a required package
CMake did not issue an errors since we never trigger the find_package
call. With this commit we now check whether such package is required
and send an error.
This commit is contained in:
Markus Blatt
2020-05-20 14:49:52 +02:00
parent 6f45df5e93
commit 9452796c57

View File

@@ -106,8 +106,13 @@ macro (find_and_append_package_to prefix name)
# if we're told not to look for the package, pretend it was never found
if (CMAKE_DISABLE_FIND_PACKAGE_${name})
set (${name}_FOUND FALSE)
set (${NAME}_FOUND FALSE)
# If required send an error
cmake_parse_arguments(FIND "REQUIRED" "" "" ${ARGN} )
set (${name}_FOUND FALSE)
set (${NAME}_FOUND FALSE)
if (FIND_REQUIRED)
message(SEND_ERROR "package ${name} but disable with CMAKE_DISABLE_FIND_PACKAGE_${name}")
endif ()
else ()
# List of components might differ for every module. Therefore we will
# need to research for a library multiple times. _search_components