2008-03-25 18:27:18 +03:00
cmake_minimum_required ( VERSION 2.6 )
2003-07-24 19:33:06 +04:00
PROJECT ( FindPackageTest )
2010-11-18 00:32:53 +03:00
LIST ( APPEND CMAKE_MODULE_PATH ${ CMAKE_CURRENT_SOURCE_DIR } )
# Look for a package which uses FindPackageHandleStandardArgs.cmake with the
# new (as of cmake 2.8.3) syntax. This works only if CMP0017 is set to NEW,
# because otherwise FindPackageHandleStandardArgs.cmake from the current
# directory is included (via CMAKE_MODULE_PATH).
CMAKE_POLICY ( SET CMP0017 NEW )
2010-12-16 00:24:05 +03:00
FIND_PACKAGE ( ZLIB QUIET )
2010-11-18 00:32:53 +03:00
2003-07-24 19:33:06 +04:00
# Look for a package that has a find module and may be found.
FIND_PACKAGE ( OpenGL QUIET )
# Look for a package that has no find module and will not be found.
2007-08-08 21:05:27 +04:00
FIND_PACKAGE ( NotAPackage QUIET )
2003-07-24 19:33:06 +04:00
# Look for a package that has an advanced find module.
FIND_PACKAGE ( VTK QUIET )
ADD_EXECUTABLE ( FindPackageTest FindPackageTest.cxx )
2007-10-26 17:55:40 +04:00
2007-12-19 19:06:47 +03:00
# test behaviour of cmFindBase wrt. the CMAKE_PREFIX_PATH variable
2007-10-26 17:55:40 +04:00
# foo.h should be found in ${CMAKE_CURRENT_SOURCE_DIR}/include:
2007-12-19 19:06:47 +03:00
SET ( CMAKE_PREFIX_PATH /blub /blah "${CMAKE_CURRENT_SOURCE_DIR}" )
2007-10-26 17:55:40 +04:00
FIND_PATH ( FOO_DIR foo.h )
IF ( NOT FOO_DIR )
MESSAGE ( FATAL_ERROR " Did not find foo.h which is in ${ CMAKE_CURRENT_SOURCE_DIR } /include
2007-12-19 19:06:47 +03:00
C M A K E _ P R E F I X _ P A T H = $ { C M A K E _ P R E F I X _ P A T H } " )
2007-10-26 17:55:40 +04:00
ENDIF ( NOT FOO_DIR )
2008-01-21 16:48:33 +03:00
FIND_PACKAGE ( VersionTestA 1 )
FIND_PACKAGE ( VersionTestB 1.2 )
FIND_PACKAGE ( VersionTestC 1.2.3 )
2008-09-10 18:11:48 +04:00
FIND_PACKAGE ( VersionTestD 1.2.3.4 )
2008-01-21 16:48:33 +03:00
2011-04-13 22:28:00 +04:00
#-----------------------------------------------------------------------------
# Test system package registry if possible.
SET ( CMakeTestSystemPackage "" )
IF ( WIN32 AND NOT CYGWIN )
# Try writing a value to the system package registry.
2011-04-14 17:35:21 +04:00
SET ( _data "${FindPackageTest_SOURCE_DIR}/SystemPackage" )
2011-04-13 22:28:00 +04:00
SET ( _key "HKLM\\Software\\Kitware\\CMake\\Packages\\CMakeTestSystemPackage" )
SET ( _file "${FindPackageTest_BINARY_DIR}/CMakeTestSystemPackage.data" )
FILE ( WRITE ${ _file } "${_data}\n" )
EXECUTE_PROCESS (
C O M M A N D $ { C M A K E _ C O M M A N D } - E m d 5 s u m $ { _ f i l e }
O U T P U T _ V A R I A B L E _ o u t p u t E R R O R _ V A R I A B L E _ e r r o r R E S U L T _ V A R I A B L E _ f a i l e d
O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E
)
STRING ( REGEX REPLACE " .*" "" _value "${_output}" )
IF ( NOT _failed AND _value )
EXECUTE_PROCESS (
C O M M A N D r e g a d d " $ { _ k e y } " / v " $ { _ v a l u e } " / t R E G _ S Z / d " $ { _ d a t a } " / f
O U T P U T _ V A R I A B L E _ o u t p u t E R R O R _ V A R I A B L E _ o u t p u t R E S U L T _ V A R I A B L E _ f a i l e d
)
ENDIF ( )
# If the above worked, add the rest of the test and a rule to
# cleanup the value.
IF ( NOT _failed )
MESSAGE ( STATUS "HKLM is writable: enabling CMakeTestSystemPackage" )
SET ( CMakeTestSystemPackage_CLEANUP reg delete "${_key}" /v "${_value}" /f )
SET ( CMakeTestSystemPackage CMakeTestSystemPackage )
ELSE ( )
MESSAGE ( STATUS "HKLM is readonly: disabling CMakeTestSystemPackage" )
ENDIF ( )
ENDIF ( )
2008-01-21 16:48:33 +03:00
#-----------------------------------------------------------------------------
2008-01-17 17:06:36 +03:00
#SET(CMAKE_FIND_DEBUG_MODE 1)
# For purposes of the test wipe out previous find results.
2008-01-29 04:38:48 +03:00
SET ( PACKAGES
2011-06-17 00:42:00 +04:00
f o o F o o B a r B l u b T F r a m e w o r k T f r a m e w o r k T A p p T a p p S p e c i a l
2008-12-17 17:24:05 +03:00
V e r s i o n e d A V e r s i o n e d B V e r s i o n e d C V e r s i o n e d D V e r s i o n e d E
2009-10-07 22:37:30 +04:00
W r o n g A W r o n g B W r o n g C W r o n g D
2008-06-09 23:09:14 +04:00
w i b b l e A w i b b l e B
2008-10-03 18:40:07 +04:00
R e c u r s i v e A R e c u r s i v e B R e c u r s i v e C
2011-06-08 18:28:20 +04:00
A r c h A A r c h B A r c h C A r c h D
2009-11-04 21:14:57 +03:00
E n v A E n v B
2011-04-13 22:28:00 +04:00
$ { C M a k e T e s t S y s t e m P a c k a g e }
2008-01-29 04:38:48 +03:00
)
2008-01-17 17:06:36 +03:00
FOREACH ( p ${ PACKAGES } )
SET ( ${ p } _DIR "" CACHE FILEPATH "Wipe out find results for testing." FORCE )
ENDFOREACH ( p )
# Enable framework and bundle searching. Make sure bundles are found
# before unix-syle packages.
SET ( CMAKE_FIND_FRAMEWORK LAST )
SET ( CMAKE_FIND_APPBUNDLE FIRST )
2009-01-14 17:34:42 +03:00
# Set the wrong answer for a find to make sure it re-finds.
set ( VersionedA_DIR ${ CMAKE_CURRENT_SOURCE_DIR } /lib/cmake/zot-4.0 )
2010-08-13 02:20:47 +04:00
# Test that CMAKE_IGNORE_PATH can ignore the purposely bad package
# files in the lib/cmake/zot-3.1 directory.
set ( CMAKE_IGNORE_PATH ${ CMAKE_CURRENT_SOURCE_DIR } /lib/cmake/zot-3.1 )
2008-01-17 17:06:36 +03:00
# Look for packages with new-style signatures.
FIND_PACKAGE ( foo NO_MODULE )
FIND_PACKAGE ( Foo CONFIGS FooConfig.cmake )
FIND_PACKAGE ( Bar )
2011-06-17 00:42:00 +04:00
SET ( CMAKE_DISABLE_FIND_PACKAGE_Blub TRUE )
FIND_PACKAGE ( Blub NO_MODULE )
2008-01-17 17:06:36 +03:00
FIND_PACKAGE ( TFramework CONFIGS TFrameworkConfig.cmake )
FIND_PACKAGE ( Tframework )
FIND_PACKAGE ( TApp )
FIND_PACKAGE ( Tapp CONFIGS tapp-config.cmake )
FIND_PACKAGE ( Special NAMES Suffix SuffixTest PATH_SUFFIXES test )
2008-01-29 04:38:48 +03:00
FIND_PACKAGE ( VersionedA 2 NAMES zot )
FIND_PACKAGE ( VersionedB 3.1 EXACT NAMES zot )
2008-12-16 17:13:39 +03:00
FIND_PACKAGE ( VersionedC 4.0 EXACT NAMES zot )
2008-12-17 17:24:05 +03:00
FIND_PACKAGE ( VersionedD 1.1 EXACT NAMES Baz )
FIND_PACKAGE ( VersionedE 1.2 EXACT NAMES Baz )
2008-01-17 17:06:36 +03:00
2009-10-07 22:37:30 +04:00
# 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 )
2008-06-09 23:09:14 +04:00
# HINTS should override the system but PATHS should not
LIST ( INSERT CMAKE_SYSTEM_PREFIX_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}/A" )
FIND_PACKAGE ( wibbleA NAMES wibble PATHS B )
FIND_PACKAGE ( wibbleB NAMES wibble HINTS B )
2008-10-03 18:40:07 +04:00
# Look for package with recursive find-modules.
2011-04-07 23:36:05 +04:00
FIND_PACKAGE ( RecursiveA COMPONENTS A )
2008-10-03 18:40:07 +04:00
FIND_PACKAGE ( RecursiveB 2 )
FIND_PACKAGE ( RecursiveC 3.1 EXACT )
2011-06-08 18:28:20 +04:00
# Test architecture-specific search directories.
SET ( CMAKE_LIBRARY_ARCHITECTURE arch )
FIND_PACKAGE ( ArchA NAMES Bar )
FIND_PACKAGE ( ArchB NAMES Foo CONFIGS FooConfig.cmake )
FIND_PACKAGE ( ArchC 3.1 EXACT NAMES zot )
FIND_PACKAGE ( ArchD 4.0 EXACT NAMES zot )
UNSET ( CMAKE_LIBRARY_ARCHITECTURE )
2009-11-04 21:14:57 +03:00
# Test <Package>_DIR environment variable.
# We erase the main prefix path to ensure the env var is used.
SET ( CMAKE_PREFIX_PATH )
SET ( ENV{EnvA_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/lib/zot-3.1" )
FIND_PACKAGE ( EnvA 3.1 EXACT QUIET NAMES zot ) # Should Work
FIND_PACKAGE ( EnvB 3.1 EXACT QUIET NAMES zot ) # Should Fail
2011-04-13 22:28:00 +04:00
# Test system package registry if available.
IF ( CMakeTestSystemPackage )
FIND_PACKAGE ( CMakeTestSystemPackage )
EXECUTE_PROCESS ( COMMAND ${ CMakeTestSystemPackage_CLEANUP }
O U T P U T _ V A R I A B L E _ o u t p u t E R R O R _ V A R I A B L E _ e r r o r )
ENDIF ( )
2008-01-17 17:06:36 +03:00
# Expected locations at which packages should be found.
SET ( foo_EXPECTED "lib/foo-1.2/foo-config.cmake" )
SET ( Foo_EXPECTED "lib/foo-1.2/CMake/FooConfig.cmake" )
SET ( Bar_EXPECTED "lib/Bar/BarConfig.cmake" )
2011-06-17 00:42:00 +04:00
SET ( Blub_MISSING "" )
2008-01-17 17:06:36 +03:00
SET ( Special_EXPECTED "lib/suffix/test/SuffixTestConfig.cmake" )
SET ( TFramework_EXPECTED
" T F r a m e w o r k . f r a m e w o r k / V e r s i o n s / A / R e s o u r c e s / C M a k e / T F r a m e w o r k C o n f i g . c m a k e " )
SET ( Tframework_EXPECTED
" T F r a m e w o r k . f r a m e w o r k / V e r s i o n s / A / R e s o u r c e s / t f r a m e w o r k - c o n f i g . c m a k e " )
SET ( TApp_EXPECTED
" T A p p . a p p / C o n t e n t s / R e s o u r c e s / T A p p C o n f i g . c m a k e " )
SET ( Tapp_EXPECTED
" T A p p . a p p / C o n t e n t s / R e s o u r c e s / c m a k e / t a p p - c o n f i g . c m a k e " )
2008-01-29 04:38:48 +03:00
SET ( VersionedA_EXPECTED "lib/zot-2.0/zot-config.cmake" )
2008-12-16 17:13:39 +03:00
SET ( VersionedB_EXPECTED "lib/zot-3.1/zot-config.cmake" )
SET ( VersionedC_EXPECTED "lib/cmake/zot-4.0/zot-config.cmake" )
2008-12-17 17:24:05 +03:00
SET ( VersionedD_EXPECTED "Baz 1.1/BazConfig.cmake" )
SET ( VersionedE_EXPECTED "Baz 1.2/CMake/BazConfig.cmake" )
2009-10-07 22:37:30 +04:00
SET ( WrongA_EXPECTED "${VersionedE_EXPECTED}" )
SET ( WrongB_EXPECTED "${VersionedE_EXPECTED}" )
SET ( WrongC_MISSING "WrongC_DIR-NOTFOUND" )
SET ( WrongD_MISSING "WrongD_DIR-NOTFOUND" )
2008-06-09 23:09:14 +04:00
SET ( wibbleA_EXPECTED "A/wibble-config.cmake" )
SET ( wibbleB_EXPECTED "B/wibble-config.cmake" )
2008-10-03 18:40:07 +04:00
SET ( RecursiveA_EXPECTED "lib/RecursiveA/recursivea-config.cmake" )
SET ( RecursiveB_EXPECTED "lib/zot-2.0/zot-config.cmake" )
2008-12-16 17:13:39 +03:00
SET ( RecursiveC_EXPECTED "lib/zot-3.1/zot-config.cmake" )
2011-06-08 18:28:20 +04:00
SET ( ArchA_EXPECTED "lib/arch/Bar/BarConfig.cmake" )
SET ( ArchB_EXPECTED "lib/arch/foo-1.2/CMake/FooConfig.cmake" )
SET ( ArchC_EXPECTED "lib/arch/zot-3.1/zot-config.cmake" )
SET ( ArchD_EXPECTED "lib/arch/cmake/zot-4.0/zot-config.cmake" )
2009-11-04 21:14:57 +03:00
SET ( EnvA_EXPECTED "lib/zot-3.1/zot-config.cmake" )
SET ( EnvB_MISSING "EnvB_DIR-NOTFOUND" )
2011-04-13 22:28:00 +04:00
SET ( CMakeTestSystemPackage_EXPECTED "SystemPackage/CMakeTestSystemPackageConfig.cmake" )
2008-01-17 17:06:36 +03:00
# Check the results.
FOREACH ( p ${ PACKAGES } )
2009-10-07 22:37:30 +04:00
IF ( DEFINED ${ p } _MISSING )
# Check and report failure.
IF ( NOT "${${p}_DIR}" STREQUAL "${${p}_MISSING}" )
MESSAGE ( SEND_ERROR
" P a c k a g e $ { p } s h o u l d h a v e b e e n [ $ { $ { p } _ M I S S I N G } ] b u t "
" w a s [ $ { $ { p } _ D I R } ] " )
ENDIF ( )
ELSEIF ( ${ p } _FOUND )
2008-01-17 17:06:36 +03:00
# Convert to relative path for comparison to expected location.
FILE ( RELATIVE_PATH REL_ ${ p } _CONFIG "${CMAKE_CURRENT_SOURCE_DIR}"
" $ { $ { p } _ C O N F I G } " )
# Debugging output.
IF ( CMAKE_FIND_DEBUG_MODE )
MESSAGE ( "Package ${p} found [${REL_${p}_CONFIG}]" )
ENDIF ( CMAKE_FIND_DEBUG_MODE )
# Check and report failure.
IF ( NOT "${REL_${p}_CONFIG}" STREQUAL "${${p}_EXPECTED}" )
MESSAGE ( SEND_ERROR
" P a c k a g e $ { p } s h o u l d h a v e b e e n [ $ { $ { p } _ E X P E C T E D } ] b u t "
" w a s [ $ { R E L _ $ { p } _ C O N F I G } ] " )
ENDIF ( NOT "${REL_${p}_CONFIG}" STREQUAL "${${p}_EXPECTED}" )
2009-10-07 22:37:30 +04:00
ELSE ( )
2008-01-17 17:06:36 +03:00
MESSAGE ( SEND_ERROR "Package ${p} not found!" )
2009-10-07 22:37:30 +04:00
ENDIF ( )
2008-01-17 17:06:36 +03:00
ENDFOREACH ( p )
2008-01-29 04:38:48 +03:00
# Check that version information was extracted.
IF ( NOT "${VersionedA_VERSION}" STREQUAL "2.0" )
MESSAGE ( SEND_ERROR
" P a c k a g e V e r s i o n e d A i s v e r s i o n [ $ { V e r s i o n e d A _ V E R S I O N } ] , n o t [ 2 . 0 ] " )
ENDIF ( NOT "${VersionedA_VERSION}" STREQUAL "2.0" )
IF ( NOT "${VersionedA_VERSION_MAJOR}" STREQUAL "2" )
MESSAGE ( SEND_ERROR
" P a c k a g e V e r s i o n e d A i s m a j o r v e r s i o n [ $ { V e r s i o n e d A _ V E R S I O N _ M A J O R } ] , n o t [ 2 ] " )
ENDIF ( NOT "${VersionedA_VERSION_MAJOR}" STREQUAL "2" )
IF ( NOT "${VersionedA_VERSION_MINOR}" STREQUAL "0" )
MESSAGE ( SEND_ERROR
" P a c k a g e V e r s i o n e d A i s m i n o r v e r s i o n [ $ { V e r s i o n e d A _ V E R S I O N _ M I N O R } ] , n o t [ 0 ] " )
ENDIF ( NOT "${VersionedA_VERSION_MINOR}" STREQUAL "0" )
IF ( NOT "${VersionedB_VERSION}" STREQUAL "3.1" )
MESSAGE ( SEND_ERROR
" P a c k a g e V e r s i o n e d B i s v e r s i o n [ $ { V e r s i o n e d B _ V E R S I O N } ] , n o t [ 3 . 1 ] " )
ENDIF ( NOT "${VersionedB_VERSION}" STREQUAL "3.1" )
IF ( NOT "${VersionedB_VERSION_MAJOR}" STREQUAL "3" )
MESSAGE ( SEND_ERROR
" P a c k a g e V e r s i o n e d B i s m a j o r v e r s i o n [ $ { V e r s i o n e d B _ V E R S I O N _ M A J O R } ] , n o t [ 3 ] " )
ENDIF ( NOT "${VersionedB_VERSION_MAJOR}" STREQUAL "3" )
IF ( NOT "${VersionedB_VERSION_MINOR}" STREQUAL "1" )
MESSAGE ( SEND_ERROR
" P a c k a g e V e r s i o n e d B i s m i n o r v e r s i o n [ $ { V e r s i o n e d B _ V E R S I O N _ M I N O R } ] , n o t [ 1 ] " )
ENDIF ( NOT "${VersionedB_VERSION_MINOR}" STREQUAL "1" )
IF ( NOT "${Special_VERSION}" STREQUAL "1.2" )
MESSAGE ( SEND_ERROR
" P a c k a g e S p e c i a l i s v e r s i o n [ $ { S p e c i a l _ V E R S I O N } ] , n o t [ 1 . 2 ] " )
ENDIF ( NOT "${Special_VERSION}" STREQUAL "1.2" )
IF ( NOT "${Special_VERSION_MAJOR}" STREQUAL "1" )
MESSAGE ( SEND_ERROR
" P a c k a g e S p e c i a l i s m a j o r v e r s i o n [ $ { S p e c i a l _ V E R S I O N _ M A J O R } ] , n o t [ 1 ] " )
ENDIF ( NOT "${Special_VERSION_MAJOR}" STREQUAL "1" )
IF ( NOT "${Special_VERSION_MINOR}" STREQUAL "2" )
MESSAGE ( SEND_ERROR
" P a c k a g e S p e c i a l i s m i n o r v e r s i o n [ $ { S p e c i a l _ V E R S I O N _ M I N O R } ] , n o t [ 2 ] " )
ENDIF ( NOT "${Special_VERSION_MINOR}" STREQUAL "2" )
2008-09-10 19:58:40 +04:00
# Test version number comparison.
IF ( NOT "1.2.3.4" VERSION_LESS "1.2.3.5" )
MESSAGE ( SEND_ERROR "1.2.3.4 VERSION_LESS 1.2.3.5 is not true!" )
ENDIF ( )
IF ( NOT "1.2" VERSION_LESS "1.10" )
MESSAGE ( SEND_ERROR "1.2 VERSION_LESS 1.10 is not true!" )
ENDIF ( )
IF ( NOT "1.02" VERSION_GREATER "1.1" )
MESSAGE ( SEND_ERROR "1.02 VERSION_GREATER 1.1 is not true!" )
ENDIF ( )
IF ( "1.2.3" VERSION_GREATER "1.2.3.4" )
MESSAGE ( SEND_ERROR "1.2.3 VERSION_GREATER 1.2.3.4 is not false!" )
ENDIF ( )
IF ( NOT "1.2" VERSION_EQUAL "1.2.0.0" )
MESSAGE ( SEND_ERROR "1.2 VERSION_EQUAL 1.2.0.0 is not true!" )
ENDIF ( )
2009-09-01 22:05:42 +04:00
#-----------------------------------------------------------------------------
# Test export(PACKAGE) with find_package.
MESSAGE ( STATUS "Preparing export(PACKAGE) test project" )
TRY_COMPILE ( EXPORTER_COMPILED
$ { F i n d P a c k a g e T e s t _ B I N A R Y _ D I R } / E x p o r t e r
$ { F i n d P a c k a g e T e s t _ S O U R C E _ D I R } / E x p o r t e r
C M a k e T e s t E x p o r t P a c k a g e d u m m y
O U T P U T _ V A R I A B L E o u t p u t )
MESSAGE ( STATUS "Searching for export(PACKAGE) test project" )
SET ( CMakeTestExportPackage_DIR "" CACHE FILEPATH
" W i p e o u t f i n d r e s u l t s f o r t e s t i n g . " F O R C E )
2010-04-23 18:01:49 +04:00
STRING ( REGEX REPLACE "-.*$" "" version ${ CMAKE_VERSION } )
FIND_PACKAGE ( CMakeTestExportPackage 1. ${ version } EXACT REQUIRED )
2011-08-02 01:29:27 +04:00
2012-02-17 02:12:14 +04:00
#-----------------------------------------------------------------------------
# Test configure_package_config_file().
include ( CMakePackageConfigHelpers )
set ( INCLUDE_INSTALL_DIR include )
set ( SHARE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/" )
set ( CURRENT_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}" )
configure_package_config_file ( RelocatableConfig.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/RelocatableConfig.cmake"
I N S T A L L _ D E S T I N A T I O N " $ { C M A K E _ I N S T A L L _ P R E F I X } "
P A T H _ V A R S I N C L U D E _ I N S T A L L _ D I R S H A R E _ I N S T A L L _ D I R C U R R E N T _ B U I L D _ D I R
)
include ( "${CMAKE_CURRENT_BINARY_DIR}/RelocatableConfig.cmake" )
if ( NOT "${RELOC_INCLUDE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/include" )
message ( SEND_ERROR "RELOC_INCLUDE_DIR set by configure_package_config_file() is set to \" ${ RELOC_INCLUDE_DIR } \" ( expected \"${CMAKE_CURRENT_BINARY_DIR}/include\")")
endif ( )
if ( NOT "${RELOC_SHARE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/share/" )
message ( SEND_ERROR "RELOC_SHARE_DIR set by configure_package_config_file() is set to \" ${ RELOC_SHARE_DIR } \" ( expected \"${CMAKE_CURRENT_BINARY_DIR}/share/\")")
endif ( )
if ( NOT "${RELOC_BUILD_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}" )
message ( SEND_ERROR "RELOC_BUILD_DIR set by configure_package_config_file() is set to \" ${ RELOC_BUILD_DIR } \" ( expected \"${CMAKE_CURRENT_BINARY_DIR}\")")
endif ( )
2011-08-02 01:29:27 +04:00
#-----------------------------------------------------------------------------
# Test write_basic_config_version_file().
2012-02-17 03:36:18 +04:00
write_basic_package_version_file ( ${ CMAKE_CURRENT_BINARY_DIR } /Foo123ConfigVersion.cmake
V E R S I O N 1 . 2 . 3
C O M P A T I B I L I T Y A n y N e w e r V e r s i o n )
2011-08-02 01:29:27 +04:00
set ( PACKAGE_FIND_VERSION 2.3.4 )
include ( ${ CMAKE_CURRENT_BINARY_DIR } /Foo123ConfigVersion.cmake )
if ( PACKAGE_VERSION_COMPATIBLE )
message ( SEND_ERROR "Found Foo123 with version 1.2.3, but 2.3.4 was requested !" )
endif ( )
set ( PACKAGE_FIND_VERSION 0.0.1 )
include ( ${ CMAKE_CURRENT_BINARY_DIR } /Foo123ConfigVersion.cmake )
if ( NOT PACKAGE_VERSION_COMPATIBLE )
message ( SEND_ERROR "Did not find Foo123 with version 1.2.3 (0.0.1 was requested) !" )
endif ( )
set ( PACKAGE_FIND_VERSION 1.0.0 )
include ( ${ CMAKE_CURRENT_BINARY_DIR } /Foo123ConfigVersion.cmake )
if ( NOT PACKAGE_VERSION_COMPATIBLE )
message ( SEND_ERROR "Did not find Foo123 with version 1.2.3 (1.0.0 was requested) !" )
endif ( )
if ( PACKAGE_VERSION_EXACT )
message ( SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !" )
endif ( )
set ( PACKAGE_FIND_VERSION 1.2.3 )
include ( ${ CMAKE_CURRENT_BINARY_DIR } /Foo123ConfigVersion.cmake )
if ( NOT PACKAGE_VERSION_COMPATIBLE )
message ( SEND_ERROR "Did not find Foo123 with version 1.2.3 (1.2.3 was requested) !" )
endif ( )
if ( NOT PACKAGE_VERSION_EXACT )
message ( SEND_ERROR "PACKAGE_VERSION_EXACT not set, although it should be !" )
endif ( )
#######################
2012-02-17 03:36:18 +04:00
include ( WriteBasicConfigVersionFile )
2011-08-02 01:29:27 +04:00
write_basic_config_version_file ( ${ CMAKE_CURRENT_BINARY_DIR } /Boo123ConfigVersion.cmake
V E R S I O N 1 . 2 . 3
C O M P A T I B I L I T Y S a m e M a j o r V e r s i o n )
2011-08-06 00:42:57 +04:00
set ( PACKAGE_VERSION_EXACT FALSE )
2011-08-02 01:29:27 +04:00
set ( PACKAGE_FIND_VERSION 2.3.4 )
set ( PACKAGE_FIND_VERSION_MAJOR 2 )
include ( ${ CMAKE_CURRENT_BINARY_DIR } /Boo123ConfigVersion.cmake )
if ( PACKAGE_VERSION_COMPATIBLE )
message ( SEND_ERROR "Found Boo123 with version 1.2.3, but 2.3.4 was requested !" )
endif ( )
2011-08-06 00:42:57 +04:00
if ( PACKAGE_VERSION_EXACT )
message ( SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !" )
endif ( )
2011-08-02 01:29:27 +04:00
set ( PACKAGE_FIND_VERSION 0.0.1 )
set ( PACKAGE_FIND_VERSION_MAJOR 0 )
include ( ${ CMAKE_CURRENT_BINARY_DIR } /Boo123ConfigVersion.cmake )
if ( PACKAGE_VERSION_COMPATIBLE )
message ( SEND_ERROR "Found Boo123 with version 1.2.3, but 0.0.1 was requested !" )
endif ( )
2011-08-06 00:42:57 +04:00
if ( PACKAGE_VERSION_EXACT )
message ( SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !" )
endif ( )
2011-08-02 01:29:27 +04:00
set ( PACKAGE_FIND_VERSION 1.0.0 )
set ( PACKAGE_FIND_VERSION_MAJOR 1 )
include ( ${ CMAKE_CURRENT_BINARY_DIR } /Boo123ConfigVersion.cmake )
if ( NOT PACKAGE_VERSION_COMPATIBLE )
message ( SEND_ERROR "Did not find Boo123 with version 1.2.3 (1.0.0 was requested) !" )
endif ( )
if ( PACKAGE_VERSION_EXACT )
message ( SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !" )
endif ( )
set ( PACKAGE_FIND_VERSION 1.2.3 )
set ( PACKAGE_FIND_VERSION_MAJOR 1 )
include ( ${ CMAKE_CURRENT_BINARY_DIR } /Boo123ConfigVersion.cmake )
if ( NOT PACKAGE_VERSION_COMPATIBLE )
message ( SEND_ERROR "Did not find Boo123 with version 1.2.3 (1.2.3 was requested) !" )
endif ( )
if ( NOT PACKAGE_VERSION_EXACT )
message ( SEND_ERROR "PACKAGE_VERSION_EXACT not set, although it should be !" )
endif ( )
2011-08-06 00:42:57 +04:00
if ( PACKAGE_VERSION_UNSUITABLE )
message ( SEND_ERROR "PACKAGE_VERSION_UNSUITABLE set, but must not be !" )
endif ( )