| View Issue Details [ Jump to Notes ] | [ Print ] | ||||||||
| ID | Project | Category | View Status | Date Submitted | Last Update | ||||
| 0008192 | CMake | CMake | public | 2008-11-28 11:06 | 2009-02-24 15:15 | ||||
| Reporter | Thorsten Köster | ||||||||
| Assigned To | Brad King | ||||||||
| Priority | normal | Severity | feature | Reproducibility | always | ||||
| Status | closed | Resolution | fixed | ||||||
| Platform | OS | OS Version | |||||||
| Product Version | CMake-2-6 | ||||||||
| Target Version | Fixed in Version | ||||||||
| Summary | 0008192: Included scripts should be protected by policy push/pop | ||||||||
| Description | Linking to libraries with hard-coded paths and non-standard extensions leads to what seems to be the "OLD" behaviour in CMake-2.6.2, i.e. the paths are removed and the standard extension is added. | ||||||||
| Additional Information | CMAKE_POLICY(GET CMP0008 somevar) results in an empty somevar. Original summary: Policy CMP0008 is not honoured in CMake-2.6.2 Summary was changed after true problem was discovered. | ||||||||
| Tags | No tags attached. | ||||||||
| Attached Files | |||||||||
| Relationships | |
| Relationships |
| Notes | |
|
(0014225) Bill Hoffman (manager) 2008-11-28 11:29 |
Can you provide an example of this? |
|
(0014259) Thorsten Köster (reporter) 2008-12-01 03:32 |
I just uploaded a CMakeLists.txt and an IncludeFile.cmake that reproduce what I noticed on Friday. I'm sorry for causing trouble, since the problem was clearly on my side: The includ*ed* file re-sets the CMAKE_MINIMUM_REQUIRED to version 2.6, while the includ*ing* file still expects this to be 2.6.2. I only noticed that when I was boiling down my CMake files to a minimum test case I could submit today. Can we change this bug entry to a feature request for pushing and popping policies when including files, if that makes sense? |
|
(0014353) Brad King (manager) 2008-12-15 15:54 |
We cannot automatically push/pop on include() because some people create policy-setting files to be included. You can protect yourself though: cmake_policy(PUSH) include(...) cmake_policy(POP) |
|
(0014578) Brad King (manager) 2009-01-15 16:37 |
I'm re-opening this issue since I've come up with a solution to it. Details to follow later. |
|
(0014662) Brad King (manager) 2009-01-22 13:40 edited on: 2009-01-22 13:45 |
There are two types of included files: (1) Those included from inside the project's source tree (2) Those included from an outside third-party project installation Files of type (1) usually don't change policies and just use the policies of the main project. For these it doesn't matter whether policies are protected by a push/pop or not. It is possible that the purpose of a file is to set policies for its including context, but that is a special case. Files of type (2) should use cmake_minimum_required to enforce a version. Usually the including project just wants the file to do what it documents and doesn't care that it may have been written for a different version of CMake. For these files the including project should be protected by a push/pop. There is also a special case utilized by KDE4 in which application authors can write # No cmake_minimum_required!! project(mykde4app) find_package(KDE4) # Has cmake_minimum_required and sets some policies The file included by the find_package command sets CMP0000 to OLD to quiet the warning that the top file should have cmake_minimum_required. Any change we make needs to preserve this "development framework" use case. We've concluded that in the common case include() and find_package() should protect their calling contexts from the included file by automatically implying a cmake_policy(PUSH) and cmake_policy(POP) around the loaded files. I've committed changes that make the commands do this by default but provide a NO_POLICY_SCOPE option to disable it. I've introduced policy CMP0011 for compatibility. It's OLD behavior is to imply NO_POLICY_SCOPE and its NEW behavior is to not imply the option. This supports the KDE4 use case because the find_package(KDE4) line occurs before CMP0011 has been set, so it uses the OLD behavior (and if the included file sets CMP0011 then there is no warning). The changes also make functions and macros record policies set when they are created and use them when they are invoked. This is important so that functions provided by a third-party script run with the policies they expect. |
|
(0014663) Brad King (manager) 2009-01-22 13:44 |
The following series of commits implement the new bheavior. Author: Brad King <brad.king@kitware.com> Date: Thu Jan 22 15:56:39 2009 +0000 ENH: Refactor policy stack representation This defines PolicyMap as a public member of cmPolicies. Its previous role as a policy stack entry is now called PolicyStackEntry and represented as a class to which more information can be added later. Source/cmMakefile.cxx | 7 +++---- Source/cmMakefile.h | 12 +++++++++--- Source/cmPolicies.h | 4 ++++ 3 files changed, 16 insertions(+), 7 deletions(-) Author: Brad King <brad.king@kitware.com> Date: Thu Jan 22 15:56:50 2009 +0000 ENH: Create automatic policy push/pop helper This creates cmMakefile::PolicyPushPop to push and pop policy scope automatically. It also enforces balanced push/pop pairs inside the scope it handles. Source/cmMakefile.cxx | 29 +++++++++++++++++++++++++++++ Source/cmMakefile.h | 12 ++++++++++++ 2 files changed, 41 insertions(+), 0 deletions(-) Author: Brad King <brad.king@kitware.com> Date: Thu Jan 22 15:56:58 2009 +0000 ENH: Refactor find_package version file scoping This converts the variable and policy scope protection find_package() uses when loading version files to use automatic variables. Source/cmFindPackageCommand.cxx | 10 ++++------ 1 files changed, 4 insertions(+), 6 deletions(-) Author: Brad King <brad.king@kitware.com> Date: Thu Jan 22 15:57:09 2009 +0000 ENH: Make policy push/pop methods private This makes cmMakefile::PushPolicy and cmMakefile::PopPolicy private so that any outside place that uses them needs to use the PolicyPushPop helper in an automatic variable. We grant an exception to cmCMakePolicyCommand so it can implement cmake_policy(PUSH) and cmake_policy(POP). Source/cmMakefile.h | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-) Author: Brad King <brad.king@kitware.com> Date: Thu Jan 22 15:57:16 2009 +0000 ENH: Create policy scope barriers This creates a barrier mechanism to prevent user code from using cmake_policy(POP) to pop a scope it didn't push with cmake_policy(PUSH). Source/cmCMakePolicyCommand.cxx | 14 ++---- Source/cmMakefile.cxx | 110 ++++++++++++++++++++++++-------------- Source/cmMakefile.h | 12 +++- 3 files changed, 82 insertions(+), 54 deletions(-) Author: Brad King <brad.king@kitware.com> Date: Thu Jan 22 18:16:27 2009 +0000 ENH: Create notion of a 'weak' policy stack entry A 'weak' poilcy stack entry responds normally to queries. However, setting a policy in a weak entry will recursively set the policy in the next entry too. This also gives the internal interface to create a weak entry the option to provide an initial PolicyMap for it. Source/cmMakefile.cxx | 19 +++++++++++++------ Source/cmMakefile.h | 14 +++++++++----- 2 files changed, 22 insertions(+), 11 deletions(-) Author: Brad King <brad.king@kitware.com> Date: Thu Jan 22 18:16:33 2009 +0000 ENH: Improve stack discussion in cmake_policy This re-organizes the discussion of the policy stack in documentation of the cmake_policy() command. The new organization clearer and easier to extend with new information. Source/cmCMakePolicyCommand.h | 17 +++++++++-------- 1 files changed, 9 insertions(+), 8 deletions(-) Author: Brad King <brad.king@kitware.com> Date: Thu Jan 22 18:16:47 2009 +0000 ENH: Better policies for functions and macros This teaches functions and macros to use policies recorded at creation time when they are invoked. It restores the policies as a weak policy stack entry so that any policies set by a function escape to its caller as before. Source/cmCMakePolicyCommand.h | 6 ++++ Source/cmFunctionCommand.cxx | 8 +++++ Source/cmFunctionCommand.h | 6 +++- Source/cmMacroCommand.cxx | 8 +++++ Source/cmMacroCommand.h | 6 +++- Source/cmMakefile.cxx | 12 ++++++++ Source/cmMakefile.h | 1 + Tests/CMakeLists.txt | 1 + Tests/PolicyScope/CMakeLists.txt | 55 ++++++++++++++++++++++++++++++++++++++ Tests/PolicyScope/main.c | 4 +++ 10 files changed, 105 insertions(+), 2 deletions(-) Author: Brad King <brad.king@kitware.com> Date: Thu Jan 22 18:18:40 2009 +0000 ENH: Isolate policy changes in included scripts Isolation of policy changes inside scripts is important for protecting the including context. This teaches include() and find_package() to imply a cmake_policy(PUSH) and cmake_policy(POP) around the scripts they load, with a NO_POLICY_SCOPE option to disable the behavior. This also creates CMake Policy CMP0011 to provide compatibility. See issue 0008192. Source/cmCMakePolicyCommand.h | 3 + Source/cmFindPackageCommand.cxx | 30 ++++++++--- Source/cmFindPackageCommand.h | 4 +- Source/cmIncludeCommand.cxx | 8 +++- Source/cmIncludeCommand.h | 10 +++- Source/cmMakefile.cxx | 107 ++++++++++++++++++++++++++++++++++++-- Source/cmMakefile.h | 3 +- Source/cmPolicies.cxx | 20 +++++++ Source/cmPolicies.h | 1 + Tests/PolicyScope/Bar.cmake | 8 +++ Tests/PolicyScope/CMakeLists.txt | 33 +++++++++++- Tests/PolicyScope/FindFoo.cmake | 2 + 12 files changed, 210 insertions(+), 19 deletions(-) |
|
(0015338) Brad King (manager) 2009-02-24 15:15 |
CMake 2.6.3 implements CMP0011 as described in this issue. |
| Notes |
| Issue History | |||
| Date Modified | Username | Field | Change |
| 2008-11-28 11:06 | Thorsten Köster | New Issue | |
| 2008-11-28 11:29 | Bill Hoffman | Note Added: 0014225 | |
| 2008-11-28 11:29 | Bill Hoffman | Status | new => assigned |
| 2008-11-28 11:29 | Bill Hoffman | Assigned To | => Brad King |
| 2008-12-01 03:24 | Thorsten Köster | File Added: CMakeLists.txt | |
| 2008-12-01 03:24 | Thorsten Köster | File Added: IncludeFile.cmake | |
| 2008-12-01 03:32 | Thorsten Köster | Note Added: 0014259 | |
| 2008-12-15 15:54 | Brad King | Note Added: 0014353 | |
| 2008-12-15 15:54 | Brad King | Status | assigned => closed |
| 2008-12-15 15:54 | Brad King | Resolution | open => no change required |
| 2009-01-15 16:37 | Brad King | Note Added: 0014578 | |
| 2009-01-15 16:37 | Brad King | Status | closed => feedback |
| 2009-01-15 16:37 | Brad King | Resolution | no change required => reopened |
| 2009-01-15 16:39 | Brad King | Severity | major => feature |
| 2009-01-15 16:39 | Brad King | Status | feedback => assigned |
| 2009-01-15 16:39 | Brad King | Summary | Policy CMP0008 is not honoured in CMake-2.6.2 => Included scripts should be protected by policy push/pop |
| 2009-01-15 16:39 | Brad King | Additional Information Updated | |
| 2009-01-22 13:40 | Brad King | Note Added: 0014662 | |
| 2009-01-22 13:44 | Brad King | Note Added: 0014663 | |
| 2009-01-22 13:45 | Brad King | Note Edited: 0014662 | |
| 2009-02-24 15:15 | Brad King | Note Added: 0015338 | |
| 2009-02-24 15:15 | Brad King | Status | assigned => closed |
| 2009-02-24 15:15 | Brad King | Resolution | reopened => fixed |
| Issue History |
| Copyright © 2000 - 2018 MantisBT Team |