Commit Graph

148 Commits

Author SHA1 Message Date
Brad King
f0e67da061 target_link_libraries: Fix out-of-dir linking of a list of targets
In a case like

    target_link_libraries(targetInOtherDir PUBLIC "$<1:a;b>")

then all entries in the list need to be looked up in the caller's
scope.  Previously our `::@(directory-id)` suffix would apply only
to the last entry.  Instead surround the entire entry by a pair
`::@(directory-id);...;::@` so that the `::@` syntax can encode
a directory lookup scope change evaluated as the list is processed.

Fixes: #20204
2020-01-16 13:24:27 -05:00
Brad King
ba675f1ecc Tests: Enable CMP0022 in ExportImport out-of-dir linking case
Since out-of-dir linking is enabled by CMP0079, which is newer than
CMP0022, it is likely that both will be set in practice when out-of-dir
linking is used.
2020-01-14 15:27:07 -05:00
Joseph Snyder
c621839bd9 Add set_property option: DEPRECATION
Add a new property flag for a target which contains a message regarding
deprecation status.

Add a warning at "Generate" time if a linked target is marked as
deprecated.

Expand ExportImport test to ensure that new property is being set and
passed correctly.  Ensure that the message is shown during the
"Generate" step run of the ExportImport test.
2020-01-02 17:11:31 -05:00
Robert Maynard
2467a2b318 CUDA: Add cuda meta-features (e.g. `cuda_std_11`) support 2019-12-10 17:56:48 -05:00
Kyle Edwards
5695b0464b Merge topic 'cmake-e-rm'
2d0100fac7 replace remove and remove_directory with rm in tests
5239fc5c75 cmake -E: Add rm with improved semantics over remove and remove_directory

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3949
2019-11-15 09:57:56 -05:00
Johnny Jazeix
2d0100fac7 replace remove and remove_directory with rm in tests 2019-11-13 18:02:18 -05:00
Brad King
77a8f9ecbc Tests: Fix ExportImport PCH expectation on Cray Classic compiler
Do not expect PCH-included definitions for this compiler.
2019-11-11 11:18:35 -05:00
Brad King
0e436c573c install,export: Do not treat language names as target names
When generating `IMPORTED_LINK_INTERFACE_LANGUAGES`, do not treat the
entries as target names.

Fixes: #19846
2019-10-16 12:48:20 -04:00
Brad King
3ded5b6da8 install,export: Fix export of a genex following $<INSTALL_PREFIX>
The relative path check added by commit 5838aba1aa (Export: Report error
on relative include with genex., 2013-11-26, v3.0.0-rc1~285^2) was added
one condition too early.  If the value starts in `${_IMPORT_PREFIX}`
(which comes from `$<INSTALL_PREFIX>`) then it is an absolute path.

Fixes: #19791
2019-10-04 09:53:22 -04:00
Kitware Robot
ed98209ddc Revise include order using clang-format-6.0
Run the `clang-format.bash` script to update our C and C++ code to a new
include order `.clang-format`.  Use `clang-format` version 6.0.
2019-10-01 12:26:36 -04:00
Brad King
c54448e185 PCH: Propagate INTERFACE_PRECOMPILE_HEADERS in install(EXPORT)
This was accidentally left out of commit 0467a2f91b (PCH: add
PRECOMPILE_HEADERS to special properties, 2015-03-12).  Also add a test
case for `install(EXPORT)` and `export()` propagation of precompiled
headers.

Fixes: #19741
2019-09-25 12:06:28 -04:00
Brad King
73a829e078 InterfaceLibrary: Whitelist EXPORT_PROPERTIES property
Fixes: #19261
2019-05-17 09:20:04 -04:00
Zsolt Parragi
091afa7342 Tests: Teach tests when to treat clang-cl as MSVC
* Disable the system include unused variable test in ExportImport when
  clang is in MSVC compatible mode.

* Disable CxxDialect testcase when clang is in MSVC compatible mode, as
  it doesn't support `typeof`.

* Teach Module.WriteCompilerDetectionHeader to treat clang-cl as MSVC.

* Disable the SystemIncludeDirectories testcase within
  IncludeDirectories when clang is in MSVC compatible mode.

