[Cmake-commits] [cmake-commits] king committed Bar.cmake NONE 1.1 CMakeLists.txt 1.1 1.2 FindFoo.cmake NONE 1.1

cmake-commits at cmake.org cmake-commits at cmake.org
Thu Jan 22 13:18:42 EST 2009


Update of /cvsroot/CMake/CMake/Tests/PolicyScope
In directory public:/mounts/ram/cvs-serv2946/Tests/PolicyScope

Modified Files:
	CMakeLists.txt 
Added Files:
	Bar.cmake FindFoo.cmake 
Log Message:
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 #8192.


--- NEW FILE: FindFoo.cmake ---
cmake_minimum_required(VERSION 2.6.3)
cmake_policy(SET CMP0003 OLD)

Index: CMakeLists.txt
===================================================================
RCS file: /cvsroot/CMake/CMake/Tests/PolicyScope/CMakeLists.txt,v
retrieving revision 1.1
retrieving revision 1.2
diff -C 2 -d -r1.1 -r1.2
*** CMakeLists.txt	22 Jan 2009 18:16:47 -0000	1.1
--- CMakeLists.txt	22 Jan 2009 18:18:40 -0000	1.2
***************
*** 1,4 ****
- cmake_minimum_required(VERSION 2.6.3)
  project(PolicyScope C)
  
  #-----------------------------------------------------------------------------
--- 1,4 ----
  project(PolicyScope C)
+ # No cmake_minimum_required(VERSION), it's in FindFoo.
  
  #-----------------------------------------------------------------------------
***************
*** 11,14 ****
--- 11,45 ----
  
  #-----------------------------------------------------------------------------
+ # Test using a development framework that sets policies for us.
+ 
+ # Policy CMP0011 should not be set at this point.
+ cmake_policy(GET CMP0011 cmp)
+ check(CMP0011 "" "${cmp}")
+ 
+ # Put the test modules in the search path.
+ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
+ 
+ # The included file should set policies for us.
+ find_package(Foo)
+ 
+ # Check policies set by the package.
+ cmake_policy(GET CMP0003 cmp)
+ check(CMP0003 "OLD" "${cmp}")
+ cmake_policy(GET CMP0002 cmp)
+ check(CMP0002 "NEW" "${cmp}")
+ cmake_policy(GET CMP0011 cmp)
+ check(CMP0011 "NEW" "${cmp}")
+ 
+ # Make sure an included file cannot change policies.
+ include(Bar)
+ cmake_policy(GET CMP0003 cmp)
+ check(CMP0003 "OLD" "${cmp}")
+ 
+ # Allow the included file to change policies.
+ include(Bar NO_POLICY_SCOPE)
+ cmake_policy(GET CMP0003 cmp)
+ check(CMP0003 "NEW" "${cmp}")
+ 
+ #-----------------------------------------------------------------------------
  # Test function and macro policy recording.
  

--- NEW FILE: Bar.cmake ---
cmake_minimum_required(VERSION 2.6.3)

# Make sure a policy set differently by our includer is now correct.
cmake_policy(GET CMP0003 cmp)
check(CMP0003 "NEW" "${cmp}")

# Test allowing the top-level file to not have cmake_minimum_required.
cmake_policy(SET CMP0000 OLD)



More information about the Cmake-commits mailing list