Commit Graph

48 Commits

Author SHA1 Message Date
Daniele E. Domenichelli e3007c92e0 CMakePackageConfigHelpers: Add unit tests for INSTALL_PREFIX option 2014-08-11 09:38:29 -04:00
Daniele E. Domenichelli be8ae96098 Allow the Package Registry to be disabled (#14849)
When a project is packaged for redistribution the local package
registries should not be updated or consulted.  They are for developers.

Add variables to disable use of package registries globally:

* CMAKE_EXPORT_NO_PACKAGE_REGISTRY that disables the export(PACKAGE)
  command
* CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY that disables the User Package
  Registry in all the find_package calls.
* CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY that disables the
  System Package Registry in all the find_package calls.

Update documentation and unit tests.
2014-05-12 09:50:01 -04:00
Brad King d09fda5d91 Tests: Improve FindPackageTest for in-source builds
Use a different directory name for the Exporter build tree so that it is
out-of-source even when the main test is in-source.
2014-05-12 09:44:32 -04:00
Brad King ac24a1c031 Tests: Improve FindPackageTest exported package version
Add a random version component so that the test is unlikely to conflict
with other tests of the same CMake version on the same machine.
2014-05-12 09:44:28 -04:00
Brad King 7e187eeacd CMP0017: Fix check when including from CMake source tree
When running CMake from the build tree the CMAKE_ROOT is the
entire source tree.  Fix the CMP0017 check to be specific to
the Modules/ directory under CMAKE_ROOT so that Tests/ does
not count.  Fix the FindPackageTest modules to include FPHSA
by full path from CMAKE_ROOT so that they do not include the
local FPHSA which reports an error meant to test that CMP0017
works.
2014-03-04 09:35:00 -05:00
Alex Neundorf 7bb1abe56a FPHSA: Add FOUND_VAR option to specify _FOUND variable name
In the new mode FPHSA now accepts a FOUND_VAR option, which can be set
either to ExactCase_FOUND or UPPERCASE_FOUND, no other values are
accepted.  Also add tests for that, including failure.

Alex
2013-02-22 08:31:00 -05:00
Kitware Robot 9db3116226 Remove CMake-language block-end command arguments
Ancient versions of CMake required else(), endif(), and similar block
termination commands to have arguments matching the command starting the
block.  This is no longer the preferred style.

Run the following shell code:

for c in else endif endforeach endfunction endmacro endwhile; do
    echo 's/\b'"$c"'\(\s*\)(.\+)/'"$c"'\1()/'
done >convert.sed &&
git ls-files -z -- bootstrap '*.cmake' '*.cmake.in' '*CMakeLists.txt' |
egrep -z -v '^(Utilities/cm|Source/kwsys/)' |
egrep -z -v 'Tests/CMakeTests/While-Endwhile-' |
xargs -0 sed -i -f convert.sed &&
rm convert.sed
2012-08-13 14:19:16 -04:00
Kitware Robot 77543bde41 Convert CMake-language commands to lower case
Ancient CMake versions required upper-case commands.  Later command
names became case-insensitive.  Now the preferred style is lower-case.

Run the following shell code:

cmake --help-command-list |
grep -v "cmake version" |
while read c; do
    echo 's/\b'"$(echo $c | tr '[:lower:]' '[:upper:]')"'\(\s*\)(/'"$c"'\1(/g'
done >convert.sed &&
git ls-files -z -- bootstrap '*.cmake' '*.cmake.in' '*CMakeLists.txt' |
egrep -z -v '^(Utilities/cm|Source/kwsys/)' |
xargs -0 sed -i -f convert.sed &&
rm convert.sed
2012-08-13 14:19:16 -04:00
Alex Neundorf 14b213c0ce add test for #13241: empty SIZEOF_VOIDP in write_basic_package_version_file
Alex
2012-05-23 20:48:47 +02:00
Alex Neundorf d81d83c218 add macro check_required_components() to configure_package_config_file()
As discussed on cmake-developers, this patch adds a macro
check_required_components() to the file configured via
configure_package_config_file(), so for proper handling
of components in Config.cmake files users can simply call

check_required_components(PackageName)

and this will do the right thing.

Alex
2012-03-19 10:53:36 -04:00
Alex Neundorf b15c0b418b FPHSA(): add HANDLE_COMPONENTS option
if the HANDLE_COMPONENTS is used, FPHSA() now also checks all required COMPONENTS,
i.e. all elements from <name>_FIND_COMPONENTS for which <name>_FIND_REQUIRED_<comp>
is true, and sets <name>_FOUND only to true if all have been found.
As discussed on cmake-developers.

Alex
2012-03-19 10:53:36 -04:00
Alex Neundorf 56ae3f9412 find_package: add test for setting Foo_FOUND to FALSE in a Config file
Alex
2012-03-13 16:56:52 -04:00
Alex Neundorf e390f87dd1 WriteBasicConfigVersionFile: add test for ExactVersion mode
Alex
2012-03-10 16:19:02 +01:00
Alex Neundorf 6973e2d5a8 wrap write_basic_config_version_file as write_basic_package_version_file()
So the name fits better with configure_package_config_file(), as
discussed on the mailing list. Adapt the documentation accordingly.

Alex
2012-03-07 11:23:18 -05:00
Alex Neundorf 204f5d443c add CMakePackageConfigHelpers: configure_package_config_file()
The function configure_package_config_file() may be used instead of
configure_file() for generating the Config.cmake files for installation,
they help to make those files relocatable.

Alex
2012-03-07 11:23:11 -05:00
Alex Neundorf 208bb9009b Set UNSUITABLE instead of not COMPATIBLE
Alex
2011-08-05 22:42:57 +02:00
Alex Neundorf 4ba09bc6a2 Add some tests for write_basic_config_version_file()
Alex
2011-08-01 23:29:27 +02:00
Alex Neundorf 4a50b5f2aa Add a basic test for CMAKE_DISABLE_FIND_PACKAGE_<package>
Alex
2011-06-23 11:09:54 +02:00
Brad King 52a6ed2aed Test find_package multiarch support (#12037) 2011-06-08 10:28:20 -04:00
Brad King 08b93977cf find_package: Fix system package registry test path conversion
Do not use file(TO_NATIVE_PATH) to compute the value to store in the
registry.  It is meant for constructing values to be put in shells.
Since find_package() can use the value with CMake-normalized slashes do
not bother with any conversion.
2011-04-14 09:35:21 -04:00
Brad King 93021adb73 find_package: Test system package registry when possible
Teach the FindPackagTest to try creating the appropriate HKLM system
package registry value.  If it works then add a test to verify that
find_package() reads it as expected.  Then delete the value to cleanup.
2011-04-13 14:28:00 -04:00
Brad King 9fc7ea4c62 find_package: Forward component list for recursive calls in modules
Some find modules call find_package recursively to locate a package
configuration file for the package instead of searching for individual
pieces.  Commit 79e9b755 (Help recursive find_package calls in modules,
2008-10-03) taught find_package to forward the version number and EXACT
arguments through the recursive call automatically.  Do the same for the
component list.
2011-04-07 15:36:05 -04:00
Alex Neundorf 7db8db5b72 Improve documentation and messages for the new CMP0017
This patch incorporates the comments from Brad:
-some improvements to the documentation of CMP0017
-make the test QUIETLY search for zlib
2011-01-04 08:19:33 -05:00
Alex Neundorf db44848f44 Prefer files from CMAKE_ROOT when including from CMAKE_ROOT
This patch makes include() and find_package() prefer cmake files
located in CMAKE_ROOT over those in CMAKE_MODULE_PATH.
This makes sure that the including file gets that file included
which it expects, i.e. the one from cmake with which it was tested.
It only changes behaviour when such an included file exists both
in CMAKE_MODULE_PATH and in CMAKE_ROOT.
This comes together with a new policy CMP0017, with default
behaviour it behaves as it always did, but warns.
With NEW behaviour it includes the file from CMAKE_ROOT
instead from CMAKE_MODULE_PATH. This fixes (if CMP0017 is set)
building KDE 4.5 with cmake >= 2.8.3.
Also a basic test for this policy in included.
2011-01-04 08:06:20 -05:00
Todd Gamblin 1221581aa8 Teach find_* commands to ignore some paths
Add platform configuration variable CMAKE_SYSTEM_IGNORE_PATH and user
configuration variable CMAKE_IGNORE_PATH.  These specify a set of
directories that will be ignored by all the find commands.  Update
FindPackageTest so that several cases will fail without a functioning
CMAKE_IGNORE_PATH.
2010-08-13 11:53:28 -04:00
Brad King 0328379411 Report commit hash in CMake development versions
For builds from Git repositories, add "-g<commit>" to the end of the
version number.  If the source tree is modified, append "-dirty".
For builds from CVS checkouts, add "-cvs-<branch>".
2010-04-23 10:01:49 -04:00
Brad King 3a790251f4 Document and test find_package <pkg>_DIR env var
The find_package(<pkg>) command checks the <pkg>_DIR environment
variable.  This commit documents and tests the feature.
2009-11-04 13:14:57 -05:00
Brad King 71910b3fd4 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.
2009-10-07 14:37:30 -04:00
Brad King 07f029d6ef Test the user package registry
We teach the FindPackageTest to build a sample project that stores its
build tree in the user package registry using export(PACKAGE), and then
find it with find_package.
2009-09-01 14:05:42 -04:00
Brad King bb2c08546c ENH: Test find_package re-find feature
Recently we taught find_package to re-find a package if its
<package>_DIR result variable was set to a location not containing the
package (instead of reporting an error as before).  This tests the
feature.
2009-01-14 09:34:42 -05:00
Brad King 3958b3e112 ENH: Teach find_package about more install dirs
We now search in

  <prefix>/<name>*/
  <prefix>/<name>*/(cmake|CMake)

when looking for package configuration files.  This is useful on Windows
since the Program Files folder is in CMAKE_SYSTEM_PREFIX_PATH.  These
paths are the Windows equivalent to the Apple convention application and
framework paths we already search.  See issue #8264.
2008-12-17 09:24:05 -05:00
Brad King 63e186a8e6 ENH: Strengthen FindPackageTest version check
The previous change to test finding in lib/cmake/<name>* weakened the
versioned find tests.  Since the lib/cmake paths are searched before
lib/<name>* paths the previous change skipped requiring the command to
ignore zot-3.0 when finding zot-3.1.  This change restores that and adds
zot-4.0 to test the lib/cmake path.
2008-12-16 09:13:39 -05:00
Brad King e51969ac49 ENH: Add useful search locations to find_package
This teaches find_package to search

  <prefix>/(share|lib)/cmake/<name>*/

for package configuration files.  Packages that do not already have
files in a <prefix>/lib/<name>* directory can use this location to avoid
cluttering the lib directory.
2008-12-09 14:07:19 -05:00
Brad King 25a5c34a62 ENH: Remove implicit NO_MODULE when recursing
Recently we taught find_package that the NO_MODULE option is implied
when it is recursively invoked in a find-module.  This behavior may be
confusing because two identical calls may enter different modes
depending on context.  It also disallows the possibility that one
find-module defers to another find-module by changing CMAKE_MODULE_PATH
and recursively invoking find_package.  This change reverts the feature.
2008-10-08 10:56:23 -04:00
Brad King 0ae545ebad ENH: Add UNSUITABLE result to package version test
Package version test files may now declare that they are unsuitable for
use with the project testing them.  This is important when the version
being tested does not provide a compatible ABI with the project target
environment.
2008-10-03 10:41:15 -04:00
Brad King 79e9b75558 ENH: Help recursive find_package calls in modules
These changes teach find_package to behave nicely when invoked
recursively inside a find-module for the same package.  The module will
never be recursively loaded again.  Version arguments are automatically
forwarded.
2008-10-03 10:40:07 -04:00
Brad King 4fa96dbf95 ENH: Add version comparison to if() command
Provide VERSION_LESS, VERSION_EQUAL, and VERSION_GREATER operators in
the if() command.  This simplifies component-wise comparison of version
numbers in the form "major[.minor[.patch[.tweak]]]".
2008-09-10 11:58:40 -04:00
Brad King 994262e5cc ENH: Improve find_package version numbering
Make the number of version components specified explicitly available.
Set variables for unspecified version components to "0" instead of
leaving them unset.  This simplifies version number handling for find-
and config-modules.  Also support a fourth "tweak" version component
since some packages use them.
2008-09-10 10:11:48 -04:00
Brad King fdb17d604c ENH: Add test for new find_* command HINTS option. 2008-06-09 15:09:14 -04:00
Ken Martin ce8810c4e7 ENH: preclean some warnings 2008-03-25 11:27:18 -04:00
Brad King 41c2895b75 ENH: Added version support to Config mode of find_package command.
- Added EXACT option to request an exact version.
  - Enforce version using check provided by package.
  - Updated FindPackageTest to test versioning in config mode.
2008-01-28 20:38:48 -05:00
Brad King f41b1e8e91 ENH: Implement version support in the find_package command module mode. Version numbers provided to the command are converted to variable settings to tell the FindXXX.cmake module what version is requested. This addresses issue #1645. 2008-01-21 08:48:33 -05:00
Brad King 81af53e3c0 ENH: Updated FindPackageTest to test new find_package command features. 2008-01-17 09:06:36 -05:00
Brad King 07db9b83a7 ENH: Renamed CMAKE_FIND_PREFIX_PATH to CMAKE_PREFIX_PATH for brevity and consistency with other find path variable names. 2007-12-19 11:06:47 -05:00
Alexander Neundorf 0398d8ad38 ENH: add support for CMAKE_FIND_PREFIX_PATH as discussed with Brad.
CMAKE_FIND_PREFIX_PATH is both an environment variable and a cmake variable,
which is a list of base directories where FIND_PATH, FIND_FILE, FIND_PROGRAM
and FIND_LIBRARY will search in the respective subdirectories

Alex
2007-10-26 09:55:40 -04:00
Alexander Neundorf 9deca5887d ENH: remove the watch for the upper case variable name, it breaks the
feature summary, which needs to check for both the upper case and original
case _FOUND variables

Alex
2007-08-08 13:05:27 -04:00
Alexander Neundorf 5ac0a79029 BUG: disable this test temporarily
Alex
2007-08-07 18:02:33 -04:00
Brad King 62d5138ca3 ENH: Added FindPackageTest to improve coverage. 2003-07-24 11:33:06 -04:00