diff --git a/cmake/SFMLConfig.cmake.in b/cmake/SFMLConfig.cmake.in index cb4fdc82c..741161cc2 100644 --- a/cmake/SFMLConfig.cmake.in +++ b/cmake/SFMLConfig.cmake.in @@ -130,11 +130,11 @@ if (EXISTS "${targets_config_file}") foreach (component ${SFML_FIND_COMPONENTS}) string(TOUPPER "${component}" UPPER_COMPONENT) + set(SFML_${UPPER_COMPONENT}_FOUND FALSE) if (TARGET SFML::${component}) set(SFML_${UPPER_COMPONENT}_FOUND TRUE) - else() + elseif(SFML_FIND_REQUIRED_${component}) set(FIND_SFML_ERROR "Found SFML but requested component '${component}' is missing in the config defined in ${SFML_DIR}.") - set(SFML_${UPPER_COMPONENT}_FOUND FALSE) set(SFML_FOUND FALSE) endif() endforeach()