find_package with COMPONENTS never honors REQUIRED

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

find_package with COMPONENTS never honors REQUIRED

George PF
Hi,

once COMPONENTS is added to a find_package statement, any REQUIRED statement ceases to have an effect:

    cmake_minimum_required(VERSION 3.12)

    # find_package(FailsCorrectly REQUIRED)
   
    find_package(Qt REQUIRED COMPONENTS REQUIRED Qt5XYZ REQUIRED)
    find_package(Qt REQUIRED COMPONENTS          Qt5XYZ         )
    find_package(Qt          COMPONENTS REQUIRED Qt5XYZ         )
    find_package(Qt          COMPONENTS          Qt5XYZ REQUIRED)
    find_package(Qt          COMPONENTS REQUIRED Qt5XYZ REQUIRED)
    find_package(Qt REQUIRED COMPONENTS          Qt5XYZ REQUIRED)
    find_package(Qt REQUIRED COMPONENTS REQUIRED Qt5XYZ         )
   

This CMakeLists.txt runs, despite Qt5XYZ not existing. How can this be made to fail as it should, why
else would there be OPTIONAL_COMPONENTS as well?

Regards

GPF
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: find_package with COMPONENTS never honors REQUIRED

Eric Noulard


Le jeu. 30 août 2018 à 18:01, George PF <[hidden email]> a écrit :
Hi,

once COMPONENTS is added to a find_package statement, any REQUIRED statement ceases to have an effect:

    cmake_minimum_required(VERSION 3.12)

    # find_package(FailsCorrectly REQUIRED)

    find_package(Qt REQUIRED COMPONENTS REQUIRED Qt5XYZ REQUIRED)
    find_package(Qt REQUIRED COMPONENTS          Qt5XYZ         )
    find_package(Qt          COMPONENTS REQUIRED Qt5XYZ         )
    find_package(Qt          COMPONENTS          Qt5XYZ REQUIRED)
    find_package(Qt          COMPONENTS REQUIRED Qt5XYZ REQUIRED)
    find_package(Qt REQUIRED COMPONENTS          Qt5XYZ REQUIRED)
    find_package(Qt REQUIRED COMPONENTS REQUIRED Qt5XYZ         )


This CMakeLists.txt runs, despite Qt5XYZ not existing. How can this be made to fail as it should, why
else would there be OPTIONAL_COMPONENTS as well?

The documentation is intriguing about REQUIRED COMPONENTS interaction....

"A package-specific list of required components may be listed after the
``COMPONENTS`` option (or after the ``REQUIRED`` option if present).
Additional optional components may be listed after
``OPTIONAL_COMPONENTS``."

and....

"Available components and their influence on
whether a package is considered to be found are defined by the target
package."

and later on:

"In Config mode ``find_package`` handles ``REQUIRED``, ``QUIET``, and
``[version]`` options automatically but leaves it to the package
configuration file to handle components in a way that makes sense
for the package.  The package configuration file may set
``<package>_FOUND`` to false to tell ``find_package`` that component
requirements are not satisfied."

So it is possible that the failure behavior when specifying COMPONENTS is up to the module...

Do you see this only with Qt or do other packages with components (may be Boost) behave like this?
I guess that Qt5 should be running in config mode, whereas boost must be in module mode though. 

By the way for Qt5 the doc says you shouldn't be using find_package(Qt):

But probably directly:
find_package(Qt5)

--
Eric

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: find_package with COMPONENTS never honors REQUIRED

George PF
> The documentation is intriguing about REQUIRED COMPONENTS interaction....

That's... one way to put it.
 

> "A package-specific list of required components may be listed after the
> ``COMPONENTS`` option (or after the ``REQUIRED`` option if present).
> Additional optional components may be listed after
> ``OPTIONAL_COMPONENTS``."
>  
> and....
>  
> "Available components and their influence on
> whether a package is considered to be found are defined by the target
> package."
>  
> and later on:
>  
> "In Config mode ``find_package`` handles ``REQUIRED``, ``QUIET``, and
> ``[version]`` options automatically but leaves it to the package
> configuration file to handle components in a way that makes sense
> for the package.  The package configuration file may set
> ``<package>_FOUND`` to false to tell ``find_package`` that component
> requirements are not satisfied."
>  
> So it is possible that the failure behavior when specifying COMPONENTS is up to the module...

I admit I was not reading the docs in that depth, but REQUIRED can only mean one thing and should
not need second guessing the documentation. Sadly, someone thought otherwise.

> Do you see this only with Qt or do other packages with components (may be Boost) behave like this?
> I guess that Qt5 should be running in config mode, whereas boost must be in module mode though.

I was debugging an older cmake project and wondered why it was not finding the non-standard Qt location,
that's when I stumbled upon this issue.

GPF
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: find_package with COMPONENTS never honors REQUIRED

Eric Noulard


Le jeu. 30 août 2018 à 20:03, George PF <[hidden email]> a écrit :
> The documentation is intriguing about REQUIRED COMPONENTS interaction....

That's... one way to put it.

Yeah you know. Kind of ironic here :-)
   
> So it is possible that the failure behavior when specifying COMPONENTS is up to the module...

I admit I was not reading the docs in that depth, but REQUIRED can only mean one thing and should
not need second guessing the documentation. Sadly, someone thought otherwise.

I guess there is no one to blame here.
The doc is too-realistic about the state of find modules.
At least Config mode should do it right I hope.
Module mode is historically for hand-written module maintained by volunteers: https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/dev/Module-Maintainers

> Do you see this only with Qt or do other packages with components (may be Boost) behave like this?
> I guess that Qt5 should be running in config mode, whereas boost must be in module mode though.

I was debugging an older cmake project and wondered why it was not finding the non-standard Qt location,
that's when I stumbled upon this issue.

I see. I think something could/should be done for Config mode, for Module mode It would certainly depends on the module maintainer.
 
--
Eric

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake