1200 Commits

Author SHA1 Message Date
Jiang Yue
f08dcbffec Property: Add INSTALL_REMOVE_ENVIROMENT_RPATH property 2019-07-25 12:30:23 -04:00
Brad King
2fa920c0cd AIX: Create import library for executables with exports
On AIX, plugins meant to be loaded into executables via `dlopen` must be
linked with access to a list of symbols exported from the executable in
order to use them (when not using runtime linking).  The AIX linker
supports specifying this list as an "import file" passed on the command
line either via the `-bI:...` option or (with a leading `#! .` line) as
a normal input file like any other library file.

The linker import file plays the same role on AIX as import libraries do
on Windows.  Teach CMake to enable its import library abstraction on AIX
for executables with the `ENABLE_EXPORTS` target property set.  Teach
our internal `ExportImportList` script to optionally generate a leading
`#! .` line at the top of the generated export/import list.  Update our
rule for linking an executable with exports to generate a public-facing
"import library" implemented as an AIX linker import file.

With this approach, our existing infrastructure for handling import
libraries on Windows will now work for AIX linker import files too:

* Plugins that link to their executable's symbols will be automatically
  linked using the import file on the command line.

* The executable's import file will be (optionally) installed and
  exported for use in linking externally-built plugins.

This will allow executables and their plugins to build even if we later
turn off runtime linking.

Issue: #19163
2019-07-16 14:15:13 -04:00
Brad King
9f5c2040bf AIX: Explicitly compute executable exports for both XL and GNU
On AIX, symbols in executables must be exported in order to be visible
to modules (plugins) they load via `dlopen`.  Prior to policy `CMP0065`,
CMake linked all executables with flags to export symbols, but the NEW
behavior for that policy is to do so only for executables that have the
`ENABLE_EXPORTS` target property set.  In both cases, CMake has always
used the AIX linker option `-bexpall` option to export symbols from
executables.

This has worked fairly well with the XL compiler, but with the GNU
compiler it works only for C ABI symbols.  The reason is that `-bexpall`
does not export symbols starting in `_` but the GNU C++ ABI mangles all
symbols with a leading `_`.  Therefore we have only supported C ABI
plugins with the GNU compiler on AIX.  Some projects have tried to work
around this by replacing `-bexpall` with `-bexpfull`, but the latter
often exports symbols that we do not want exported.

Avoid using `-bexpall` for executables by instead using by our own
internal `ExportImportList` script to compute symbol export lists from
the object files to be linked into an executable.  Pass the explicitly
computed export list to the AIX linker's `-bE:...` option.  We already
do this for shared object exports.

Issue: #19163
2019-07-15 13:27:16 -04:00
Brad King
d7e53b4274 Merge topic 'cleanup-gen-lookups'
7ff9ab3b10 Makefile: De-duplicate executable link rule lookup
79f5ef19fe De-duplicate checks for whether a platform uses Windows DLLs
22d3eb5d5e Refactor checks for whether a target has an import library

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3550
2019-07-15 07:41:52 -04:00
Marc Chevrier
d9b2c7dae2 Introduce memory management helper: cm_memory.hxx 2019-07-14 15:37:30 +02:00
Brad King
79f5ef19fe De-duplicate checks for whether a platform uses Windows DLLs 2019-07-12 17:35:49 -04:00
Sebastian Holtermann
537ea119b9 cmTarget: Initialize static std::unordered_set on construction 2019-06-04 18:11:19 +02:00
Sebastian Holtermann
c4826787d5 cmTarget: Property initialization cleanup 2019-06-04 18:11:19 +02:00
Sebastian Holtermann
006229278b Use cmAppend to append ranges to std::vector instances 2019-05-23 16:19:49 +02:00
Ruslan Baratov
26ea022c3b Add variable CMAKE_FRAMEWORK 2019-05-21 14:26:23 +03:00
Saleem Abdulrasool
b6412e3e38 Ninja: add placeholders to support Swift build
Add the placeholders needed to support compiling Swift code.
2019-05-16 14:41:05 -04:00
Luca Cappa
2a9ff9703e MSVC: Add support for /JMC (Just My Code) 2019-05-14 13:27:18 -04:00
Brad King
fb3370b6a1 MSVC: Add abstraction for runtime library selection
Replace our hard-coded defaults for `/MD` and `/MDd` with a first-class
abstraction to select the runtime library from an enumeration of logical
names.  We've long hesitated to do this because the idea of "runtime
library selection" touches on related concepts on several platforms.
Avoid that scope creep by simply defining an abstraction that applies
only when targeting the MSVC ABI on Windows.

