Commit Graph

38 Commits

Author SHA1 Message Date
Saleem Abdulrasool
f481b3a947 Swift: repair RPATH handling for macOS
The configuration previously handled Linux properly but did not function
on macOS as `ld64` does not support `:` delimited paths.  Account for
that by setting it to the empty string which will use multiple
invocations of the `-Xlinker -rpath -Xlinker ...` pattern to compute the
correct RPATH.
2020-03-11 08:45:47 -04:00
Saleem Abdulrasool
321df5783d Swift: support -rpath for executables
This adjusts the flags to enable setting the RPATH for executables.
2020-02-17 11:07:40 -05:00
Saleem Abdulrasool
1e26d57188 Ninja: properly handle exports from Swift exes
This adds logic to properly handle Swift executables.  Only executables
marked as exporting symbols will now generate module interfaces for the
executable.
2020-02-01 17:25:57 -08:00
Saleem Abdulrasool
576c2e7a2d Swift: move windows handling into platform file (NFC)
This moves the definition of the import library flags for Windows into a
platform specific file (much like the Darwin `-sdk` flag).  This is in
preparation for re-use of the flag to make the flags handling for
executables more precise.
2019-12-21 18:25:54 -08:00
Brad King
9c9bbedd31 Merge topic 'swift-rpath-darwin'
ff6c336127 Swift: support `-rpath` on Darwin

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4059
2019-11-18 13:43:11 -05:00
Brad King
eead6a2504 Merge topic 'swift-darwin-install-name'
f935de6746 Swift: support `INSTALL_NAME_DIR` on Darwin

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4060
2019-11-18 13:42:09 -05:00
Saleem Abdulrasool
ff6c336127 Swift: support -rpath on Darwin
Darwin also has the concept of RPATH.  Additionally, the flag is
identical to that on other Unixish platforms.  Simply avoid the `-rpath`
handling on Windows.

This enables the use of `BUILD_WITH_INSTALL_RPATH` and `INSTALL_RPATH`
with Swift targets on Darwin.
2019-11-18 10:04:09 -05:00
Saleem Abdulrasool
f935de6746 Swift: support INSTALL_NAME_DIR on Darwin
Adjust the shared object rule to ensure that we honour the
`INSTALL_NAME_DIR` property on Swift targets.  This enables the use of
`INSTALL_NAME_DIR` and `BUILD_WITH_INSTALL_NAME_DIR` on Darwin with
Ninja.
2019-11-18 10:02:50 -05:00
Saleem Abdulrasool
a27a1c7e88 Swift: Allow build and installed RPATHs to differ
Define the RPATH separator to `:` so that CMake can reserve room to edit
the ELF RPATH at install time.  This enables the use of `BUILD_RPATH` and
`INSTALL_RPATH` with differing values.
2019-11-12 10:02:06 -05:00
Brad King
a53921b016 Merge branch 'swift-rpath' into release-3.16
Merge-request: !3965
2019-10-31 09:08:34 -04:00
Saleem Abdulrasool
1e05f89f4b Swift: support BUILD_RPATH properties
Enable passing a RPATH to Swift shared libraries.  This enables testing
libraries before they have been installed.
2019-10-30 14:18:15 -04:00
Saleem Abdulrasool
d9dd7cca66 Swift: correct flags for parallel jobs
`-num-threads` is for the threading, not the job control.  Use `-j` to
launch the parallel jobs.  This enables parallel builds for Swift again
after driver updates preventing the parallelization through
`-num-threads`.
2019-10-28 11:36:57 -04:00
Brad King
e3746821df Merge topic 'swift-mode-flags'
4d83e47c05 Swift: define `CMAKE_Swift_FLAGS` correctly

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Ben Boeckel <ben.boeckel@kitware.com>
Merge-request: !3684
2019-08-19 15:08:22 -04:00
Kyle Edwards
c41c79285b Merge topic 'swift-import-library-location'
5480f65ab1 Swift: honour `IMPLIB_LOCATION` property

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Ben Boeckel <ben.boeckel@kitware.com>
Merge-request: !3686
2019-08-19 13:25:16 -04:00
Saleem Abdulrasool
5480f65ab1 Swift: honour IMPLIB_LOCATION property
The rules did not account for the import library location (through
`<TARGET_IMPLB>`) and instead would always write the import library to
the default location (next to the shared library/executable).  This
prevented the use of `CMAKE_RUNTIME_OUTPUT_LOCATION` and
`CMAKE_ARCHIVE_OUTPUT_LOCATION`.
2019-08-11 22:29:49 -07:00
Saleem Abdulrasool
4d83e47c05 Swift: define CMAKE_Swift_FLAGS correctly
Invoke `cmake_initialize_per_config_variable` to ensure that build type
flags are properly initialised.
2019-08-11 17:59:52 -07:00
Saleem Abdulrasool
689be6235e Generator: support per-language link library flag
This enables the use of MSVC and Swift on Windows in a single project.
MSVC uses no flag to indicate linked libraries while Swift uses `-l`.
Add support for a language specific link library flag which takes
precedence over the global `CMAKE_LINK_LIBRARY_FLAG` which preserves
compatibility with earlier releases.
2019-08-09 08:16:29 -07:00
Saleem Abdulrasool
2171f6ec0e Swift: correct SONAME flag for Darwin targets
Adjust the build rules for Swift to fix the SONAME handling for Darwin.
2019-08-05 17:29:41 -07:00
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