<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">Le jeu. 30 août 2018 à 18:01, George PF <<a href="mailto:george.p.f@mail.com">george.p.f@mail.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
once COMPONENTS is added to a find_package statement, any REQUIRED statement ceases to have an effect:<br>
<br>
    cmake_minimum_required(VERSION 3.12)<br>
<br>
    # find_package(FailsCorrectly REQUIRED)<br>
<br>
    find_package(Qt REQUIRED COMPONENTS REQUIRED Qt5XYZ REQUIRED)<br>
    find_package(Qt REQUIRED COMPONENTS          Qt5XYZ         )<br>
    find_package(Qt          COMPONENTS REQUIRED Qt5XYZ         )<br>
    find_package(Qt          COMPONENTS          Qt5XYZ REQUIRED)<br>
    find_package(Qt          COMPONENTS REQUIRED Qt5XYZ REQUIRED)<br>
    find_package(Qt REQUIRED COMPONENTS          Qt5XYZ REQUIRED)<br>
    find_package(Qt REQUIRED COMPONENTS REQUIRED Qt5XYZ         )<br>
<br>
<br>
This CMakeLists.txt runs, despite Qt5XYZ not existing. How can this be made to fail as it should, why <br>
else would there be OPTIONAL_COMPONENTS as well?<br></blockquote><div><br></div><div>The documentation is intriguing about REQUIRED COMPONENTS interaction....</div><div><br></div><div>"A package-specific list of required components may be listed after the</div><div>``COMPONENTS`` option (or after the ``REQUIRED`` option if present).</div><div>Additional optional components may be listed after</div><div>``OPTIONAL_COMPONENTS``."</div><div><br></div><div>and....</div><div><br></div><div>"Available components and their influence on</div><div>whether a package is considered to be found are defined by the target</div><div>package."</div><div><br></div><div>and later on:</div><div><br></div><div>"In Config mode ``find_package`` handles ``REQUIRED``, ``QUIET``, and</div><div>``[version]`` options automatically but leaves it to the package</div><div>configuration file to handle components in a way that makes sense</div><div>for the package.  The package configuration file may set</div><div>``<package>_FOUND`` to false to tell ``find_package`` that component</div><div>requirements are not satisfied."</div><div><br></div><div>So it is possible that the failure behavior when specifying COMPONENTS is up to the module...</div><div><br></div><div>Do you see this only with Qt or do other packages with components (may be Boost) behave like this?</div><div>I guess that Qt5 should be running in config mode, whereas boost must be in module mode though. <br></div><div><br></div><div>By the way for Qt5 the doc says you shouldn't be using find_package(Qt):</div><div><a href="https://cmake.org/cmake/help/latest/module/FindQt.html">https://cmake.org/cmake/help/latest/module/FindQt.html</a><br></div><div><br></div><div>But probably directly:</div><div>find_package(Qt5)</div><div><br></div><div>see example here: <a href="https://blog.kitware.com/cmake-finding-qt5-the-right-way/">https://blog.kitware.com/cmake-finding-qt5-the-right-way/</a></div></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Eric<br></div></div></div></div></div></div>