[Cmake-commits] [cmake-commits] king committed CMakeLists.txt 1.18 1.19
cmake-commits at cmake.org
cmake-commits at cmake.org
Wed Oct 7 14:37:32 EDT 2009
Update of /cvsroot/CMake/CMake/Tests/FindPackageTest
In directory public:/mounts/ram/cvs-serv19912/Tests/FindPackageTest
Modified Files:
CMakeLists.txt
Log Message:
Fix find_package() when <pkg>_DIR is wrong
When <pkg>_DIR is set to an incorrect version we search again and store
the result in the variable, even if it is <pkg>_DIR-NOTFOUND.
There was a bug in the case when the new search does not find anything
and the old value came from a cache entry with UNINITALIZED type. The
command used to try to load a package configuration file from the last
place searched, and would leave the old wrong value in the entry. This
commit fixes the behavior to avoid trying to load a missing file and to
set the value to <pkg>_DIR-NOTFOUND as expected.
Index: CMakeLists.txt
===================================================================
RCS file: /cvsroot/CMake/CMake/Tests/FindPackageTest/CMakeLists.txt,v
retrieving revision 1.18
retrieving revision 1.19
diff -C 2 -d -r1.18 -r1.19
*** CMakeLists.txt 1 Sep 2009 18:05:41 -0000 1.18
--- CMakeLists.txt 7 Oct 2009 18:37:30 -0000 1.19
***************
*** 38,41 ****
--- 38,42 ----
foo Foo Bar TFramework Tframework TApp Tapp Special
VersionedA VersionedB VersionedC VersionedD VersionedE
+ WrongA WrongB WrongC WrongD
wibbleA wibbleB
RecursiveA RecursiveB RecursiveC
***************
*** 68,71 ****
--- 69,90 ----
FIND_PACKAGE(VersionedE 1.2 EXACT NAMES Baz)
+ # Test wrong initial path when result is present.
+ SET(WrongA_DIR "${VersionedD_DIR}")
+ FIND_PACKAGE(WrongA 1.2 EXACT NAMES Baz)
+
+ # Test wrong initial cache entry of UNINITIALIZED type when result is present.
+ SET(WrongB_DIR "${VersionedD_DIR}" CACHE UNINITIALIZED "Wrong Value" FORCE)
+ GET_PROPERTY(type CACHE WrongB_DIR PROPERTY TYPE)
+ FIND_PACKAGE(WrongB 1.2 EXACT NAMES Baz)
+
+ # Test wrong initial path when result is missing.
+ SET(WrongC_DIR "${VersionedD_DIR}")
+ FIND_PACKAGE(WrongC 1.3 EXACT QUIET NAMES Baz)
+
+ # Test wrong initial cache entry of UNINITIALIZED type when result is missing.
+ SET(WrongD_DIR "${VersionedD_DIR}" CACHE UNINITIALIZED "Wrong Value" FORCE)
+ GET_PROPERTY(type CACHE WrongD_DIR PROPERTY TYPE)
+ FIND_PACKAGE(WrongD 1.3 EXACT QUIET NAMES Baz)
+
# HINTS should override the system but PATHS should not
LIST(INSERT CMAKE_SYSTEM_PREFIX_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}/A")
***************
*** 96,99 ****
--- 115,122 ----
SET(VersionedD_EXPECTED "Baz 1.1/BazConfig.cmake")
SET(VersionedE_EXPECTED "Baz 1.2/CMake/BazConfig.cmake")
+ SET(WrongA_EXPECTED "${VersionedE_EXPECTED}")
+ SET(WrongB_EXPECTED "${VersionedE_EXPECTED}")
+ SET(WrongC_MISSING "WrongC_DIR-NOTFOUND")
+ SET(WrongD_MISSING "WrongD_DIR-NOTFOUND")
SET(wibbleA_EXPECTED "A/wibble-config.cmake")
SET(wibbleB_EXPECTED "B/wibble-config.cmake")
***************
*** 104,108 ****
# Check the results.
FOREACH(p ${PACKAGES})
! IF(${p}_FOUND)
# Convert to relative path for comparison to expected location.
FILE(RELATIVE_PATH REL_${p}_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}"
--- 127,138 ----
# Check the results.
FOREACH(p ${PACKAGES})
! IF(DEFINED ${p}_MISSING)
! # Check and report failure.
! IF(NOT "${${p}_DIR}" STREQUAL "${${p}_MISSING}")
! MESSAGE(SEND_ERROR
! "Package ${p} should have been [${${p}_MISSING}] but "
! "was [${${p}_DIR}]")
! ENDIF()
! ELSEIF(${p}_FOUND)
# Convert to relative path for comparison to expected location.
FILE(RELATIVE_PATH REL_${p}_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}"
***************
*** 120,126 ****
"was [${REL_${p}_CONFIG}]")
ENDIF(NOT "${REL_${p}_CONFIG}" STREQUAL "${${p}_EXPECTED}")
! ELSE(${p}_FOUND)
MESSAGE(SEND_ERROR "Package ${p} not found!")
! ENDIF(${p}_FOUND)
ENDFOREACH(p)
--- 150,156 ----
"was [${REL_${p}_CONFIG}]")
ENDIF(NOT "${REL_${p}_CONFIG}" STREQUAL "${${p}_EXPECTED}")
! ELSE()
MESSAGE(SEND_ERROR "Package ${p} not found!")
! ENDIF()
ENDFOREACH(p)
More information about the Cmake-commits
mailing list