* Disable the CMakeOnly.CheckCXXCompilerFlag testcase when clang is in
  MSVC compatible mode.

* Treat clang-cl as MSVC in LinkOptions.cmake in the try_run and
  try_compile testcases.
2019-02-11 15:04:28 +01:00
Brad King
beb991110d Remove now-unused code once used on IRIX
We dropped support for IRIX as a host platform long ago.
Remove some leftover code.
2019-01-11 13:50:46 -05:00
Marc Chevrier
a71caab46b LINK_DIRECTORIES: Add new properties and commands
These new capabilities enable to manage link directories

Two new properties:
* target properties: LINK_DIRECTORIES and INTERFACE_LINK_DIRECTORIES

One new command
* target_link_directories(): to populate target properties

Fixes: #17215
2018-09-25 23:59:58 +10:00
Brad King
a1ad0a699b target_link_libraries: Allow use with targets in other directories
Previously the command did not allow naming targets on the LHS that
were not created in the calling directory.  Lift this restriction to
enable more flexible use by projects.

Targets named on the RHS will need to be looked up during generation in
the scope of the call site rather than the scope of the LHS target.
Introduce an internal syntax in `[INTERFACE_]LINK_LIBRARIES` properties
to specify target names that need to be looked up in a directory other
than that containing the target on which the property is set.  Add
minimal documentation of the syntax to help users that encounter it.

Unfortunately CMake previously did allow such calls in the case that
only `INTERFACE` libraries are specified, but those libraries would be
looked up in the target's directory rather than the caller's.  Add
policy `CMP0079` to enable the new behavior with new lookup scope in a
compatible way.

Fixes: #17943
2018-09-12 13:06:36 -04:00
Kyle Edwards
5a7a006fdd Tests: Add test for $<0:...> in ExportImport
This test case already includes test cases for $<1...> and $<0...>,
but this commit adds a few $<0:...>'s in cases where it was missing.
2018-07-17 09:07:02 -04:00
Marc Chevrier
cc9f88af53 LINK_DEPENDS: add support for property INTERFACE_LINK_DEPENDS
Fixes: #17997
2018-06-27 18:38:36 +02:00
Marc Chevrier
c1f5a44b28 LINK_OPTIONS: Add new family of properties
This family enable to manage link flags

Three new properties:
* directory property: LINK_OPTIONS
* target properties: LINK_OPTIONS and INTERFACE_LINK_OPTIONS

Two new commands
* add_link_options(): to populate directory property
* target_link_options(): to populate target properties

Fixes: #16543
2018-06-06 17:22:39 +02:00
Kitware Robot
d7204e649e Revise C++ coding style using clang-format-6.0
Run the `clang-format.bash` script to update all our C and C++ code to a
new style defined by `.clang-format`.  Use `clang-format` version 6.0.

* 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.
2018-06-01 09:53:42 -04:00
Wouter Klouwen
6db61f0725 Export: allow exporting of additional properties
This change introduces an additional property that may be set on a
target to allow additional properties to be exported. Normally only a
limited number of properties are exported.

Additional properties may be exported by simply setting the
`EXPORT_PROPERTIES` property on a target that is exported.
2018-03-16 09:00:56 -04:00
Brad King
7776ce98c3 Tests: Add cases for usage requirements of linked object libs
Add tests to cover transitive usage requirements on installation and
export of targets that link to object libraries.

Issue: #14778
2018-03-01 09:28:00 -05:00
Brad King
ea0ce73a19 install,export: Maybe transform OBJECT libraries to INTERFACE libraries
Teach the `install` and `export` commands to support installing and
exporting `OBJECT` libraries without their object files.  Transform
them to `INTERFACE` libraries in such cases.

For `install(TARGETS)`, activate this when no destination for the object
files is specified.  For `export`, activate this only under Xcode with
multiple architectures when we have no well-defined object file
locations to give to clients.
2018-02-28 10:58:10 -05:00
Craig Scott
c267ea1c3e GENERATOR_IS_MULTI_CONFIG: Use for multi-config checks in Tests 2017-12-30 09:35:56 +11:00
Craig Scott
94cd4505f7 Tests: Make function name not match SONAME
We look for `SONAME` in the output of `readelf` to check whether the
binary contains the field.  Do not provide a symbol that may
accidentally match.