Removing the old default flags requires a policy because existing
projects may rely on string processing to edit them and choose a runtime
library under the old behavior.  Add policy CMP0091 to provide
compatibility.

Fixes: #19108
2019-04-17 11:00:44 -04:00
Sebastian Holtermann
735c6f39d9 Fix invalid ///! doxygen comment line starts
In various places `///!` was used to start a comment line.  This is not valid
Doygen syntax.  This patch replaces `///!` comment starts with `//!`.
2019-03-31 11:27:12 +02:00
Sebastian Holtermann
de0d57c97a cmTarget: Use std::unique_ptr instead of custom smart pointer
To manage the lifetime of `cmTargetInternals`, the private implementation of
`cmTarget`, use `std::unique_ptr<cmTargetInternals>` instead of
`cmTargetInternalPointer`, which is removed.

`cmTarget` is made non-copyable but movable.
2019-03-23 22:22:34 +01:00
Sebastian Holtermann
be2764a657 cmTarget: Make private SetPropertyDefault an in code lambda InitProperty 2019-03-23 22:22:34 +01:00
Sebastian Holtermann
a65a404186 cmTarget: Inline private HasImportLibrary method 2019-03-23 22:22:34 +01:00
Sebastian Holtermann
ff91071a14 cmTarget: Move member method CheckImportedLibName to impl 2019-03-23 22:22:34 +01:00
Sebastian Holtermann
afc4612fa5 cmTarget: Move member method ProcessSourceItemCMP0049() to impl 2019-03-23 22:22:34 +01:00
Sebastian Holtermann
72b0eeeb21 cmTarget: Move member booleans to impl 2019-03-23 22:22:34 +01:00
Sebastian Holtermann
db182eb160 cmTarget: Move member *Commands to impl 2019-03-23 22:22:34 +01:00
Sebastian Holtermann
30495bb1c2 cmTarget: Move member RuntimeInstallPath to impl 2019-03-23 21:45:10 +01:00
Sebastian Holtermann
0dcef68cd8 cmTarget: Move member InstallPath to impl 2019-03-23 21:45:10 +01:00
Sebastian Holtermann
5db17e9d81 cmTarget: Move member Name to impl 2019-03-23 21:45:10 +01:00
Sebastian Holtermann
ccf76c6e4c cmTarget: Move member TLLCommands to impl 2019-03-23 21:45:10 +01:00
Sebastian Holtermann
7742bf4ff5 cmTarget: Move member Backtrace to impl 2019-03-23 21:45:09 +01:00
Sebastian Holtermann
2c14eb4852 cmTarget: Move member PolicyMap to impl 2019-03-23 21:45:09 +01:00
Sebastian Holtermann
f6241db3e0 cmTarget: Move member OriginalLinkLibraries to impl 2019-03-23 21:45:09 +01:00
Sebastian Holtermann
3c09bf0fa7 cmTarget: Move member Utilities to impl 2019-03-23 21:45:09 +01:00
Sebastian Holtermann
856a271fb7 cmTarget: Move member SystemIncludeDirectories to impl 2019-03-23 21:45:09 +01:00
Sebastian Holtermann
46075091d5 cmTarget: Move member Properties to impl class 2019-03-23 21:15:32 +01:00
Sebastian Holtermann
2cd4104600 cmTarget: Move member Makefile to impl 2019-03-23 15:10:50 +01:00
Sebastian Holtermann
fa8e2dfc7b cmTarget: Move member TargetType to impl 2019-03-23 15:04:56 +01:00
Sebastian Holtermann
c9bd2e941f cmTarget: Rename member Internal to impl 2019-03-23 15:04:42 +01:00
Brad King
fb05b6a8f5 Merge topic 'cmTarget_micro_fixes'
965da8d787 cmTarget: Acquire data only when needed
03d17a35b5 cmTarget: Use helper function to append to lists

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3135
2019-03-22 09:19:09 -04:00
Harry Mallon
413b71485a Xcode: Create Xcode schemes per target 2019-03-21 16:50:41 +00:00
Sebastian Holtermann
965da8d787 cmTarget: Acquire data only when needed 2019-03-21 16:58:29 +01:00
Sebastian Holtermann
03d17a35b5 cmTarget: Use helper function to append to lists 2019-03-21 16:57:27 +01:00
Regina Pfeifer
9eb0e73f46 cmRange: Move to dedicated header file 2019-02-21 08:24:25 -05:00
Artur Ryt
706b93fa55 Modernize: C-arrays and loops over them
It replaces C arrays with deduced std::initializer_lists
or std::array what makes enables for-loop over them.
2019-02-15 23:40:30 +01:00
Artur Ryt
01b2d6ab74 Modernize: Use ranged for-loops when possible
Replaced most manual `const_iterator`-based loops and some
reverse-iterator loops with range loops.

