Repository: conan-io/conan

Issue:
[bug] CMake Generator QUIET behaviour and message types.
1. According to [CMake](https://cmake.org/cmake/help/latest/command/find_package.html) `find_package(<pkg> QUIET)` should not print (informational) message (unless it could not be found...). However both cmake_find_package as well as CMakeDeps generators still print output even on success.  
E.g. `find_package(libsystemd REQUIRED QUIET)` results in:
~~~
-- Conan: Target declared 'libsystemd::libsystemd'
-- Conan: Component target declared 'libcap::cap'
-- Conan: Target declared 'libcap::libcap'
-- Conan: Target declared 'libmount::libmount'
[...]
~~~

I found CONAN_CMAKE_SILENT_OUTPUT which silences the output, but my question is if "QUIET" should not already do that.

2. Looking into the corresponding generated cmake files, I found something else: it looks like the message type is dropped, is this intentional?
~~~
 function(conan_message MESSAGE_OUTPUT)
     if(NOT CONAN_CMAKE_SILENT_OUTPUT)
         message(${ARGV${0}})
~~~
I.e. `conan_message(FATAL_ERROR [...]` will result in a `message([...]`

### Environment Details (include every applicable attribute)
  * Operating System+version: debian/testing (Debian 5.14.9-2 (2021-10-03) x86_64 GNU/Linux)
  * Compiler+version: gcc 10.3.0
  * Conan version: 1.42.0
  * Python version: 3.9.7


Discussion:
CLAassistant: [![CLA assistant check](https://cla-assistant.io/pull/badge/not_signed)](https://cla-assistant.io/conan-io/conan?pullRequest=12967) <br/>Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our [Contributor License Agreement](https://cla-assistant.io/conan-io/conan?pullRequest=12967) before we can accept your contribution.<br/><sub>You have signed the CLA already but the status is still pending? Let us [recheck](https://cla-assistant.io/check/conan-io/conan?pullRequest=12967) it.</sub>
praetorian20: Sorry about the broken template code, I think it's fixed in the latest patchset. I'll look into adding unit tests but I haven't been able to run them successfully yet. I keep running into this error with a lot of the cmakedeps tests even though I have cmake 3.22 installed - `Failed: Required 'cmake' tool version 'Any' is not available`

I'm following the instructions for running tests using pytest and executing this command - `venv/bin/python -m pytest . -k cmakedeps`. I'm using WSL Ubuntu 22.04, will try tomorrow on a RHEL 8 machine in case it's a WSL issue.
memsharded: > Sorry about the broken template code, I think it's fixed in the latest patchset. I'll look into adding unit tests but I haven't been able to run them successfully yet. I keep running into this error with a lot of the cmakedeps tests even though I have cmake 3.22 installed - Failed: Required 'cmake' tool version 'Any' is not available

No worries! Yes, we have some dicts defining tools and versions in ``conftest.py`` and it can be overriden in ``conftest_user.py``, to default cmake to a different version and location, it might be necessary so Conan uses your own cmake



Patch:
diff --git a/conan/tools/cmake/cmakedeps/templates/config.py b/conan/tools/cmake/cmakedeps/templates/config.py
index 5892a4160..07b44a4a8 100644
--- a/conan/tools/cmake/cmakedeps/templates/config.py
+++ b/conan/tools/cmake/cmakedeps/templates/config.py
@@ -45,6 +45,12 @@ class ConfigTemplate(CMakeDepsFileTemplate):
             message(FATAL_ERROR "The 'CMakeDeps' generator only works with CMake >= 3.15")
         endif()
 
+        if({{ file_name }}_FIND_QUIETLY)
+            set({{ file_name }}_MESSAGE_MODE VERBOSE)
+        else()
+            set({{ file_name }}_MESSAGE_MODE STATUS)
+        endif()
+
         include(${CMAKE_CURRENT_LIST_DIR}/cmakedeps_macros.cmake)
         include(${CMAKE_CURRENT_LIST_DIR}/{{ targets_include_file }})
         include(CMakeFindDependencyMacro)
@@ -66,7 +72,7 @@ class ConfigTemplate(CMakeDepsFileTemplate):
 
         # Only the first installed configuration is included to avoid the collision
         foreach(_BUILD_MODULE {{ '${' + pkg_name + '_BUILD_MODULES_PATHS' + config_suffix + '}' }} )
-            message(STATUS "Conan: Including build module from '${_BUILD_MODULE}'")
+            message({% raw %}${{% endraw %}{{ file_name }}_MESSAGE_MODE} "Conan: Including build module from '${_BUILD_MODULE}'")
             include({{ '${_BUILD_MODULE}' }})
         endforeach()
 
@@ -76,7 +82,7 @@ class ConfigTemplate(CMakeDepsFileTemplate):
         if({{ file_name }}_FIND_COMPONENTS)
             foreach(_FIND_COMPONENT {{ '${'+file_name+'_FIND_COMPONENTS}' }})
                 if (TARGET ${_FIND_COMPONENT})
-                    message(STATUS "Conan: Component '${_FIND_COMPONENT}' found in package '{{ pkg_name }}'")
+                    message({% raw %}${{% endraw %}{{ file_name }}_MESSAGE_MODE} "Conan: Component '${_FIND_COMPONENT}' found in package '{{ pkg_name }}'")
                 else()
                     message(FATAL_ERROR "Conan: Component '${_FIND_COMPONENT}' NOT found in package '{{ pkg_name }}'")
                 endif()
diff --git a/conan/tools/cmake/cmakedeps/templates/targets.py b/conan/tools/cmake/cmakedeps/templates/targets.py
index c3cea116d..42d8d7f9c 100644
--- a/conan/tools/cmake/cmakedeps/templates/targets.py
+++ b/conan/tools/cmake/cmakedeps/templates/targets.py
@@ -66,13 +66,13 @@ class TargetsTemplate(CMakeDepsFileTemplate):
         foreach(_COMPONENT {{ '${' + pkg_name + '_COMPONENT_NAMES' + '}' }} )
             if(NOT TARGET ${_COMPONENT})
                 add_library(${_COMPONENT} INTERFACE IMPORTED)
-                message(STATUS "Conan: Component target declared '${_COMPONENT}'")
+                message({% raw %}${{% endraw %}{{ file_name }}_MESSAGE_MODE} "Conan: Component target declared '${_COMPONENT}'")
             endif()
         endforeach()
 
         if(NOT TARGET {{ root_target_name }})
             add_library({{ root_target_name }} INTERFACE IMPORTED)
-            message(STATUS "Conan: Target declared '{{ root_target_name }}'")
+            message({% raw %}${{% endraw %}{{ file_name }}_MESSAGE_MODE} "Conan: Target declared '{{ root_target_name }}'")
         endif()
 
         {%- for alias, target in cmake_target_aliases.items() %}
diff --git a/conans/client/conf/__init__.py b/conans/client/conf/__init__.py
index ad204d43b..7971b1feb 100644
--- a/conans/client/conf/__init__.py
+++ b/conans/client/conf/__init__.py
@@ -90,9 +90,9 @@ _t_default_settings_yml = Template(textwrap.dedent("""
                       "5", "5.1", "5.2", "5.3", "5.4", "5.5",
                       "6", "6.1", "6.2", "6.3", "6.4", "6.5",
                       "7", "7.1", "7.2", "7.3", "7.4", "7.5",
-                      "8", "8.1", "8.2", "8.3", "8.4",
-                      "9", "9.1", "9.2", "9.3", "9.4",
-                      "10", "10.1", "10.2", "10.3",
+                      "8", "8.1", "8.2", "8.3", "8.4", "8.5",
+                      "9", "9.1", "9.2", "9.3", "9.4", "9.5",
+                      "10", "10.1", "10.2", "10.3", "10.4",
                       "11", "11.1", "11.2", "11.3",
                       "12", "12.1", "12.2"]
             libcxx: [libstdc++, libstdc++11]
diff --git a/conans/client/migrations_settings.py b/conans/client/migrations_settings.py
index 811bc2d70..fde2d0f69 100644
--- a/conans/client/migrations_settings.py
+++ b/conans/client/migrations_settings.py
@@ -4188,4 +4188,156 @@ settings_1_56_0 = settings_1_55_0
 
 settings_1_57_0 = settings_1_56_0
 
-settings_1_58_0 = settings_1_57_0
+settings_1_58_0 = """
+# Only for cross building, 'os_build/arch_build' is the system that runs Conan
+os_build: [Windows, WindowsStore, Linux, Macos, FreeBSD, SunOS, AIX, VxWorks]
+arch_build: [x86, x86_64, ppc32be, ppc32, ppc64le, ppc64, armv5el, armv5hf, armv6, armv7, armv7hf, armv7s, armv7k, armv8, armv8_32, armv8.3, sparc, sparcv9, mips, mips64, avr, s390, s390x, sh4le, e2k-v2, e2k-v3, e2k-v4, e2k-v5, e2k-v6, e2k-v7]
+
+# Only for building cross compilation tools, 'os_target/arch_target' is the system for
+# which the tools generate code
+os_target: [Windows, Linux, Macos, Android, iOS, watchOS, tvOS, FreeBSD, SunOS, AIX, Arduino, Neutrino]
+arch_target: [x86, x86_64, ppc32be, ppc32, ppc64le, ppc64, armv5el, armv5hf, armv6, armv7, armv7hf, armv7s, armv7k, armv8, armv8_32, armv8.3, sparc, sparcv9, mips, mips64, avr, s390, s390x, asm.js, wasm, sh4le, e2k-v2, e2k-v3, e2k-v4, e2k-v5, e2k-v6, e2k-v7, xtensalx6, xtensalx106, xtensalx7]
+
+# Rest of the settings are "host" settings:
+# - For native building/cross building: Where the library/program will run.
+# - For building cross compilation tools: Where the cross compiler will run.
+os:
+    Windows:
+        subsystem: [None, cygwin, msys, msys2, wsl]
+    WindowsStore:
+        version: ["8.1", "10.0"]
+    WindowsCE:
+        platform: ANY
+        version: ["5.0", "6.0", "7.0", "8.0"]
+    Linux:
+    iOS:
+        version: &ios_version
+                 ["7.0", "7.1", "8.0", "8.1", "8.2", "8.3", "9.0", "9.1", "9.2", "9.3", "10.0", "10.1", "10.2", "10.3",
+                  "11.0", "11.1", "11.2", "11.3", "11.4", "12.0", "12.1", "12.2", "12.3", "12.4",
+                  "13.0", "13.1", "13.2", "13.3", "13.4", "13.5", "13.6", "13.7",
+                  "14.0", "14.1", "14.2", "14.3", "14.4", "14.5", "14.6", "14.7", "14.8",
+                  "15.0", "15.1", "15.2", "15.3", "15.4", "15.5", "15.6", "16.0", "16.1"]
+        sdk: [None, "iphoneos", "iphonesimulator"]
+        sdk_version: [None, "11.3", "11.4", "12.0", "12.1", "12.2", "12.4",
+                      "13.0", "13.1", "13.2", "13.4", "13.5", "13.6", "13.7",
+                      "14.0", "14.1", "14.2", "14.3", "14.4", "14.5", "15.0", "15.2", "15.4", "15.5", "16.0", "16.1"]
+    watchOS:
+        version: ["4.0", "4.1", "4.2", "4.3", "5.0", "5.1", "5.2", "5.3", "6.0", "6.1", "6.2",
+                  "7.0", "7.1", "7.2", "7.3", "7.4", "7.5", "7.6", "8.0", "8.1", "8.3", "8.4", "8.5", "8.6", "8.7", "9.0", "9.1"]
+        sdk: [None, "watchos", "watchsimulator"]
+        sdk_version: [None, "4.3", "5.0", "5.1", "5.2", "5.3", "6.0", "6.1", "6.2",
+                      "7.0", "7.1", "7.2", "7.4", "8.0", "8.0.1", "8.3", "8.5", "9.0", "9.1"]
+    tvOS:
+        version: ["11.0", "11.1", "11.2", "11.3", "11.4", "12.0", "12.1", "12.2", "12.3", "12.4",
+                  "13.0", "13.2", "13.3", "13.4", "14.0", "14.2", "14.3", "14.4", "14.5", "14.6", "14.7",
+                  "15.0", "15.1", "15.2", "15.3", "15.4", "15.5", "15.6", "16.0", "16.1"]
+        sdk: [None, "appletvos", "appletvsimulator"]
+        sdk_version: [None, "11.3", "11.4", "12.0", "12.1", "12.2", "12.4",
+                      "13.0", "13.1", "13.2", "13.4", "14.0", "14.2", "14.3", "14.5", "15.0", "15.2", "15.4", "16.0", "16.1"]
+    Macos:
+        version: [None, "10.6", "10.7", "10.8", "10.9", "10.10", "10.11", "10.12", "10.13", "10.14", "10.15", "11.0", "12.0", "13.0"]
+        sdk: [None, "macosx"]
+        sdk_version: [None, "10.13", "10.14", "10.15", "11.0", "11.1", "11.3", "12.0", "12.1", "12.3", "13.0"]
+        subsystem:
+            None:
+            catalyst:
+                ios_version: *ios_version
+    Android:
+        api_level: ANY
+    FreeBSD:
+    SunOS:
+    AIX:
+    Arduino:
+        board: ANY
+    Emscripten:
+    Neutrino:
+        version: ["6.4", "6.5", "6.6", "7.0", "7.1"]
+    baremetal:
+    VxWorks:
+        version: ["7"]
+arch: [x86, x86_64, ppc32be, ppc32, ppc64le, ppc64, armv4, armv4i, armv5el, armv5hf, armv6, armv7, armv7hf, armv7s, armv7k, armv8, armv8_32, armv8.3, sparc, sparcv9, mips, mips64, avr, s390, s390x, asm.js, wasm, sh4le, e2k-v2, e2k-v3, e2k-v4, e2k-v5, e2k-v6, e2k-v7, xtensalx6, xtensalx106, xtensalx7]
+compiler:
+    sun-cc:
+        version: ["5.10", "5.11", "5.12", "5.13", "5.14", "5.15"]
+        threads: [None, posix]
+        libcxx: [libCstd, libstdcxx, libstlport, libstdc++]
+    gcc: &gcc
+        version: ["4.1", "4.4", "4.5", "4.6", "4.7", "4.8", "4.9",
+                  "5", "5.1", "5.2", "5.3", "5.4", "5.5",
+                  "6", "6.1", "6.2", "6.3", "6.4", "6.5",
+                  "7", "7.1", "7.2", "7.3", "7.4", "7.5",
+                  "8", "8.1", "8.2", "8.3", "8.4", "8.5",
+                  "9", "9.1", "9.2", "9.3", "9.4", "9.5",
+                  "10", "10.1", "10.2", "10.3", "10.4",
+                  "11", "11.1", "11.2", "11.3",
+                  "12", "12.1", "12.2"]
+        libcxx: [libstdc++, libstdc++11]
+        threads: [None, posix, win32]  # Windows MinGW
+        exception: [None, dwarf2, sjlj, seh]  # Windows MinGW
+        cppstd: [None, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17, 20, gnu20, 23, gnu23]
+    Visual Studio: &visual_studio
+        runtime: [MD, MT, MTd, MDd]
+        version: ["8", "9", "10", "11", "12", "14", "15", "16", "17"]
+        toolset: [None, v90, v100, v110, v110_xp, v120, v120_xp,
+                  v140, v140_xp, v140_clang_c2, LLVM-vs2012, LLVM-vs2012_xp,
+                  LLVM-vs2013, LLVM-vs2013_xp, LLVM-vs2014, LLVM-vs2014_xp,
+                  LLVM-vs2017, LLVM-vs2017_xp, v141, v141_xp, v141_clang_c2, v142,
+                  llvm, ClangCL, v143]
+        cppstd: [None, 14, 17, 20, 23]
+    msvc:
+        version: [170, 180, 190, 191, 192, 193]
+        update: [None, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+        runtime: [static, dynamic]
+        runtime_type: [Debug, Release]
+        cppstd: [98, 14, 17, 20, 23]
+        toolset: [None, v110_xp, v120_xp, v140_xp, v141_xp]
+    clang:
+        version: ["3.3", "3.4", "3.5", "3.6", "3.7", "3.8", "3.9", "4.0",
+                  "5.0", "6.0", "7.0", "7.1",
+                  "8", "9", "10", "11", "12", "13", "14", "15", "16"]
+        libcxx: [None, libstdc++, libstdc++11, libc++, c++_shared, c++_static]
+        cppstd: [None, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17, 20, gnu20, 23, gnu23]
+        runtime: [None, MD, MT, MTd, MDd, static, dynamic]
+        runtime_type: [None, Debug, Release]
+        runtime_version: [None, v140, v141, v142, v143]
+    apple-clang: &apple_clang
+        version: ["5.0", "5.1", "6.0", "6.1", "7.0", "7.3", "8.0", "8.1", "9.0", "9.1", "10.0", "11.0", "12.0", "13", "13.0", "13.1", "14", "14.0"]
+        libcxx: [libstdc++, libc++]
+        cppstd: [None, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17, 20, gnu20, 23, gnu23]
+    intel:
+        version: ["11", "12", "13", "14", "15", "16", "17", "18", "19", "19.1"]
+        update: [None, ANY]
+        base:
+            gcc:
+                <<: *gcc
+                threads: [None]
+                exception: [None]
+            Visual Studio:
+                <<: *visual_studio
+            apple-clang:
+                <<: *apple_clang
+    intel-cc:
+        version: ["2021.1", "2021.2", "2021.3"]
+        update: [None, ANY]
+        mode: ["icx", "classic", "dpcpp"]
+        libcxx: [None, libstdc++, libstdc++11, libc++]
+        cppstd: [None, 98, gnu98, 03, gnu03, 11, gnu11, 14, gnu14, 17, gnu17, 20, gnu20, 23, gnu23]
+        runtime: [None, static, dynamic]
+        runtime_type: [None, Debug, Release]
+    qcc:
+        version: ["4.4", "5.4", "8.3"]
+        libcxx: [cxx, gpp, cpp, cpp-ne, accp, acpp-ne, ecpp, ecpp-ne]
+        cppstd: [None, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17]
+    mcst-lcc:
+        version: ["1.19", "1.20", "1.21", "1.22", "1.23", "1.24", "1.25"]
+        base:
+            gcc:
+                <<: *gcc
+                threads: [None]
+                exceptions: [None]
+
+build_type: [None, Debug, Release, RelWithDebInfo, MinSizeRel]
+
+
+cppstd: [None, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17, 20, gnu20, 23, gnu23]  # Deprecated, use compiler.cppstd
+"""
diff --git a/conans/model/build_info.py b/conans/model/build_info.py
index e27d432d5..94c0a6f61 100644
--- a/conans/model/build_info.py
+++ b/conans/model/build_info.py
@@ -400,14 +400,6 @@ class CppInfo(_CppInfo):
 
         def _check_components_requires_instersection(comp_requires):
             reqs = [it.split(COMPONENT_SCOPE)[0] for it in comp_requires if COMPONENT_SCOPE in it]
-            # Raise on components requires without package requires
-            for pkg_require in pkg_requires:
-                if package_requires[pkg_require].private or package_requires[pkg_require].override:
-                    # Not standard requires, skip
-                    continue
-                if pkg_require not in reqs:
-                    raise ConanException("Package require '%s' not used in components requires"
-                                         % pkg_require)
             # Raise on components requires requiring inexistent package requires
             for comp_require in reqs:
                 reason = None


Test patch:
diff --git a/conans/test/functional/generators/components/propagate_specific_components_test.py b/conans/test/functional/generators/components/propagate_specific_components_test.py
index a1ac6e7a5..b4270ee04 100644
--- a/conans/test/functional/generators/components/propagate_specific_components_test.py
+++ b/conans/test/functional/generators/components/propagate_specific_components_test.py
@@ -1,8 +1,6 @@
 import textwrap
 import unittest
 
-import pytest
-
 from conans.test.utils.tools import TestClient
 
 
@@ -133,25 +131,6 @@ class WrongComponentsTestCase(unittest.TestCase):
             self.assertIn("ERROR: Component 'top::not-existing' not found in 'top'"
                           " package requirement", t.out)
 
-    def test_unused_requirement(self):
-        """ Requires should include all listed requirements
-            This error is known when creating the package if the requirement is consumed.
-        """
-        consumer = textwrap.dedent("""
-            from conans import ConanFile
-
-            class Recipe(ConanFile):
-                requires = "top/version"
-                def package_info(self):
-                    self.cpp_info.requires = ["other::other"]
-        """)
-        t = TestClient()
-        t.save({'top.py': self.top, 'consumer.py': consumer})
-        t.run('create top.py top/version@')
-        t.run('create consumer.py wrong/version@', assert_error=True)
-        self.assertIn("wrong/version package_info(): Package require 'top' not used"
-                      " in components requires", t.out)
-
     def test_wrong_requirement(self):
         """ If we require a wrong requirement, we get a meaninful error.
             This error is known when creating the package if the requirement is not there.
diff --git a/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps.py b/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps.py
index c1ceb5d3a..370b371a5 100644
--- a/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps.py
+++ b/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps.py
@@ -657,3 +657,42 @@ def test_map_imported_config():
     assert "hello/1.0: Hello World Release!" in client.out
     assert "talk: Release!" in client.out
     assert "main: Debug!" in client.out
+
+
+@pytest.mark.tool_cmake
+def test_quiet():
+    conanfile = textwrap.dedent("""
+        from conan import ConanFile
+
+        class Test(ConanFile):
+            name = "test"
+            version = "0.1"
+
+            def package_info(self):
+                self.cpp_info.system_libs = ["lib1"]
+        """)
+    client = TestClient()
+    client.save({"conanfile.py": conanfile})
+    client.run("create .")
+
+    conanfile = textwrap.dedent("""
+        [requires]
+        test/0.1
+
+        [generators]
+        CMakeDeps
+        """)
+    cmakelists = textwrap.dedent("""
+        cmake_minimum_required(VERSION 3.15)
+        project(consumer NONE)
+        set(CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR})
+        set(CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR})
+        find_package(test QUIET)
+        """)
+
+    client.save({"conanfile.txt": conanfile,
+                 "CMakeLists.txt": cmakelists}, clean_first=True)
+    client.run("install .")
+    client.run_command('cmake . -DCMAKE_BUILD_TYPE=Release')
+    # Because we used QUIET, not in output
+    assert "Target declared 'test::test'" not in client.out
diff --git a/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_components.py b/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_components.py
index 44b0565f5..a94d0977c 100644
--- a/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_components.py
+++ b/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_components.py
@@ -116,26 +116,6 @@ def test_wrong_component(top_conanfile, from_component):
     assert "Component 'top::not-existing' not found in 'top' package requirement" in t.out
 
 
-def test_unused_requirement(top_conanfile):
-    """ Requires should include all listed requirements
-        This error is known when creating the package if the requirement is consumed.
-    """
-    consumer = textwrap.dedent("""
-        from conans import ConanFile
-
-        class Recipe(ConanFile):
-            requires = "top/version"
-            def package_info(self):
-                self.cpp_info.requires = ["other::other"]
-    """)
-    t = TestClient()
-    t.save({'top.py': top_conanfile, 'consumer.py': consumer})
-    t.run('create top.py top/version@')
-    t.run('create consumer.py wrong/version@', assert_error=True)
-    assert "wrong/version package_info(): Package require 'top' not used in components " \
-           "requires" in t.out
-
-
 def test_wrong_requirement(top_conanfile):
     """ If we require a wrong requirement, we get a meaninful error.
         This error is known when creating the package if the requirement is not there.
diff --git a/conans/test/integration/generators/package_info/package_info_test.py b/conans/test/integration/generators/package_info/package_info_test.py
index 3b4df5c2d..20e2bdcde 100644
--- a/conans/test/integration/generators/package_info/package_info_test.py
+++ b/conans/test/integration/generators/package_info/package_info_test.py
@@ -391,59 +391,6 @@ class HelloConan(ConanFile):
         client.run("create conanfile1.py")
         client.run("create conanfile2.py")
 
-        conanfile = GenConanfile("consumer", "0.1") \
-            .with_requirement("dep1/0.1") \
-            .with_requirement("dep2/0.1") \
-            .with_package_info(cpp_info={"components": {"kk": {"requires": []}}},
-                               env_info={})
-        client.save({"conanfile.py": conanfile})
-        client.run("create conanfile.py", assert_error=True)
-        self.assertIn("consumer/0.1 package_info(): Package require 'dep1' not used in "
-                      "components requires", client.out)
-
-        conanfile = GenConanfile("consumer", "0.1") \
-            .with_requirement("dep1/0.1") \
-            .with_requirement("dep2/0.1") \
-            .with_package_info(cpp_info={"components": {"kk": {"requires": ["dep1::dep1"]}}},
-                               env_info={})
-        client.save({"conanfile.py": conanfile})
-        client.run("create conanfile.py", assert_error=True)
-        self.assertIn("consumer/0.1 package_info(): Package require 'dep2' not used in components "
-                      "requires", client.out)
-
-        conanfile = GenConanfile("consumer", "0.1") \
-            .with_requirement("dep1/0.1") \
-            .with_requirement("dep2/0.1") \
-            .with_package_info(cpp_info={"components": {"kk": {"requires": ["dep1::dep1"]},
-                                                        "kkk": {"requires": ["kk"]}}},
-                               env_info={})
-        client.save({"conanfile.py": conanfile})
-        client.run("create conanfile.py", assert_error=True)
-        self.assertIn("consumer/0.1 package_info(): Package require 'dep2' not used in components "
-                      "requires", client.out)
-
-        conanfile = GenConanfile("consumer", "0.1") \
-            .with_requirement("dep1/0.1") \
-            .with_requirement("dep2/0.1") \
-            .with_package_info(cpp_info={"components": {"kk": {"requires": []},
-                                                        "kkk": {"requires": ["kk"]}}},
-                               env_info={})
-        client.save({"conanfile.py": conanfile})
-        client.run("create conanfile.py", assert_error=True)
-        self.assertIn("consumer/0.1 package_info(): Package require 'dep1' not used in components "
-                      "requires", client.out)
-
-        conanfile = GenConanfile("consumer", "0.1") \
-            .with_requirement("dep1/0.1") \
-            .with_requirement("dep2/0.1") \
-            .with_package_info(cpp_info={"components": {"kk": {"requires": ["dep2::comp"]},
-                                                        "kkk": {"requires": ["dep3::dep3"]}}},
-                               env_info={})
-        client.save({"conanfile.py": conanfile})
-        client.run("create conanfile.py", assert_error=True)
-        self.assertIn("consumer/0.1 package_info(): Package require 'dep1' not used in components "
-                      "requires", client.out)
-
         conanfile = GenConanfile("consumer", "0.1") \
             .with_requirement("dep2/0.1") \
             .with_package_info(cpp_info={"components": {"kk": {"requires": ["dep2::comp"]},
diff --git a/conans/test/integration/test_components.py b/conans/test/integration/test_components.py
index 202dae8d3..822f936e5 100644
--- a/conans/test/integration/test_components.py
+++ b/conans/test/integration/test_components.py
@@ -1,5 +1,6 @@
 import textwrap
 
+from conans.test.assets.genconanfile import GenConanfile
 from conans.test.utils.tools import TestClient
 
 
@@ -23,3 +24,27 @@ def test_components_cycles():
     assert "a requires c"
     assert "b requires a"
     assert "c rquires b"
+
+
+def test_components_not_required():
+    """
+    Allow requiring and building against one component, but not propagating it
+    https://github.com/conan-io/conan/issues/12965
+    """
+    c = TestClient()
+    conanfile = textwrap.dedent("""
+        from conan import ConanFile
+
+        class TestcycleConan(ConanFile):
+            name = "wayland"
+            version = "1.0"
+            requires = "expat/1.0"
+
+            def package_info(self):
+                self.cpp_info.components["wayland-scanner"].libdirs = []
+        """)
+    c.save({"expat/conanfile.py": GenConanfile("expat", "1.0"),
+            "wayland/conanfile.py": conanfile})
+    c.run("create expat")
+    c.run("create wayland")
+    assert "wayland/1.0: Created package" in c.out