Commit Graph

20 Commits

Author SHA1 Message Date
Saleem Abdulrasool
151ef7cef4 Swift: refactor rule construction to reduce duplication
Use the placeholder expansion to avoid constructing the `-target` option
by hand if specified.  This reduces duplication and simplifies the
rules.
2019-07-17 10:26:46 -07:00
Saleem Abdulrasool
6af97178ef Swift: support SONAME on ELFish targets
We should enable the soname to be setup for ELF shared libraries.
Failure to do so generates binaries with incorrect names which prevents
loading.
2019-07-11 11:12:26 -07:00
Saleem Abdulrasool
08cd7f6a02 Swift: support multithreaded compilation
Query the number of logical CPUs available to enable parallel
compilation for Swift.
2019-07-02 10:45:07 -07:00
Saleem Abdulrasool
8aa0b63bc6 Swift: add rules for static linking
The Swift driver recently learnt how to generate static libraries using
the `-static` flag.  This enables us to generate proper static libraries
with dependency tracking with Swift as well.
2019-06-27 21:28:48 -07:00
Saleem Abdulrasool
a982916304 Support per-language library link flags
This changes the behaviour of the generators to use a per-language
library search path flag.  This is needed for multi-language projects
with different compilers (e.g. cl + gfortran).  Since the adjusted
variable has been part of the user settings, we control this based on a
policy.

Fixes: #19307
2019-06-06 15:28:43 -07:00
Brad King
a1c291e0ac Merge topic 'swift-wrapper'
6baa80d1e3 Modules: correct linker wrapper flag for Swift

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3390
2019-05-29 09:17:44 -04:00
Brad King
f093ac36c0 Merge topic 'linker-preference'
abea06efdf Modules: setup `CMAKE_Swift_LINKER_PREFERENCE`

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3373
2019-05-29 09:16:17 -04:00
Saleem Abdulrasool
6baa80d1e3 Modules: correct linker wrapper flag for Swift
This was sitting locally but was missed in previous commits.  This
enables the use of `LINKER:` when building Swift code bases.
2019-05-28 09:21:41 -07:00
Saleem Abdulrasool
abea06efdf Modules: setup CMAKE_Swift_LINKER_PREFERENCE
Swift's driver will invoke the C++ driver (`clang++`) to invoke the
linker.  Additionally, it will configure the command line to deal with
the linkage runtime support object (`swiftrt.o` or `swiftrt.obj`) to be
added at the right time (similar to C/C++).  Since it indirects through
`clang++` it will properly setup the linker invocation for C++ and C as
well.  This should permit the correct linker driver to be invoked in
multi-language projects.

Closes #19299
2019-05-24 10:33:25 -07:00
Saleem Abdulrasool
9e5457d3b4 Ninja,Swift: correct response file handling
The response file was being written but not used due to the wrong
variable being configured for Swift.  Swift does compile+link in a
single phase and does not use the `<OBJECTS>` placeholder.  Use the
`<SWIFT_SOURCES>` placeholder instead for the response file substitution
which serves the same purpose.
2019-05-23 14:05:37 -07:00
Brad King
22df62b58d Merge topic 'swift-flag-variables'
24223ac84b Modules: add Swift MSVC_RUNTIME_LIBRARY flags
7e636fd8e0 Modules: add `CMAKE_Swift_FRAMEWORK_SEARCH_FLAG`
0fbf936b46 Modules: remove `CMAKE_INCLUDE_FLAG_SEP_Swift`

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3353
2019-05-23 09:02:55 -04:00
Saleem Abdulrasool
02c14b7fcd Ninja,Swift: pass along DEFINES/FLAGS/INCLUDES
Since the Swift model does a single compile/link phase, we would not
get the compile definitions, includes, and options past along to the
build of the module.  Compute these for the target when constructing
the main command.
2019-05-21 08:53:50 -07:00
Saleem Abdulrasool
24223ac84b Modules: add Swift MSVC_RUNTIME_LIBRARY flags
This adds support for the newly minted `-libc` flag to the Swift driver
invocation.  These allow users to control the MSVC linkage properly on
Windows targets.
2019-05-21 08:38:23 -07:00
Saleem Abdulrasool
7e636fd8e0 Modules: add CMAKE_Swift_FRAMEWORK_SEARCH_FLAG
Swift supports frameworks and uses them across all OSes.  They are added
using the `-F` flag.  There must be a space following the flag and
before the parameter.
2019-05-21 08:38:23 -07:00
Saleem Abdulrasool
0fbf936b46 Modules: remove CMAKE_INCLUDE_FLAG_SEP_Swift
The include flag specifier should be specified multiply.  The separator
was being misused for adding a space after the `-I` flag.  Correct this
to get multiple include paths correct.
2019-05-21 08:38:23 -07:00
Saleem Abdulrasool
e9b0063e8e Modules: add build rules for Swift Ninja support
Add rules to support building Swift sources using Ninja.
2019-05-16 14:41:05 -04:00
Gregor Jasny
84f9f63fcc Modules: Introduce CMAKE_EFFECTIVE_SYSTEM_NAME to lookup compiler info
Create a `CMAKE_EFFECTIVE_SYSTEM_NAME` variable to use for looking
up compiler information modules instead of using `CMAKE_SYSTEM_NAME`
directly.  This will allow multiple platforms to share the same set
of compiler information modules without spelling out all of them.

Issue: #17870
2018-04-18 07:41:25 -04:00
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
Gregor Jasny
93ac2a78d5 Xcode: Obey SYSTEM keyword for includes (#15687)
CMake used to put all header search paths into HEADER_SEARCH_PATHS
attribute. Unfortunately this attribute does not support to declare
a search path as a system include.

As a hack one could add a -isystem /path to the cflags but then include
ordering is not deterministic. A better approach was chosen with this
patch by not filling HEADER_SEARCH_PATHS at all and to populate
the C, C++, and Fortran flags directly. The include paths used by
Xcode should be now identical to the ones used by Unix Makefiles and
Ninja generator.
2016-08-09 20:30:07 +02:00
Brad King
bf11253163 Add rudimentary support for the Apple Swift language with Xcode
Allow the `Swift` language to be enabled with the Xcode generator for
Xcode >= 6.1.  Reject it on other generators and with older Xcode
versions.  Since Apple is the only vendor implementing the language
right now, the compiler id can be just `Apple`.
2015-07-06 16:15:49 -04:00