Commit Graph

111 Commits

Author SHA1 Message Date
Alex Neundorf 1f8f58a0b9 fix #13195: avoid multiple mentions of found packages
Now before adding a package to the list of found or not-found
packages, the package is remvoed from both lists before.

Alex
2012-05-06 16:32:10 +02:00
Brad King 5ed93db4cf find_package: Fix components signature documentation (#13142)
Update the signature notation to show that "REQUIRED COMPONENTS ..." is
allowed and that REQUIRED is an option on its own.
2012-04-19 09:41:17 -04:00
Brad King 6c12e820b8 find_package: Document <package>_FIND_* variables (#13142)
When loading a find module or package config file the find_package
command defines several variables to provide information about the
caller's request.  Previously this was documented only in the
Modules/readme.txt file which is not distributed.  Document the
behavior explicitly in the main find_package documentation.
2012-04-18 09:17:35 -04:00
Alex Neundorf 34108cd3b3 find_package: add documentation for OPTIONAL_COMPONENTS
This patch adds documentation for OPTIONAL_COMPONENTS to cmFindPackage.cxx,
and also extends Modules/readme.txt significantly with regard to how
components should be handled.

Alex
2012-03-19 10:53:36 -04:00
Alex Neundorf f2e0a18761 find_package: add OPTIONAL_COMPONENTS keyword
Add an OPTIONAL_COMPONENTS keyword to find_package() so we can have a
clear distinction between required and optional components.  Don't allow
a component to be both required and optional.

Alex
2012-03-19 10:53:36 -04:00
Alex Neundorf 16c0c7376c find_package: allow <pkg>Config.cmake to set <pkg>_FOUND to FALSE
Before, find_package in Config mode always set Foo_FOUND to true if the
Config file has been found and could be executed.
If the Config file itself detected some problem, like a missing dependency,
it did not have a way to signal to the outside that the package is not working.
With this patch, if a Config file sets Foo_FOUND to FALSE, this is taken into
account and not overridden.

Alex
2012-03-13 16:56:23 -04:00
David Cole fa0f065426 Merge topic 'find_package_fatal_error_if_required_and_config_not_found'
c5ae733 find_package: Test that REQUIRED aborts processing correctly
c91a54d find_package: error out if REQUIRED Config has not been found
2012-03-08 15:14:23 -05:00
David Cole da43d8fa8d Merge topic 'MakingConfigFilesEasier_ConfigureMacro'
6973e2d wrap write_basic_config_version_file as write_basic_package_version_file()
204f5d4 add CMakePackageConfigHelpers: configure_package_config_file()
2012-03-08 15:14:12 -05: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 c91a54db37 find_package: error out if REQUIRED Config has not been found
If in Config mode a configuration file could not be found, cmake printed
an error, but did not actually stop processing. With SetFatalErrorOccured
it does.

Alex
2012-03-06 21:16:24 +01:00
David Cole e4382180fc Merge topic 'add-const-qualifiers'
737c49a Add 'const' qualifier to some cmCommand members
261491f cmPropertyDefinition::IsChained is const
2012-03-02 11:50:07 -05:00
Yury G. Kudryashov 737c49a357 Add 'const' qualifier to some cmCommand members
Use const_cast for the special case in cmFindBase where
GetFullDocumentation calls GenerateDocumentation.
2012-02-29 13:27:04 -05:00
Brad King d3651041e9 find_package: Optionally warn when implicitly using Config mode
Define variable CMAKE_FIND_PACKAGE_WARN_NO_MODULE for use by a project
that wants to use an explicit mode in every call to find_package in
order to generate more specific failure messages.  Word the warning
using the new CONFIG and MODULE mode keywords when the minimum required
version of CMake is new enough to have them.  Otherwise word the warning
using the old NO_MODULE mode keyword.

Inspired-by: Alex Neundorf <neundorf@kde.org>
2012-02-28 10:01:44 -05:00
Brad King 31ead5f695 find_package: Reject mixed use of MODULE- and CONFIG-only options
Many options imply exclusive Config mode.  The new MODULE option
implies exclusive Module mode.  Do not allow mixed combinations.
2012-02-28 09:58:31 -05:00
Alex Neundorf 6d8308314a find_package: mention requested version number in error message
When neither a Find-module or a config file can be found print the
required version so the user knows which version of the package to
install.
2012-02-28 09:58:31 -05:00
Alex Neundorf 9c39bbd474 find_package: add CONFIG mode keyword alias for NO_MODULE 2012-02-28 09:58:31 -05:00
Alex Neundorf f310f67291 find_package: add MODULE mode to use only Find-modules
The new mode differ from default mode in that that it doesn't fallback
to config mode.  The default mode stays unchanged.
2012-02-28 09:58:01 -05:00
Alex Neundorf 7d67dcf52b find_package: improve error message when no Find module is present
Explain exactly why CMake is looking for a package configuration file
and who is expected to provide what:

 CMake Error at CMakeLists.txt:7 (find_package):
  By not providing "Find<pkg>.cmake" in CMAKE_MODULE_PATH the caller
  has asked CMake to find a package configuration file provided by
  "<pkg>", but CMake did not find one.

  Could not find a package configuration file provided by "<pkg>"
  with any of the names:

    <pkg>Config.cmake
    <pkg>-config.cmake

  Add the installation prefix of "<pkg>" to CMAKE_PREFIX_PATH or
  set "<pkg>_DIR" to a directory containing one of the above files.
  If "<pkg>" provides separate development package or SDK be sure
  it has been installed.

The first paragraph explains how CMake is interpreting the intention of
the caller.  This puts the blame or credit at the call site in the
project code where it belongs both when it is a bug and when it is
intentional.  It can be dropped in NO_MODULE mode.

Suggested-by: Brad King <brad.king@kitware.com>
2012-02-28 09:56:49 -05:00
Alex Neundorf 978d89b99d find_package: rename NoModule to UseFindModules
...positive logic is easier to handle

Alex
2012-02-27 16:36:29 -05:00
Alex Neundorf b3f9fe42f9 find_package: print error if an invalid CONFIGS name is used
In commit 41c2895b (Added version support to Config mode of find_package
command, 2008-01-28) the error message was computed but was not
reported.  Add the SetError call to report it.
2012-02-27 16:09:34 -05:00
Alex Neundorf e6c5b9452a fix FeatureSummary for REQUIRED packages, they were reported as OPTIONAL
Alex
2012-02-11 18:04:26 +01:00
Brad King b0cd630521 Refactor find_* command final path list computation
All find_* commands re-root the list of paths and then add trailing
slashes.  Factor this pair of calls out into a dedicated method.  The
new method would be the only caller to AddTrailingSlashes, so subsume
that method into it.
2011-09-23 14:36:27 -04:00
David Cole 674be27a7f Merge topic 'WriteConfigVersionFile_2TemplateFiles'
c9761de Improve documentation for WriteBasicConfigVersionFile.cmake
208bb90 Set UNSUITABLE instead of not COMPATIBLE
bb03c2d Really fix copyright notice
d50a61a Fix copyright notice
4ba09bc Add some tests for write_basic_config_version_file()
02b1e4b Add example to documentation
d216a67 Provide macro write_basic_config_version_file()
2011-08-16 17:03:00 -04:00
David Cole 2c7b38afa6 Merge topic 'FeatureSummaryImprovements'
b62349c FeatureSummary.cmake: update documentation
f366cf8 FeatureSummary.cmake: cosmetics
f407bb5 FeatureSummary.cmake: only higher TYPEs can override previous TYPEs
02d47ab FeatureSummary.cmake: error out when a REQUIRED package is missing
91a1527 FeatureSummary.cmake: add INCLUDE_QUIET_PACKAGES keyword
0671a02 FeatureSummary.cmake: remove "comment" field
aae13f4 Extend FeatureSummary: add PURPOSE of package and TYPE
2011-08-02 15:09:41 -04:00
Alex Neundorf d216a67e4a Provide macro write_basic_config_version_file()
This macro can be used to generate basic version files which can be
installed along a Config.cmake file to provide versioning support.

This (3rd try) is implemented using a macro, which maps
the COMPATIBILITY mode to a filename and configure_file()s the
resulting file.

Alex
2011-08-01 22:59:18 +02:00
Alex Neundorf 91a1527735 FeatureSummary.cmake: add INCLUDE_QUIET_PACKAGES keyword
Now found packages are not stored in ENABLED/DISABLED_FEATURES
anymore, but always in PACKAGES_FOUND/NOT_FOUND.
ENABLED/DISABLED_FEATURES is now only used via
ADD_FEATURE_INFO(), e.g. for stuff set via option().

Alex
2011-07-17 17:48:00 +02:00
Alex Neundorf a66df08543 Add documentation for the CMAKE_DISABLE_FIND_PACKAGE_<Name> switch
Alex
2011-06-23 11:09:41 +02:00
Alex Neundorf 6e1d3edb4d Add a switch to disable a find_package() call completely
As discussed, this adds a switch CMAKE_DISABLE_FIND_PACKAGE_<name>,
which, when set to TRUE, keeps the find_package() command from executing.
When the package is REQUIRED at the same time, an error is generated.

Alex
2011-06-21 21:18:23 +02:00
Brad King b41ad3b399 Teach find_(library|package) about Linux multiarch (#12037)
Implement support for multiarch as specified here:

  http://wiki.debian.org/Multiarch
  https://wiki.ubuntu.com/MultiarchSpec

Detect the <arch> part of <prefix>/lib/<arch> from the implicit library
search path from each compiler to set CMAKE_<lang>_LIBRARY_ARCHITECTURE.
Define CMAKE_LIBRARY_ARCHITECTURE using one of these values (they should
all be the same).  Teach the find_library and find_package commands to
search <prefix>/lib/<arch> whenever they would search <prefix>/lib.
2011-06-08 10:04:44 -04:00
Brad King b95f3cac91 find_package: Check both 32-bit and 64-bit registry views
The system package registry is under HKEY_LOCAL_MACHINE\SOFTWARE which
has separate views for 32-bit and 64-bit applications.  Look in both
views, but prefer the architecture matching the build target platform.
2011-04-13 13:17:42 -04:00
Brad King a0d76c10a7 find_package: Search a "system package registry"
Generalize the "user package registry" created by commit ed0650f6 (Teach
find_package to search a "package registry", 2009-09-01).  Define a
corresponding "system" registry key under HKEY_LOCAL_MACHINE.  This
gives package installers a place to create a registry value that points
at the right location for find_package() to locate the package.
2011-04-13 13:17:00 -04:00
Brad King 549458f280 find_package: Document user package registry locations
Specify the Windows registry key under HKEY_CURRENT_USER and directory
on UNIX platforms in which the package registry is stored.
2011-04-13 13:13:58 -04:00
Brad King c9563dbe1a find_package: Cleanup user package registry less aggressively
Delete only REG_SZ entries that are specifically detected to point to
invalid paths.  This will allow future versions to add other value types
for different purposes.
2011-04-13 12:59:00 -04:00
Brad King 4df119773c find_package: Rename implementation of user package registry
Rename {Registry => UserRegistry} in names associated specifically with
the user package registry and not registry access in general.
2011-04-13 12:57:18 -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
Brad King 5303fbf09e Speedup find_* commands (#11412)
Delay computation of the command documentation until it is needed.
It is wasteful to do it in the constructor on every call.

Inspired-By: Christian Ehrlicher <Ch.Ehrlicher@gmx.de>
2010-11-12 10:47:28 -05:00
Brad King 4ea441eaf9 Merge topic 'ImproveFindPackageConfigMode'
5cdfc9c Improve wording of the error message of find_package() in config-mode
4969c3b Improve version notice in the generated message
e8ae504 Add option CONFIG_MODE to FPHSA()
b4b8f96 Don't create an empty element at the end of Foo_CONSIDERED_CONFIGS/VERSIONS
cc955a0 Small cleanup of FindPackageHandleStandardArgs.cmake
0367245 Replace the two vector<string,string> with one vector<struct{string,string}>
130b0e2 Improve error message in Config-mode when no appropriate version was found
dfe9c95 Record all considered Config files and their versions.
2010-09-08 11:07:55 -04:00
Alex Neundorf 5cdfc9c8ea Improve wording of the error message of find_package() in config-mode
As suggested by Brad, this improves the wording of the error message
in config-mode when config-files were found, but no suitable version.
The patch also contains the small loop-optimization suggested by Brad.

Alex
2010-08-31 21:10:00 +02:00
Alex Neundorf b4b8f96391 Don't create an empty element at the end of Foo_CONSIDERED_CONFIGS/VERSIONS
Alex
2010-08-29 19:50:51 +02:00
Alex Neundorf 0367245f0c Replace the two vector<string,string> with one vector<struct{string,string}>
Before this patch there were two separate vectors, and the code made sure
they always had the same size.
With this patch the code doesn't have to ensure this anymore, there is only
one vector now.

Alex
2010-08-29 17:51:44 +02:00
Alex Neundorf 130b0e2195 Improve error message in Config-mode when no appropriate version was found
If in config-mode config files have been found by find_package(), but their
version didn't match the requested version, now all considered files
and their versions are printed (instead of saying "didn't find config file)

Alex
2010-08-29 17:43:45 +02:00
Alex Neundorf dfe9c95129 Record all considered Config files and their versions.
As suggested on cmake-devel, find_package in Config-mode now records
all considered config-files and their versions in
<package>_CONSIDERED_CONFIGS and <package>_CONSIDERED_VERSIONS respectively.

Alex
2010-08-29 17:07:39 +02:00
Alex Neundorf 33338781db Log the required package version and major improvement to FeatureSummary
find_package() now also stores the required version automatically, so it
can be used by FeatureSummary.cmake.
This was one of the requested features for setting up nightly builds
for KDE, since with this functionality it will be possible to write
a file at the end of each project which lists all required packages
and their versions. This file could then be compared for equality
with an older one and if something has changed the build maintainer
can be emailed.

In FeatureSummary.cmake there is now a new function feature_summary(),
which also allows to print the log to a file or into a variable.
It also allows to specify whether to append to a file or to write a new
one, and what information to log.

Docs are still missing.

Alex
2010-08-24 21:24:54 +02: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 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 56d1a1780d Create cmMakefile::PlatformIs64Bit helper method
This method centralizes tests for whether CMAKE_SIZEOF_VOID_P is 8.
2009-09-30 13:45:14 -04:00
Brad King 96afb12087 Convert CMake to OSI-approved BSD License
This converts the CMake license to a pure 3-clause OSI-approved BSD
License.  We drop the previous license clause requiring modified
versions to be plainly marked.  We also update the CMake copyright to
cover the full development time range.
2009-09-28 11:43:28 -04:00
Brad King 6c59b924d2 Use BeAPI for per-user package registry on Haiku
Applications on Haiku are discouraged from storing their data in $HOME.
This teaches export(PACKAGE) and find_package() to use the BeAPI on
Haiku to store the package registry instead of using ~/.cmake/packages.

See issue #9603.
2009-09-28 09:45:34 -04:00
Brad King b41a548d86 Add parentheses around '&&' between '||' for gcc
The GNU compiler warns about possible operator precedence mistakes and
asks for explicit parentheses (-Wparentheses).  We add the parentheses
to silence the warning.  This also fixes one real logic error in the
find_package() implementation by correcting expression evaluation order.
2009-09-11 08:18:15 -04:00