Commit Graph

173 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 60ebd0acf8 Merge topic 'size-empty'
73f648f1 use empty method to check for emptyness
2016-09-16 10:21:39 -04:00
Daniel Pfeifer 73f648f167 use empty method to check for emptyness 2016-09-15 23:59:29 +02:00
Pierluigi Taddei 31be918b0b find_package: Optionally sort globbed directories in a meaningful order
Add `CMAKE_FIND_PACKAGE_SORT_{ORDER,DIRECTION}` variables to specify
sort order and direction.

When multiple package with the same name have been found in the same
location sorting option can be used to force a specific version to be
loaded (e.g. libA_1.12.0 instead of libA_1.1.0).  Currently sorting by
NAME and by NATURAL order have been implemented.

Natural ordering makes use of the `strverscmp(3)` ordering.
2016-09-15 13:35:25 -04:00
Silvio Traversaro 828d6c137d find_package: Extend search path for combined Windows/UNIX convention
Find packages that install their cmake package configuration files in
`lib/cmake/<name>` when they are installed in the default Windows
CMAKE_INSTALL_PREFIX, `C:/Program Files/<name>`.

Closes: #16212
2016-08-24 09:40:25 -04:00
Dāvis Mosāns b1f87a50b3 Use better KWSys SystemTools::GetEnv and HasEnv signatures 2016-07-18 09:51:01 -04:00
Brad King b5ec5b0901 Avoid using KWSys auto_ptr by adopting it ourselves
Replace use of cmsys::auto_ptr with a CM_AUTO_PTR macro that maps to
our own implementation adopted from the KWSys auto_ptr implementation.
Later we may be able to map CM_AUTO_PTR to std::auto_ptr on compilers
that do not warn about it.

Automate the client site conversions:

    git grep -l auto_ptr -- Source/ | grep -v Source/kwsys/ | xargs sed -i \
      's|cmsys::auto_ptr|CM_AUTO_PTR|;s|cmsys/auto_ptr.hxx|cm_auto_ptr.hxx|'