Fixes: #18858
2019-02-07 22:39:05 +01:00
Bruno Manganelli
b6a957c969 cmOutputConverter: move ConvertToRelativePath to cmStateDirectory. 2019-01-27 15:48:57 +00:00
Brad King
1fba410ecf Merge topic 'autogen_mocs_compilation_first'
1ed4d48dcf Autogen: Prepend instead of append `mocs_compilation.cpp` to the sources list
a42b700cc2 cmTarget,cmGeneratorTarget: Add optional `before` parameter to AddSource

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Peter Wu <peter@lekensteyn.nl>
Merge-request: !2815
2019-01-21 07:53:23 -05:00
Sebastian Holtermann
a42b700cc2 cmTarget,cmGeneratorTarget: Add optional before parameter to AddSource
The new optional `before` parameter in `cmTarget::AddSource` and
`cmGeneratorTarget::AddSource` allows to prepend a source file
to the sources list instead of appending it.
2019-01-18 13:47:23 +01:00
Regina Pfeifer
ef61997b1b clang-tidy: Use emplace 2019-01-17 13:12:02 -05:00
Bruno Manganelli
cc2a5261f8 Factor out enum MessageType into dedicated header
Reduce the number of files relying on `cmake.h`.
2019-01-16 08:16:31 -05:00
Artur Ryt
ecf6fc8dc1 cmTarget: Remove unused classes cmTargetSet and cmTargetManifest 2018-12-06 11:40:13 -05:00
Cengizhan Pasaoglu
c67ab22cdc Using front() and back() instead of calculations 2018-11-06 21:43:33 +03:00
Sebastian Holtermann
b5e895b5d4 Autogen: Add (CMAKE_)AUTOGEN_ORIGIN_DEPENDS support
This adds

- the variable ``CMAKE_AUTOGEN_ORIGIN_DEPENDS`` which initializes
- the target property ``AUTOGEN_ORIGIN_DEPENDS``

which controls whether or not the origin target dependencies
should be forwarded to the corresponding ``_autogen`` target.

The default value of ``CMAKE_AUTOGEN_ORIGIN_DEPENDS`` is ``ON``
which corresponds to the behavior that is in place since CMake 3.9.

Closes: #18493
2018-11-03 12:14:40 +01:00
Peter Wu
6114d85a7d RPATH: Add option for using $ORIGIN in build tree
This makes binaries independent of the build directory by not embedding
the build directory via RPATH.  The tests are partially based on the
existing RuntimePath test, but with the check moved into a POST_BUILD
command such that it can be skipped when the platform lacks support.

Fixes: #18413
2018-10-26 09:25:51 -04:00