Commit Graph

55 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
Bill Hoffman d5257063b0 Export: Virtualize file generation step helpers
Allow subclasses to override the actual content generation.
2016-09-08 10:37:33 -04:00
Bill Hoffman f81b9475f3 Export: Factor out file generation steps into helpers
Do not actually generate any content in the driving code paths.
Use helpers for that.
2016-09-08 10:37:31 -04:00
Daniel Pfeifer efed6468ed fix a load of include-what-you-use violations 2016-09-03 08:04:56 -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 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
Stephen Kelly d231c31b98 Export: Port internal API to cmGeneratorTarget. 2015-10-18 16:29:30 +02:00
Stephen Kelly e666128243 Export: Port internal utility to cmGeneratorTarget. 2015-10-18 16:29:30 +02:00
Stephen Kelly 2b9cc1e248 Export: Port some API to cmGlobalGenerator. 2015-10-18 16:29:30 +02:00
Stephen Kelly 6a72b3c84e Export: Port interface to cmGeneratorTarget. 2015-10-18 16:29:29 +02:00
Stephen Kelly d560bfd273 cmGeneratorTarget: Move GetInstallNameDir* from cmTarget. 2015-08-05 18:20:47 +02:00
Stephen Kelly c971338416 Export: Port more API to cmGeneratorTarget. 2015-08-05 18:20:44 +02:00
Stephen Kelly 57f03e59ba Port some of the cmExportFileGenerator API to cmGeneratorTarget.
Enough to make it more possible to move GetLinkInterface
to cmGeneratorTarget.
2015-07-27 21:59:03 +02:00
Stephen Kelly 6da65b3907 Allow export of targets with INTERFACE_SOURCES.
Use the same rules for paths in source and binary dirs in
installed INTERFACE_SOURCES as are used for
INTERFACE_INCLUDE_DIRECTORIES.
2015-02-11 00:51:34 +01:00
Brad King edce43514d cmExportFileGenerator: Make SetImportLinkProperty a template
Allow the vector of property entries to have any element type
that can convert to std::string.
2014-06-23 09:22:07 -04:00
Ben Boeckel b3bf31a548 stringapi: Miscellaneous char* parameters 2014-03-08 13:05:37 -05:00
Ben Boeckel 84fdc9921c stringapi: Pass configuration names as strings 2014-03-08 13:05:36 -05: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
Ben Boeckel ec97ed7d0c stringapi: Use strings for property names
Property names are always generated by CMake and should never be NULL.
2014-03-08 13:05:28 -05:00
Brad King 7cbab17871 Change version scheme to use only two components for feature levels
Historically CMake used three version components for the feature level.
We released new features while incrementing only the third version
component.  Since commit v2.8.2~105^2~4 (New version scheme to support
branchy workflow, 2010-04-23) we used the fourth version component for
bug-fix releases and the development date:

 <major>.<minor>.<patch>[.<tweak>][-rc<n>] = Release
 <major>.<minor>.<patch>.<date>[-<id>]     = Development

This solidified use of three components for the feature level, and was
necessary to continue releasing 2.x versions because:

* Some existing projects performed floating-point comparisons of
  ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} to 2.x numbers
  so ``x`` could never be higher than 9.

* Version 2.9.<date> was used briefly in post-2.8.0 development in
  CVS prior to the transition to Git, so using it in releases may
  have caused confusion.

Now that we are moving to 3.x versions, these two restrictions go away.
Therefore we now change to use only two components for the feature
level and use the scheme:

 <major>.<minor>.<patch>[-rc<n>] = Release
 <major>.<minor>.<date>[-<id>]   = Development
2014-02-19 09:30:13 -05:00
Stephen Kelly 6ca6613ab8 Export: Use the CMAKE_DEVEL_VERSION macro for build-export files.
Move the macro definition to the cmExportBuildFileGenerator.h header
to share it.
2014-02-11 16:31:53 +01:00
Stephen Kelly 3429541e1c export: Rename some variables to reflect content type.
This method is used with a list of languages.
2014-01-06 17:25:10 +01:00
Stephen Kelly c4373b33b2 cmTarget: Make GetProperty() const.
This has follow-on effects for other methods and classes. Further
work on making the use of const cmTarget pointers common can be
done, particularly with a view to generate-time methods.
2013-10-31 14:52:11 +01:00
Stephen Kelly 66b290e7e2 export(): Process the export() command at generate time.
Make the API for adding targets string based so that it can easily
use cmGeneratorTarget.

