View Issue Details [ Jump to Notes ] | [ Print ] | ||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | ||||
0016089 | CMake | CMake | public | 2016-05-02 12:37 | 2016-06-10 14:31 | ||||
Reporter | LCID Fire | ||||||||
Assigned To | Kitware Robot | ||||||||
Priority | normal | Severity | major | Reproducibility | always | ||||
Status | closed | Resolution | moved | ||||||
Platform | PC | OS | Windows | OS Version | 7 | ||||
Product Version | CMake 3.5.2 | ||||||||
Target Version | Fixed in Version | ||||||||
Summary | 0016089: Overriding subdir options no longer works | ||||||||
Description | Setting options for subdirectory no longer seems to work. | ||||||||
Steps To Reproduce | # CMakeLists.txt content set( myoption ON ) add_subdirectory( test ) # test/CMakeLists.txt content option( myoption "A test" OFF ) message( "TEST_VALUE ${myoption}" ) | ||||||||
Additional Information | Output is: TEST_VALUE OFF | ||||||||
Tags | No tags attached. | ||||||||
Attached Files | |||||||||
Relationships | |
Relationships |
Notes | |
(0041014) LCID Fire (reporter) 2016-05-03 05:35 |
We see this in on multiple OSes and back even with 3.4. There seems to be some combination where overriding options does not work reliably. |
(0041017) Brad King (manager) 2016-05-03 08:14 |
Check the value on both the first run of CMake in a new tree and again on a second run when the cache is already populated. There is an unfortunate combination of behaviors that causes the cache entry to override the variable on the first run but not later runs. This is documented for the set() command with the CACHE option: https://cmake.org/cmake/help/v3.5/command/set.html [^] "If the cache entry does not exist prior to the call or the FORCE option is given then the cache entry will be set to the given value. Furthermore, any normal variable binding in the current scope will be removed to expose the newly cached value to any immediately following evaluation." Of course on the second run the cache entry already exists and so no removal of the normal variable is triggered. In general the safest way to override a cache entry is by setting it as a cache entry. Often when I import a third-party project into a subdirectory and want to set one of its cache options instead of exposing it to the user I'll do something like this: set( myoption ON CACHE INTERNAL "override subdir value") |
(0041020) LCID Fire (reporter) 2016-05-03 09:11 |
Thanks. That indeed works. Scary however when I think how often we have done the old method across projects. Would be really great if there was an option to have CMake complain when there is a non CACHE variable used. |
(0042994) 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 |
2016-05-02 12:37 | LCID Fire | New Issue | |
2016-05-03 05:35 | LCID Fire | Note Added: 0041014 | |
2016-05-03 08:14 | Brad King | Note Added: 0041017 | |
2016-05-03 09:11 | LCID Fire | Note Added: 0041020 | |
2016-06-10 14:29 | Kitware Robot | Note Added: 0042994 | |
2016-06-10 14:29 | Kitware Robot | Status | new => resolved |
2016-06-10 14:29 | Kitware Robot | Resolution | open => moved |
2016-06-10 14:29 | Kitware Robot | Assigned To | => Kitware Robot |
2016-06-10 14:31 | Kitware Robot | Status | resolved => closed |
Issue History |
Copyright © 2000 - 2018 MantisBT Team |