Fixes: #16894
2017-05-18 10:26:09 -04:00
Robert Maynard
eec93bceec Allow OBJECT libraries to be installed, exported, and imported
Teach install() and export() to handle the actual object files.
Disallow this on Xcode with multiple architectures because it
still cannot be cleanly supported there.

Co-Author: Brad King <brad.king@kitware.com>
2017-04-18 11:36:10 -04:00
Robert Maynard
8577978c58 Tests: ExportImport C code should use explicit (void) in prototypes 2017-04-18 09:03:34 -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
Brad King
b42866a34a Drop Visual Studio 6 generator
This generator has been deprecated since CMake 3.3.  Remove it.
Update documentation, modules, and tests to drop content specific
to this generator.
2016-03-09 09:42:18 -05:00
Brad King
aea1b03617 Fix export of STATIC library PRIVATE dependencies with CMP0022 NEW
The target_link_libraries command records the PRIVATE dependencies of a
STATIC library in INTERFACE_LINK_LIBRARIES as "$<LINK_ONLY:dep>".  This
hides the target name from export namespacing logic inside a generator
expression.  When user-written generator expressions reference a target
name they must put it inside a "$<TARGET_NAME:dep>" expression to allow
the export logic to rename the target.  In the case that the private
dependency is not already a generator expression, target_link_libraries
must use "$<LINK_ONLY:$<TARGET_NAME:dep>>" to allow the export logic to
rename the target.

Reported-by: Tamás Kenéz <tamas.kenez@gmail.com>
2016-01-15 10:18:53 -05:00
Brad King
e5cbec14a5 Tests: Use CMP0022 NEW behavior in some ExportImport cases 2016-01-15 09:56:01 -05:00
Brad King
0ca122fcb3 Tests: Isolate policy changes in ExportImport test
Use cmake_policy(PUSH/POP) to isolate CMP0022 policy changes.
2016-01-15 09:55:26 -05:00
Yves Frederix
630c8aa843 install: Allow generator expressions in DIRECTORY
Teach install(DIRECTORY) to support generator expressions in the list
of directories, much like install(FILES) already supports.
2016-01-13 09:02:06 -05:00
Brad King
ac5ead4a9c Merge topic 'test-fix-C-comments'
4eb77a1c Tests: Use C-Style comments in C sources and headers
2015-09-28 10:44:46 -04:00
Marc Chevrier
4eb77a1c1d Tests: Use C-Style comments in C sources and headers
Not all C compilers tolerate C++-style comments in C code, so do not use
them in our tests.
2015-09-25 09:34:04 -04:00
Robert Goulet
bd189cc24e install: Allow generator expressions in DIRECTORY DESTINATION 2015-09-24 09:13:03 -04:00
Brad King
69ab5f5502 Tests: Cover install(FILES) with a genex DESTINATION 2015-09-23 14:41:52 -04:00
Raphael Kubo da Costa
21d99aa345 Tests: Use a less strict regular expression to look for "SONAME"
Commit 899458ab (Tests: Cover NO_SONAME property for SHARED libraries,
2015-08-20) introduced a few new ExportImport tests, and the
check_lib_{no}soname.cmake scripts that parse readelf(1)'s output.

Make the regular expression matching the SONAME line output by readelf
less strict, as the output format varies across implementations: GNU
binutils' readelf is the only one to write each ELF header within
parentheses (which the previous regular expression expected).  The new
tests were thus failing when either Fedora's elfutils (eu-readelf) or
elftoolchain's readelf (present on recent FreeBSD versions) were being
used, as they both list the headers without parentheses.