Teach the cmIncludeCommand to generate the exported file at
configure-time instead if it is to be include()d.

The RunCMake.ExportWithoutLanguage test now needs a dummy header.h
file as expected error from export() is now reported after the
missing file error.
2013-10-11 12:46:10 +02:00
Stephen Kelly 650e61f833 Add a convenient way to add the includes install dir to the INTERFACE.
Export the INCLUDES DESTINATION without appending to the
INTERFACE_INCLUDE_DIRECTORIES of the target itself. That way, a target
can be exported multiple times with different INCLUDES DESTINATION
without unintended cross-pollution of export sets.
2013-07-24 17:32:58 +02:00
Stephen Kelly 574fec97fd Export: Generate INTERFACE_LINK_LIBRARIES property on targets.
This property is generated only for targets which have recorded
policy CMP0022 as NEW, and a compatibility mode is added to
additionally export the old interfaces in that case too.

If the old interfaces are not exported, the generated export files
require CMake 2.8.12. Because the unit tests use a version which
is not yet called 2.8.12, temporarily require a lower version.
2013-07-08 22:39:57 +02:00
Clinton Stimpson 8576b3f978 OS X: Add support for @rpath in export files.
Also expand the IMPORTED_SONAME property for targets
to match the install_name.
2013-06-03 09:42:05 -04:00
Stephen Kelly af81a3c31b install(EXPORT): Ensure clean INTERFACE_INCLUDE_DIRECTORIES
Check that source and binary directories are not part of the
INTERFACE_INCLUDE_DIRECTORIES for installed IMPORTED targets.

This is limited to directories which do not contain generator
expressions to evaluate. Such paths can only be checked at time
of use of the imported target, which will be done in a follow up
patch.
2013-03-26 10:45:07 -04:00
Stephen Kelly 3df36b5954 Revert "Add the $<LINKED:...> generator expression."
This reverts commit 0b92602b81.

Conflicts:
	Source/cmGeneratorExpressionEvaluator.cxx
	Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt
	Tests/CMakeCommands/target_include_directories/CMakeLists.txt
2013-02-13 15:12:31 +01:00
Stephen Kelly 0b92602b81 Add the $<LINKED:...> generator expression.
This is both a short form of using a TARGET_DEFINED expression
together with a TARGET_PROPERTY definition, and a way to strip
non-target content from interface properties when exporting.
2013-01-31 17:34:20 +01:00
Stephen Kelly 34d1ade048 Add the INSTALL_PREFIX genex. 2013-01-27 09:59:26 +01:00
Stephen Kelly 830246e841 Export the COMPATIBLE_INTERFACE_BOOL content properties 2013-01-21 09:05:03 +01:00
Stephen Kelly 522bdac149 Export the INTERFACE_PIC property. 2013-01-15 14:36:22 -05:00
Stephen Kelly cfd4f0a4f4 Move the exported check for dependencies of targets
Check only once, in the Config.cmake file, instead of once in each
Config-<cfg>.cmake file.
2013-01-15 14:36:21 -05:00
Stephen Kelly 94aeaf72c7 Split LINK_INTERFACE_LIBRARIES export handling into dedicated method. 2013-01-10 18:06:57 +01:00
Stephen Kelly a3aedb8152 Split the generator expression before extracting targets.
Now that we're processing a LINK_INTERFACE_LIBRARIES string, it
can contain targets. Make sure they are extracted for
namespacing purposes.

