Commit Graph

90 Commits

Author SHA1 Message Date
Brad King 86578eccf2 Simplify CMake per-source license notices
Per-source copyright/license notice headers that spell out copyright holder
names and years are hard to maintain and often out-of-date or plain wrong.
Precise contributor information is already maintained automatically by the
version control tool.  Ultimately it is the receiver of a file who is
responsible for determining its licensing status, and per-source notices are
merely a convenience.  Therefore it is simpler and more accurate for
each source to have a generic notice of the license name and references to
more detailed information on copyright holders and full license terms.

Our `Copyright.txt` file now contains a list of Contributors whose names
appeared source-level copyright notices.  It also references version control
history for more precise information.  Therefore we no longer need to spell
out the list of Contributors in each source file notice.

Replace CMake per-source copyright/license notice headers with a short
description of the license and links to `Copyright.txt` and online information
available from "https://cmake.org/licensing".  The online URL also handles
cases of modules being copied out of our source into other projects, so we
can drop our notices about replacing links with full license text.

Run the `Utilities/Scripts/filter-notices.bash` script to perform the majority
of the replacements mechanically.  Manually fix up shebang lines and trailing
newlines in a few files.  Manually update the notices in a few files that the
script does not handle.
2016-09-27 15:14:44 -04:00
Daniel Pfeifer 516f8edb2e Avoid else after return 2016-09-16 22:45:24 +02:00
Brad King 54475018ae Restore find_(library|file|path) search of PATH itself
The fix in commit commit v3.6.0-rc1~82^2 (Drop find_(library|file|path)
prefixes from PATH on non-Windows, 2016-05-09) aggressively dropped
search of the entries in PATH itself in addition to the prefixes derived
from it.  This regresses find modules that (incorrectly) depended on the
behavior, including some of our own modules such as FindImageMagick.

Restore the search of entries in PATH itself.  If we want to drop it
later we will need to do so with a policy.  Fixes #16192.
2016-07-11 10:27:27 -04:00
Kitware Robot d9fd2f5402 Revise C++ coding style using clang-format
Run the `Utilities/Scripts/clang-format.bash` script to update
all our C++ code to a new style defined by `.clang-format`.
Use `clang-format` version 3.8.

* If you reached this commit for a line in `git blame`, re-run the blame
  operation starting at the parent of this commit to see older history
  for the content.

* See the parent commit for instructions to rebase a change across this
  style transition commit.
2016-05-16 16:05:19 -04:00
Brad King b30b32a493 Drop find_(library|file|path) prefixes from PATH on non-Windows
Since commit v3.3.0-rc1~430^2 (Teach find_(library|file|path) to get
prefixes from PATH, 2015-02-18) we search in <prefix>/include and
<prefix>/lib directories for prefixes with bin directories in the PATH
environment variable.  The motivation was to support MSYS, MinGW and
similar Windows platforms in their default environments automatically.
At the time this behavior was thought to be worthwhile in general.

Suggested-by: Chuck Atkins <chuck.atkins@kitware.com>
2016-05-09 12:58:08 -04:00
Brad King 0ac18d40c8 Remove `//------...` horizontal separator comments
Modern editors provide plenty of ways to visually separate functions.
Drop the explicit comments that previously served this purpose.
Use the following command to automate the change:

    $ git ls-files -z -- \
        "*.c" "*.cc" "*.cpp" "*.cxx" "*.h" "*.hh" "*.hpp" "*.hxx" |
      egrep -z -v "^Source/cmCommandArgumentLexer\." |
      egrep -z -v "^Source/cmCommandArgumentParser(\.y|\.cxx|Tokens\.h)" |
      egrep -z -v "^Source/cmDependsJavaLexer\." |
      egrep -z -v "^Source/cmDependsJavaParser(\.y|\.cxx|Tokens\.h)" |
      egrep -z -v "^Source/cmExprLexer\." |
      egrep -z -v "^Source/cmExprParser(\.y|\.cxx|Tokens\.h)" |
      egrep -z -v "^Source/cmFortranLexer\." |
      egrep -z -v "^Source/cmFortranParser(\.y|\.cxx|Tokens\.h)" |
      egrep -z -v "^Source/cmListFileLexer\." |
      egrep -z -v "^Source/cm_sha2" |
      egrep -z -v "^Source/(kwsys|CursesDialog/form)/" |
      egrep -z -v "^Utilities/(KW|cm).*/" |
      xargs -0 sed -i '/^\(\/\/---*\|\/\*---*\*\/\)$/ {d;}'

