View Issue Details [ Jump to Notes ] | [ Print ] | ||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | ||||
0015231 | CMake | CMake | public | 2014-10-31 12:31 | 2016-06-10 14:31 | ||||
Reporter | Charles Karney | ||||||||
Assigned To | Tamas Kenez | ||||||||
Priority | normal | Severity | feature | Reproducibility | N/A | ||||
Status | closed | Resolution | moved | ||||||
Platform | OS | OS Version | |||||||
Product Version | CMake 3.0.2 | ||||||||
Target Version | Fixed in Version | ||||||||
Summary | 0015231: find_package: should be a simple way to alter the order of the config/module lookups | ||||||||
Description | As we are integrating cmake more and more into our environment, it is clear how much superior the config-mode for find_package is compared to the module-mode. As a result, our top-level CMakeLists.txt contains several occurrences of the following pattern find_package (PROJ4 CONFIG QUIET) if (NOT PROJ4_FOUND) find_package (PROJ4 MODULE REQUIRED) endif () Request 1: Add MODULE_FIRST CONFIG_FIRST options to find_package, meaning do the module lookup first (the default but see next) or the config lookup first. (These options complement the MODULE and CONFIG options.) So the find_package invocation above becomes find_package (PROJ4 CONFIG_FIRST REQUIRED) Request 2: Add a global variable, e.g., CMAKE_FIND_PACKAGE_PREFER_CONFIG (default OFF) to specify the default lookup order. Thus if I've worked to get all my dependent packages with config-mode support, I can invoke cmake with cmake -DCMAKE_FIND_PACKAGE_PREFER_CONFIG=ON .. without having to edit the CMakeLists.txt file. Finally a comment: the advice (not sure where from) that our current pattern can be shortened to find_package (PROJ4 NO_MODULE QUIET) find_package (PROJ4 MODULE) seems not to hold in all cases. If you think this should work, let me know and I will look for a counter-example. | ||||||||
Tags | No tags attached. | ||||||||
Attached Files | |||||||||
Relationships | |
Relationships |
Notes | |
(0037122) Brad King (manager) 2014-10-31 12:50 |
There is no "order" in a single call to find_package(). If the mode is not explicitly specified then it uses module mode if and only if there is a Find module in the CMAKE_MODULE_PATH or builtin to CMake. It will always take two calls to try both modes. The order of the calls is up to the project. A common way to achieve config-then-module is to have the second call at the top of the Find<pkg>.cmake module. The find_package command documents how it forwards component and version arguments automatically. This way the application code still only has one find_package call. I don't think find_package (PROJ4 NO_MODULE QUIET) find_package (PROJ4 MODULE) is clean because the Find module will be loaded by the second call regardless of whether the first call succeeds. The "if (NOT PROJ4_FOUND)" condition is needed. |
(0037123) Charles Karney (reporter) 2014-10-31 13:13 |
Yes, I'm aware of the trick of FindXXX.cmake doing a config lookup first (from FindBoost.cmake). However our problem is that we have our own builds of standard libraries like JPEG and ZLIB which we want found via the config lookup. We don't want to be modifying the system FindXXX modules and providing overriding FindXXX modules seems to be heavy handed. |
(0037124) Brad King (manager) 2014-10-31 13:30 |
FWIW here are some approaches you could use for now with existing CMake releases: - Provide your own FindXXX modules that do the NO_MODULE call and then include() the upstream module if config mode did not find anything. - Use a my_find_package macro that contains two calls to find_package internally. Functionality like the request 1 and request 2 in the description is a reasonable proposal for future behavior. However, it would be better discussed on the developer's list: http://www.cmake.org/mailman/listinfo/cmake-developers [^] with a broader audience. I think the main challenge will be how to format error messages when neither mode finds anything for a REQUIRED package. It took years to get the current messages to a state that minimizes confusion among users that do not understand the two modes. |
(0038536) Brad King (manager) 2015-04-16 16:10 |
A relevant mailing list thread: [CMake 0015231]: find_package: should be a simple way to alter the order of the config/module lookups http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/12975 [^] |
(0042656) Kitware Robot (administrator) 2016-06-10 14:29 |
Resolving issue as `moved`. This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page. |
Notes |
Issue History | |||
Date Modified | Username | Field | Change |
2014-10-31 12:31 | Charles Karney | New Issue | |
2014-10-31 12:50 | Brad King | Note Added: 0037122 | |
2014-10-31 13:13 | Charles Karney | Note Added: 0037123 | |
2014-10-31 13:30 | Brad King | Note Added: 0037124 | |
2015-04-16 16:10 | Brad King | Note Added: 0038536 | |
2015-04-20 10:09 | Brad King | Assigned To | => Tamas Kenez |
2015-04-20 10:09 | Brad King | Status | new => assigned |
2016-06-10 14:29 | Kitware Robot | Note Added: 0042656 | |
2016-06-10 14:29 | Kitware Robot | Status | assigned => resolved |
2016-06-10 14:29 | Kitware Robot | Resolution | open => moved |
2016-06-10 14:31 | Kitware Robot | Status | resolved => closed |
Issue History |
Copyright © 2000 - 2018 MantisBT Team |