This needs to be restricted to strings which can actually have
targets named in them. For example, this is not done for
INTERFACE_COMPILE_DEFINITIONS, because even if there is a target
named 'foo', the string 'foo' in that property means that '-Dfoo'
will be set when compiling.
2013-01-10 18:06:57 +01:00
Stephen Kelly b6036d104a Extract the AddTargetNamespace method. 2013-01-10 18:06:03 +01:00
Stephen Kelly 0c657dc637 Add API to populate INTERFACE properties in exported targets.
The INTERFACE properties need to be preprocessed for context (build
location or install location) and to extract target names etc.
2013-01-05 01:18:36 +01:00
Stephen Kelly e04f737c7a Add API to extract target names from a genex string.
The TARGET_NAME expression, which requires a literal, provides
target names. $<TARGET_PROPERTY:tgt,prop> also provides target
names in the cases where tgt is a literal, so that TARGET_NAME is
not needed then in addition.
2013-01-05 01:18:36 +01:00
Stephen Kelly bf2ddceb4e Generate an early-return guard in target Export files.
Previously it was necessary for writers of Config files
which incude exported target files to write the guard themselves, but
this was not immediately obvious or documented. Options for them
would be to use a variable, or an INHERITED directory property in an
effort to avoid accidental name clashes in all contexts in
which find_package can be used.

Getting this right requires boiler plate code, so generate a simpler
check automatically instead.
2012-11-30 09:51:17 +01:00
Alex Neundorf 0cfd055acd exports: move the handling of missing targets into subclasses
Before, cmExportFileGenerator::ComplainAboutMissingTarget() was a virtual
function which had to be implemented in the subclasses. It is not
anymore. Instead, there is now a virtual function
HandleMissingTargets(), which is implemented in the two subclasses.
This makes e.g. dealing correctly with APPEND mode easier.

Alex
2012-09-30 10:26:10 -04:00
Alex Neundorf 8b5f448ba6 exports: first try at error handling if a target is missing
Now, if an imported target depends on a library which must come
from some other export set, cmake generates a check which errors
out if that target does not exist. I guess instead of completely
erroring out it would be better to only make the find_package() fail.

Alex
2012-09-28 09:21:42 -04:00
Alex Neundorf 87f4c01910 exports: accept a missing target if it is exported exactly once
If a target is exported, and a library it depends on is not part
of the same export set, before this patch cmake errored out.
With this patch, it now checks whether the missing target
is exported somewhere else exactly once, and accepts in this
case (because then it can determine the namespace for the
missing target and use this).

Alex
2012-09-28 09:21:42 -04:00
Alex Neundorf a2be068c75 install(EXPORT): Enforce existence of imported target files
Typical <package>Config.cmake files for find_package() rely only on the
files generated by install(EXPORT).  They might be wrong, for whatever
reasons, like people manually deleted files, projects were packaged
wrong by distributions, whatever.  To protect against this, add checks
that the file locations we are importing actually exist on disk.

Alex
2011-11-22 15:55:00 -05: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 06b0a692f4 ENH: Centralize default link interface computation
When LINK_INTERFACE_LIBRARIES is not set we use the link implementation
to implicitly define the link interface.  These changes centralize the
decision so that all linkable targets internally have a link interface.
2009-07-06 16:25:20 -04:00
Brad King 82fcaebe28 ENH: Pass dependent library search path to linker on some platforms.
- Move runtime path ordering out of cmComputeLinkInformation
    into its own class cmOrderRuntimeDirectories.
  - Create an instance of cmOrderRuntimeDirectories for runtime
    path ordering and another instance for dependent library
    path ordering.
  - Replace CMAKE_DEPENDENT_SHARED_LIBRARY_MODE with explicit
    CMAKE_LINK_DEPENDENT_LIBRARY_FILES boolean.
  - Create CMAKE_LINK_DEPENDENT_LIBRARY_DIRS boolean.
  - Create variables to specify -rpath-link flags:
      CMAKE_SHARED_LIBRARY_RPATH_LINK_<LANG>_FLAG
      CMAKE_EXECUTABLE_RPATH_LINK_<LANG>_FLAG
  - Enable -rpath-link flag on Linux and QNX.
  - Documentation and error message updates
2008-02-01 08:56:00 -05:00
Brad King 2cff26fa52 ENH: Support linking to shared libs with dependent libs
- Split IMPORTED_LINK_LIBRARIES into two parts:
      IMPORTED_LINK_INTERFACE_LIBRARIES
      IMPORTED_LINK_DEPENDENT_LIBRARIES
  - Add CMAKE_DEPENDENT_SHARED_LIBRARY_MODE to select behavior
  - Set mode to LINK for Darwin (fixes universal binary problem)
  - Update ExportImport test to account for changes
2008-01-31 15:45:31 -05:00
Brad King 73a5f0846f COMP: Remove unused parameter. 2008-01-31 06:51:43 -05:00