2016-06-29 09:47:58 -04:00
Daniel Pfeifer 1d6909a287 use CM_NULLPTR 2016-06-28 09:02:26 -04:00
Daniel Pfeifer a7a9239096 mark functions with CM_OVERRIDE 2016-06-27 23:24:38 +02:00
Brad King ce62454019 Merge topic 'find_package-duplicate-search-paths'
919db25c cmFindPackageCommand: remove duplicate paths from error message
ebf18df5 cmFindPackageCommand: use iterators to loop over configurations
2016-06-16 09:46:42 -04:00
Ben Boeckel 919db25c3b cmFindPackageCommand: remove duplicate paths from error message
Fixes #15252.
2016-06-13 11:16:12 -04:00
Ben Boeckel ebf18df580 cmFindPackageCommand: use iterators to loop over configurations 2016-06-13 11:16:10 -04:00
Daniel Scharrer 896ad251de Teach find_library and find_package to search lib32 paths (#11260)
Add a ``FIND_LIBRARY_USE_LIB32_PATHS`` global property analogous to the
``FIND_LIBRARY_USE_LIB64_PATHS`` property.  This helps find commands on
multilib systems that use ``lib32`` directories and either do not have
``lib`` symlinks or point ``lib`` to ``lib64``.
2016-06-10 11:09:16 -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 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 64b5520346 Isolate formatted streaming blocks with clang-format off/on
The clang-format tool can do a good job formatting most code, but
well-organized streaming blocks are best left manually formatted.

Find blocks of the form

    os <<
      "...\n"
      "...\n"
      ;

using the command

    $ git ls-files -z -- Source |
      egrep -v -z '^Source/kwsys/' |
      xargs -0 pcregrep -M --color=always -B 1 -A 1 -n \
        '<<[^\n]*\n(^ *("[^\n]*("|<<|;)$|;)\n){2,}'

Find blocks of the form

    os << "...\n"
       << "...\n"
       << "...\n";

using the command

    $ git ls-files -z -- Source |
      egrep -v -z '^Source/kwsys/' |
      xargs -0 pcregrep -M --color=always -B 1 -A 1 -n \
        '<<[^\n]*\n(^ *<<[^\n]*(\\n"|<<|;)$\n){2,}'

Surround such blocks with the pair

    /* clang-format off */
    ...
    /* clang-format on */

in order to protect them from update by clang-format.  Use the C-style
`/*...*/` comments instead of C++-style `//...` comments in order to
prevent them from ever being swallowed by re-formatting of surrounding
comments.
2016-05-06 14:25:55 -04:00
Brad King e1c7747253 Format include directive blocks and ordering with clang-format
Sort include directives within each block (separated by a blank line) in
lexicographic order (except to prioritize `sys/types.h` first).  First
run `clang-format` with the config file:

    ---
    SortIncludes: false
    ...

Commit the result temporarily.  Then run `clang-format` again with:

    ---
    SortIncludes: true
    IncludeCategories:
      - Regex:    'sys/types.h'
        Priority: -1
    ...

Commit the result temporarily.  Start a new branch and cherry-pick the
second commit.  Manually resolve conflicts to preserve indentation of
re-ordered includes.  This cleans up the include ordering without
changing any other style.

Use the following command to run `clang-format`:

    $ git ls-files -z -- \
        '*.c' '*.cc' '*.cpp' '*.cxx' '*.h' '*.hh' '*.hpp' '*.hxx' |
      egrep -z -v '(Lexer|Parser|ParserHelper)\.' |
      egrep -z -v '^Source/cm_sha2' |
      egrep -z -v '^Source/(kwsys|CursesDialog/form)/' |
      egrep -z -v '^Utilities/(KW|cm).*/' |
      egrep -z -v '^Tests/Module/GenerateExportHeader' |
      egrep -z -v '^Tests/RunCMake/CommandLine/cmake_depends/test_UTF-16LE.h' |
      xargs -0 clang-format -i

This selects source files that do not come from a third-party.

Inspired-by: Daniel Pfeifer <daniel@pfeifer-mail.de>
2016-04-29 13:58:54 -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
Brad King 6db713c07f Remove use of include <cmsys/ios/*> and cmsys_ios::*
We no longer need this compatibility layer for the compilers we support.
2015-08-20 16:19:08 -04:00
Brad King 1506f9ca56 find_package: Drop search in recent cmake-gui locations
The find_package command, on Windows, has always searched build trees
recently visited by cmake-gui (or CMakeSetup at one time).  This was
done when the command was created with the intention of simplifying
workflows involving building multiple dependent projects.  However,
this behavior depends on recent developer interaction and therefore
can create different find results based on transient system states.
It can lead to surprising results and user confusion.

Since this behavior was first added CMake has gained many more search
options, better error messages when a package is not found, and a
package registry.  The latter in particular allows projects to make
their build trees available for dependent projects to find without
user intervention.  Therefore the originally intended workflow can
be achieved in other, more stable ways.

After the above evoluion of find_package we have now decided that
the magic search-where-cmake-gui-was behavior does more harm than
good.  Drop it.  We do not need a policy for this behavior change
because it only affects interactive use.
2015-05-08 11:27:02 -04:00
Stephen Kelly 55d80d0a85 cmMakefile: Rename GetCurrent{,Source}Directory.
Match the names used in cmake code.
2015-04-21 00:12:52 +02:00
Stephen Kelly a2f2aeee2f cmMakefile: Add wrapper for reading listfiles which have an origin.
Such files are delegates from other files, and so they set the
CMAKE_PARENT_LIST_FILE to the originator.  They also may set a
policy scope.
2015-04-18 15:29:17 +02:00
Stephen Kelly 5bb4248a80 cmMakefile: Remove fullPath parameter from ReadListFile.
There is no reason for this to be a responsibility of
ReadListFile.  Additionally, the only user of it already computes
it itself.
2015-04-18 15:29:17 +02:00
Stephen Kelly 5d056c0dd8 Port Global property interaction to cmState. 2015-04-15 11:43:50 -04:00
Stephen Kelly f081c5bddd cmState: Move CacheEntryType enum from cmCacheManager. 2015-04-13 11:44:16 -04:00
Bill Hoffman a4a1b729c6 Fix warnings from clang scanbuild. 2015-03-25 12:38:37 -04:00
Stephen Kelly 7916d7bac6 Include cmAlgorithms where it is used. 2015-03-11 00:17:29 +01:00
Stephen Kelly 416df93aa9 Convert some raw loops to cmWrap. 2015-02-20 21:36:57 +01:00
Stephen Kelly 8910224950 Replace common loop pattern with cmJoin 2015-02-11 22:57:55 +01:00
Stephen Kelly fd7b371293 Replace foo.size() pattern with !foo.empty(). 2015-01-18 14:25:24 +01:00
Stephen Kelly d92887efab Replace 'foo.size() > 0' pattern with !foo.empty(). 2015-01-18 14:25:24 +01:00
Brad King b5a467262b Merge topic 'drop-ancient-workarounds'
0f7bdd61 Remove VS 6 special case.
5e92c826 Remove some obsolete stuff.
15e42bb2 cmStandardIncludes: Remove obsolete cmOStringStream.
931e055d Port all cmOStringStream to std::ostringstream.
f194a009 Remove unused cmIStringStream class.
3ec1bb15 cmStandardIncludes: Remove std namespace hack.
bb3bce70 cmStandardIncludes: Remove ANSI_FOR_SCOPE hack.
28fa4923 cmStandardIncludes: Remove iostreams workaround for obsolete Compaq compiler.
837a8a63 cmStandardIncludes: Drop Comeau-related workaround.
4030ddfd Remove Borland-related undef.
17d6a6fd cmStandardIncludes: Remove comment about Borland.
26fb5011 Drop SGI as a CMake host compiler.
2015-01-12 08:57:39 -05:00
Stephen Kelly 931e055d8c Port all cmOStringStream to std::ostringstream.
All compilers hosting CMake support the std class.
2015-01-11 17:06:03 +01:00
Stephen Kelly 2f7ef7e38d Revert "Misc. fixes for the Oracle / Sun compiler."
This reverts commit 97b65f8156.
2015-01-11 17:00:55 +01:00
Chuck Atkins 97b65f8156 Misc. fixes for the Oracle / Sun compiler.
A few pieces of code have some ambiguous type deduction that seems to
resolve correctly for most compilers but not for the Oracle compiler.
This makes those few instances more explicit.
2014-12-12 10:04:47 -05:00
Stephen Kelly 5eb4d7590e Remove some unneeded c_str calls. 2014-11-23 11:09:54 +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
Nils Gladitz cc1139cc30 strings: Remove redundant calls to std::string::c_str()
Replacements were detected and performed by the clang tool
remove-cstr-calls on a linux build.
2014-10-15 14:54:05 +02: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
Stephen Kelly af8a1643c1 Remove c_str calls when using stream APIs.
Use an ad-hoc clang tool for matching the calls which should be
ported.
2014-03-11 15:03:50 +01: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 270eb96df0 strings: Remove cmStdString references
Casts from std::string -> cmStdString were high on the list of things
taking up time. Avoid such implicit casts across function calls by just
using std::string everywhere.

The comment that the symbol name is too long is no longer relevant since
modern debuggers alias the templates anyways and the size is a
non-issue since the underlying methods are generated since it's
inherited.
2014-03-08 13:05:35 -05: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
Stephen Kelly a6971f6510 FeatureSummary: Don't list transitive package dependencies
Set a global property in the find_package implementation.  Track and
reset that property in the find_dependency macro.  Read the property
in FeatureSummary when determining whether to print output.

This means that packages which are found only as dependencies are not
listed by FeatureSummary, but if a project uses find_package elsewhere
directly, then it will be listed by FeatureSummary.

Suggested-by: Alex Merry

 http://thread.gmane.org/gmane.comp.kde.devel.frameworks/10640
2014-02-03 20:20:42 +01:00
Brad King 855e8759fd Merge topic 'minor-cleanups'
3917d86 Genex: Add a nullary form for CONFIG
5169130 Help: Document the target properties exported to IMPORTED targets.
ee21f1c CompatibleInterface: Test debugging of not-set property.
80e9fe9 Help: Note that language-specific 'built-ins' are set by the project command.
0b5bf8a Help: Mention CMAKE_DISABLE_FIND_PACKAGE_<PackageName> in package docs.
28c865b Tests: simplify Qt4 target usage
6cfe6b8 Help: Fix typo: 'target' -> 'target property'
b7deca4 Test: Remove obsolete commented code.
9c9f69f Genex: Make EQUAL support upper case binary literals
6eb3218 Genex: Fix case of methods in the dag checker.
646c6ec Genex: Use a preprocessor loop to implement transitive DAG check.
711fb38 Genex: List transitive properties and methods as a table, not two lists.
802a28f Add cmHasLiteralSuffix API.
2014-01-07 09:39:22 -05:00
Clinton Stimpson 5730710c86 Use cmsys::[io]fstream instead of cmsys_ios::[io]fstream.
Also use SystemTools::Fopen() instead of fopen().
This is to eventually support utf-8 filenames.
2014-01-07 09:27:44 -05:00