The same issue also affected Tests/Plugin's check_mod_soname.cmake, so
fix that one as well -- the only reason the test was not failing is that
it tested that the regular expression did not match, which was always
the case with a non-binutils readelf.
2015-09-01 10:30:09 -04:00
Brad King
899458ab20 Tests: Cover NO_SONAME property for SHARED libraries
This property was added by commit v2.8.9~204^2~2 (Support building
shared libraries or modules without soname, 2012-04-22).  A test for
using the property on MODULE libraries was added by commit
v2.8.9~204^2~1 (Test NO_SONAME property, 2012-04-23).  Add such a test
for SHARED libraries too.
2015-08-20 10:38:34 -04:00
Robert Goulet
d25819bc26 Add generator expression support to OUTPUT_DIRECTORY target properties
If {ARCHIVE,LIBRARY,RUNTIME}_OUTPUT_DIRECTORY is set with a genex then
do not add the per-config subdirectory on multi-config generators.
This will allow projects to use $<CONFIG> to place the per-config
part of the directory path somewhere other than the end.
2015-08-12 13:43:00 -04:00
Robert Goulet
809159c9b7 Add generator expression support to OUTPUT_NAME target property 2015-07-09 11:48:10 -04:00
Brad King
60eb396f10 Export: Escape exported property values when writing CMake language files
When writing export files, correctly encode property values that contain
characters special to the CMake language parser.  We must ensure that
they parse correctly when loaded on the consuming side.

Reported-by: Dan Liew <dan@su-root.co.uk>
2015-06-24 09:19:39 -04:00
Brad King
4fc4742477 Tests: Fix ExportImport on AIX with GCC
The iface_test_bld gets the excludedFromAll include directory with
"-isystem" because it is added indirectly through an imported target.
On AIX with GCC the -isystem flag causes sources to be preprocessed as:

  # 3 "/.../excludedFromAll.h" 2 3 4

The flags after the file name are documented here:

  https://gcc.gnu.org/onlinedocs/cpp/Preprocessor-Output.html

and the "4" flag says that following content is extern "C".  This
causes the excludedFromAll function to be declared as a C symbol
and not mangled for C++, which fails to link later because the
symbol is really provided as C++.

Work around this by setting the NO_SYSTEM_FROM_IMPORTED target property
on iface_test_bld.  Somehow iface_test_exp does not end up with -isystem
so we do not need this workaround for that target.
2015-04-23 10:53:39 -04:00
Brad King
f30022eb07 install: Allow generator expressions in TARGETS DESTINATION (#14317)
This will allow per-config destinations for targets in EXPORT sets.
Using multiple install(TARGETS) with separate CONFIGURATIONS is
rejected as a target appearing more than once in an export set.
Now instead one can write

 install(TARGETS foo EXPORT exp DESTINATION lib/$<CONFIG>)

to get a single logical membership of the target in the export set
while still having a per-config destination.
2015-02-11 15:15:33 -05: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
Matt McCormick
d0adcccbf4 try_run: Add tests for LINK_LIBRARIES with mock libraries.
Extend the ExportImport test to try using an imported library with
try_run.
2015-01-26 10:05:59 -05:00
Brad King
dd089e08b5 install: Allow absolute EXPORT destination with relative targets (#15258)
When install(EXPORT) is given an absolute destination we cannot compute
the install prefix relative to the installed export file location.
Previously we disallowed installation of targets in such exports with a
relative destination, but did not enforce this for target property
values besides the location of the main target file.  This could lead to
broken installations when the EXPORT is installed to an absolute path
but usage requirements are specified relative to the install prefix.

Since an EXPORT installed to an absolute destination cannot be relocated
we can just hard-code the value of CMAKE_INSTALL_PREFIX as the base for
relative paths.  This will allow absolute install(EXPORT) destinations
to work with relative destinations for targets and usage requirements.

Extend the ExportImport test with a case covering this behavior.
2014-12-15 11:45:49 -05:00
Brad King
09ab207c66 Tests: Add generator platform support
Propagate CMAKE_GENERATOR_PLATFORM through the test hierarchy so that all
tests can build with the selected generator platform, if any.
2014-09-10 11:21:50 -04:00
Stephen Kelly
e0890d03a4 Features: Extend concept to C language.
Add properties and variables corresponding to CXX equivalents.

Add features for c_function_prototypes (C90), c_restrict (C99),
c_variadic_macros (C99) and c_static_assert (C11). This feature
set can be extended later.

Add a <PREFIX>_RESTRICT symbol define to WriteCompilerDetectionHeader
to conditionally represent the c_restrict feature.
2014-05-15 00:15:18 +02:00