This avoids modifying third-party sources and generated sources.
2016-05-09 09:41:43 -04:00
Brad King 401229759c Merge branch 'fix-bad-search-ordering' into test-search-ordering 2015-09-15 08:52:38 -04:00
Chuck Atkins 02440154fb find_*: Fix search order when the environment duplicates some HINTS
Refactoring in the topic merged by commit v3.2.0-rc1~400 (Merge topic
'refactor-search-path-construction', 2014-11-13) introduced a bug that
filters out duplicate paths in an incorrect order.  Restore the search
path to its documented order even when duplicate paths are present.

Reported-by: Marc CHEVRIER <marc.chevrier@sap.com>
2015-09-14 14:43:38 -04:00
Stephen Kelly 8ea0b81d20 cmAlgorithms: Rename cmRange to cmMakeRange. 2015-07-22 10:58:19 -04:00
Stephen Kelly f081c5bddd cmState: Move CacheEntryType enum from cmCacheManager. 2015-04-13 11:44:16 -04:00
Stephen Kelly ff7169a03c Port to cmState. 2015-04-13 11:44:15 -04:00
Stephen Kelly ba404938a2 cmCacheManager: Port consumers to non-iterator API.
This simplifies reasoning about the follow-up commit which ports
away from cmCacheManager to a class with the same method names.
2015-04-08 18:47:00 +02:00
Brad King 3347c5e4f9 Revert topic 'refactor-cache-api'
This topic was never tested without some follow-up commits.  The
GetCacheEntryValue API returns a pointer to memory freed on return.
It will have to be revised along with the rest of the original topic.
2015-04-07 17:15:04 -04:00
Stephen Kelly 9410e24a4a cmCacheManager: Port consumers to non-iterator API.
This simplifies reasoning about the follow-up commit which ports
away from cmCacheManager to a class with the same method names.
2015-04-06 17:58:55 +02:00
Stephen Kelly 7916d7bac6 Include cmAlgorithms where it is used. 2015-03-11 00:17:29 +01:00
Brad King cc3611023d Merge topic 'use-algorithms'
bb9d71b4 Replace loops with algorithms.
4afe6c26 cmAlgorithms: Add cmReverseRange adaptor.
a3a0a8c2 cmAlgorithms: Add cmFindNot algorithm.
8c74a41f cmRST: Replace two erase with a rotate and larger erase.
61fe1919 cmAlgorithms: Update concept requirement to FowardIterator
09d6125b cmAlgorithms: Move cmRotate out of 'implementation detail' namespace.
8ed6ecac cmRST: Move two algorithms beside each other.
dfe49c20 cmRST: Use std::min where appropriate.
21b0654a cmGlobalGenerator: Convert set insert algorithm to vector algorithms.
416df93a Convert some raw loops to cmWrap.
37b88d34 cmAlgorithms: Add cmWrap.
a2818093 Use cmJoin where possible.
76207b08 cmCacheManager: Replace loop with algorithm.
60c3bb73 cmGlobalGenerator: Replace loop with algorithm.
05fec779 cmTarget: Port loop to algorithm.
9c225767 cmGlobalGenerator: Replace set::insert algorithm with cmRemoveDuplicates.
...
2015-02-23 10:26:38 -05:00
Stephen Kelly 416df93aa9 Convert some raw loops to cmWrap. 2015-02-20 21:36:57 +01:00
Stephen Kelly a281809384 Use cmJoin where possible. 2015-02-20 21:26:18 +01:00
Brad King ffc06c1239 Teach find_(library|file|path) to get prefixes from PATH (#15370)
The find_package command already knows how to compute installation
prefixes from PATH.  Use the same approach to establish prefixes for
find_library, find_file, and find_path to use to look in directories
like "<prefix>/lib[/<arch>]" and "<prefix>/include" for libraries and
headers.  This will reduce the amount of configuration end users need to
do to establish a work environment rooted under a specific prefix.
2015-02-19 10:03:17 -05:00
Stephen Kelly 0ea719326e cmFindBase: Replace loop with cmJoin on range. 2015-02-11 22:58:08 +01:00
Stephen Kelly 930bd47816 Replace 'foo.size() == 0' pattern with foo.empty(). 2015-01-18 14:25:24 +01:00
Stephen Kelly 238dd2fbab Use insert instead of a loop in some cases.
Limit this change to inserting into a vector from a vector.

A follow up change can use insert for inserting into a set.
2015-01-11 17:00:55 +01:00
Chuck Atkins 1abd7cd930 Use containers of labeled search paths instead of individual members
Manage classes of search paths in labeled containers.  This removes the
need to have a seperate member variable for each type of search path, but
also allows path types to be grouped togethor in various different ways
and manipulated as subsets of the full set of search paths.
2014-11-12 08:21:46 -05:00
Chuck Atkins 2a9ac4bd83 Encapsulate search path manipulation functions into a seperate class.
The functions for adding the various different types of paths have been
factored out into a new class, cmSearchPath.  It is to be used as a helper
container class for the various find_* commands.
2014-11-11 13:39:51 -05:00
Chuck Atkins 32922840e7 Refactor and seperate search path construction for find commands
Prior to this commit, the set of search paths to traverse for find commands
was incrementally constructed.  This change allows each group of paths, i.e.
CMakeVariablePaths, UserHintsPaths, SystemEnvironmentPaths, etc. to be
constructed and manipulated independently, and then all combined togethor.
2014-11-11 13:39:51 -05:00
Stephen Kelly 21c573f682 Remove some c_str() calls.
Use the clang RemoveCStrCalls tool to automatically migrate the
code. This was only run on linux, so does not have any positive or
negative effect on other platforms.
2014-03-11 15:03:50 +01:00
Ben Boeckel 3742bb0d32 stringapi: Use strings for variable names
Variable names are always generated by CMake and should never be NULL.
2014-03-08 13:05:28 -05:00
Brad King 7d47c69365 Drop compatibility with CMake < 2.4
Drop all behavior activated by setting CMAKE_BACKWARDS_COMPATIBILITY to
a value lower than 2.4, and generate an error when projects or the user
attempt to do so.  In the error suggest using a CMake 2.8.x release.

Teach cmake_minimum_required to warn about projects that do not require
at least CMake 2.4.  They are not supported by CMake >= 3.0.

Replace the documentation of CMAKE_BACKWARDS_COMPATIBILITY with a
reference to policy CMP0001.
2013-10-23 08:54:31 -04:00
Brad King e33d8d2d77 Drop builtin command documentation
Drop all GetTerseDocumentation and GetFullDocumentation methods from
commands.  The command documentation is now in Help/command/*.rst files.
2013-10-16 09:22:36 -04:00
Brad King b96f6fc2aa Teach find_(path|file) about Linux multiarch (#13742)
Implement support for multiarch include directories as specified here:

  https://wiki.ubuntu.com/MultiarchCross

Generalize the multiarch feature added in commit b41ad3b3 (Teach
find_(library|package) about Linux multiarch, 2011-06-08) to the
find_path and find_file commands.  Teach them to search
<prefix>/include/<arch> whenever they would search <prefix>/include.
2012-11-26 16:46:04 -05:00
Brad King 66759eea5e find_library: Optionally consider all names in each directory
When more than one value is given to the NAMES option this command by
default will consider one name at a time and search every directory for
it.  Add a NAMES_PER_DIR option to tell this command to consider one
directory at a time and search for all names in it.
2012-09-25 17:08:08 -04:00
Kitware Robot 7bbaa4283d Remove trailing whitespace from most CMake and C/C++ code
Our Git commit hooks disallow modification or addition of lines with
trailing whitespace.  Wipe out all remnants of trailing whitespace
everywhere except third-party code.

Run the following shell code:

git ls-files -z -- \
 bootstrap doxygen.config '*.readme' \
 '*.c' '*.cmake' '*.cpp' '*.cxx' \
 '*.el' '*.f' '*.f90' '*.h' '*.in' '*.in.l' '*.java' \
 '*.mm' '*.pike' '*.py' '*.txt' '*.vim' |
egrep -z -v '^(Utilities/cm|Source/(kwsys|CursesDialog/form)/)' |
egrep -z -v '^(Modules/CPack\..*\.in)' |
xargs -0 sed -i 's/ \+$//'
2012-08-13 14:18:39 -04: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 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
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 183d261b11 Fix find_* argument parsing crash (#11513)
Previously the command

  find_path(VAR DOC "")

would crash because the argument pre-processing removed the DOC ""
arguments but the rest of the parsing assumes at least 2 arguments.
Reject the call with an error instead.
2010-11-30 08:39:16 -05: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
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 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 9b8d30081c ENH: Clarify PATH_SUFFIXES documentation
This clarifies documentation of the find_* commands' PATH_SUFFIXES
option.  The option adds paths with the suffixes but does not remove the
paths without the suffixes.
2008-10-14 08:43:19 -04:00
Brad King c1075aef7b BUG: Fix find_* search order with path suffixes
In cmFindBase we were searching all path suffixes appended to all paths
before considering the paths without any suffixes.  Instead we should
consider each path with and without suffixes before moving to the next
path.  See issue #7783.
2008-10-13 09:58:22 -04:00
Brad King 4543a3ea05 BUG: In find_* commands support NO_* options in short-hand
- The short-hand forms do not document the NO_* options.
  - CMake 2.4 and 2.6.0 accepted them accidentally, but also
    treated the options as paths.
  - Now the options are accepted but do not become paths.
2008-06-10 13:22:18 -04:00
Brad King d50785e26e ENH: Make find_* command search order more intuitive.
- The CMAKE_PREFIX_PATH and similar variables have both
    environment and CMake cache versions.
  - Previously the environment value was checked before the
    cache value.
  - Now the cache value is favored because it is more specific.
2008-06-09 15:22:09 -04:00
Brad King 5b406c9044 ENH: Add HINTS option to find_* commands.
- Hints are searched after user locations but before system locations
  - The HINTS option should have paths provided by system introspection
  - The PATHS option should have paths that are hard-coded guesses
2008-06-09 15:08:59 -04:00
Brad King 6706f84cd9 ENH: Refactor find_* command framework/appbundle search order impl.
- CMAKE_FIND_FRAMEWORK and CMAKE_FIND_APPBUNDLE are supposed to specify
    whether to find frameworks/appbundles FIRST, LAST, ONLY, or NEVER.
  - Previously this affected only the placement of CMAKE_FRAMEWORK_PATH
    and CMAKE_APPBUNDLE_PATH with respect to the other path specifiers.
  - Now it behaves as documented.  The entire search path is inspected for
    each kind of program, library, or header before trying the next kind.
  - Additionally the ONLY mode is now honored for headers so that users
    do not end up with a library in framework and a header from elsewhere.
2008-06-09 11:58:29 -04:00
Brad King d53e5dec37 ENH: In find_* implementation centralize addition of trailing slashes
- Create cmFindCommon::AddTrailingSlashes
  - Use it in cmFindBase and cmFindPackageCommand
  - Remove duplication from other find commands
2008-06-09 11:57:56 -04:00
Brad King abb1c0e25e BUG: Fix find_* command calls with no PATHS but new-style options.
- In cmFindBase when CheckCommonArgument returns true, set newStyle
  - Otherwise if there are no PATHS then the ancient-style compatibility
    mode is enabled and the common argument is treated as a path.
2008-06-08 11:41:08 -04:00
Brad King 3c8ed0d600 BUG: Fix cmFindBase::AddMacPath to actually use its arguments after previous refactoring commit. 2008-06-06 09:06:27 -04:00
Brad King 789c167b6f ENH: Refactor cmFindCommon, cmFindBase, and cmFindPackageCommand
- Add each part of the search order in a separate method.
  - Collect added paths in an ivar in cmFindCommon.
  - Move user path storage up to cmFindCommon and share
    between cmFindBase and cmFindPackageCommand.
  - Expand user path registry values up in cmFindCommon
    - Enables 32-/64-bit registry view for find_package
    - Disables registry expansion for paths not specified
      with the PATHS argument, which is not expected.
2008-06-05 18:20:16 -04:00
Brad King a9a33a5c5e BUG: Fix 64-bit build of CMake so it can find 32-bit VS install.
- cmFindBase should search both 32-bit and 64-bit registry views
    for FIND_PROGRAM even if CMAKE_SIZEOF_VOID_P is not set.
  - Needed because the variable is not available when CMAKE_MAKE_PROGRAM
    is to be found.
2008-06-05 09:54:28 -04:00