Commit Graph

852 Commits

Author SHA1 Message Date
Brad King ea8eba0bbf Android: Add CMAKE_<LANG>_ANDROID_TOOLCHAIN_MACHINE
Expose the binutils' machine name (typically used as a prefix on the
tool names) publicly.  This is expected to match the `gcc -dumpmachine`
value.

Suggested-by: Ruslan Baratov <ruslan_baratov@yahoo.com>
2016-11-18 10:03:15 -05:00
Brad King 0d3eb139e1 Android: Add CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG variable
The NDK provides prebuilt toolchain files in directories named for the
host architecture.  The NDK build system calls this `HOST_TAG`.
Expose the value publicly for use by clients that need to pass it
to external tools.

Suggested-by: Ruslan Baratov <ruslan_baratov@yahoo.com>
2016-11-18 10:03:07 -05:00
Brad King 236d6244a0 Android: Always set CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION
When this variable is not set by the user or toolchain file, set it to
the default selected.  This will be useful for client code that needs to
pass the value to an external tool that needs to find the same toolchain
in the NDK.  Leave it empty for a standalone toolchain.

Suggested-by: Ruslan Baratov <ruslan_baratov@yahoo.com>
2016-11-18 10:02:57 -05:00
Brad King 503766fa0e Merge branch 'fix-macos-sysroot' into release 2016-11-02 08:44:16 -04:00
Gregor Jasny 935041908d Darwin: Remove deployment target version check
Starting with Xcode 8 the SDK folder also contains an unversioned entry:

    MacOSX.sdk
    MacOSX10.12.sdk -> MacOSX.sdk

If this unversioned path is used CMake cannot detect the SDK version.

Furthermore, querying the SDK version via

    xcodebuild -sdk <sysroot> -version Path

gives bogus results for the Command Line Tools installed into `/`.

The OS X deployment target version and SDK version are not as tied as
they once were, so this check is now more trouble than it is worth.
Simply remove it.

Closes: #16323
2016-11-01 09:37:49 -04:00
Gregor Jasny 542d52f95e Revert "Xcode: Convert maybe unversioned OSX sysroot into versioned SDK path"
Revert commit v3.7.0-rc1~48^2 (Xcode: Convert maybe unversioned OSX
sysroot into versioned SDK path, 2016-09-25).  The replacement of
`else()` with `if(CMAKE_OSX_SYSROOT)` defeats the prior handling of
`if("x${CMAKE_OSX_SYSROOT}" MATCHES "/")`. This causes the combination

    -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING="" -DCMAKE_OSX_SYSROOT:STRING=/

to not be honored and `-isysroot` to be emitted as a compiler flag
universally.  We will need another solution to the problem the
now-reverted commit was meant to address.

Closes: #16394
2016-11-01 09:31:08 -04:00
Brad King 4c272adbe1 Android: Link position-independent executables with proper flags
Add `-fPIE -pie` to the default executable link flags when
`CMAKE_POSITION_INDEPENDENT_CODE` is enabled.  This is required by
Android 16 and above for executables to run on the device.

Closes: #16382
2016-10-24 11:45:18 -04:00
Brad King 6205f1797e Android: Set CMAKE_POSITION_INDEPENDENT_CODE automatically
If the toolchain file or cache does not set this, enable it
automatically based on the Android API version.  Versions 16
and above expect position independent code.

Use the main `CMAKE_POSITION_INDEPENDENT_CODE` setting in favor of
hard-coding `-fpic` or `-fPIC` in the compiler flags for each ABI.
This allows CMake to use `-fpie` or `-fPIE` as needed when sources
are meant for executables, and `-fpic` or `-fPIC` for other sources.
2016-10-24 11:40:53 -04:00
Brad King 295c8efa35 Android: Add missing link flags for device executables
See `${ndk}/build/core/default-build-commands.mk` for link flags the NDK
uses for executables.  Add them to our default executable link flags.
Suppress `nocopyreloc` on `arm64-v8a` because it does not work with
some STL types.

Closes: #16380
2016-10-21 10:43:45 -04:00
Brad King 43f4326ece Android: Fix support for armeabi with c++_static
Add missing "unwind" and "atomic" libraries needed for this combination.
See `${ndk}/sources/cxx-stl/llvm-libc++/libs/armeabi/libc++.a` for the
libraries the NDK uses.

Issue: #16380
2016-10-21 08:42:25 -04:00
Brad King a0c539b546 Merge branch 'fix-Android-NsightTegra' into release 2016-10-18 14:24:34 -04:00
Brad King 06c396126f VS: Fix NVIDIA Nsight Tegra Visual Studio Edition support
The guard added by commit v3.7.0-rc1~229^2~17 (Android: Suppress new
functionality with Nsight Tegra in VS IDE builds, 2016-06-02) to
`Modules/Platform/Android-Determine.cmake` does not work in that
location because `CMAKE_VS_PLATFORM_NAME` is not set until after the
module is loaded.  Change this particular guard to test for the Visual
Studio generator instead.  If in the future we add support for using
Visual Studio for Android without Nsight Tegra then something more will
be needed, but this is good enough for now.

Closes: #16371
2016-10-18 13:32:50 -04:00
Brad King b6e5b6485f Merge branch 'osx-no-deployment-target-on-cross-compile' into release 2016-10-17 10:04:29 -04:00
Gregor Jasny e8bafb6fcb OS X: Do not try to set deployment target when cross-compiling
The change in commit v3.4.0-rc2~6^2 (Xcode: Adjust deployment target SDK
version to host version, 2015-10-11) does not make sense when
cross-compiling.  Make it conditional to fix this regression in some
cross-compiling cases.

Closes: #16355
2016-10-17 10:02:17 -04:00
Brad King 8cdac469d1 Android: Fix support for cxxabi.h with libc++
Additional include directories are needed for this on some STL types.

Closes: #16350
2016-10-07 09:53:51 -04:00
Brad King 0c3a04777c Android: Update libc++ include directories for NDK r13
The Android NDK r13 moved the libc++ include directories.

Closes: #16346
2016-10-06 13:26:40 -04:00
Brad King b53a12c29c Merge topic 'vs-clang-llvm-support'
3f300b84 VS: Recognize VS/LLVM toolset names as Clang
2016-09-29 08:09:39 -04:00
Roman Wüger 3f300b84f3 VS: Recognize VS/LLVM toolset names as Clang
Update the toolset name matching added by commit v3.6.0-rc1~279^2~10
(VS: in Clang/C2 toolset, setup correct compiler settings, 2016-02-18)
to match VS/LLVM toolset names too.
2016-09-28 10:53:10 -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 540815eec2 Xcode: Convert maybe unversioned OSX sysroot into versioned SDK path
Starting with Xcode 8 the SDK folder also contains an unversioned
entry:

$ ls -l /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs

drwxr-xr-x  5 root  wheel  170 Mar  4  2018 MacOSX.sdk
lrwxr-xr-x  1 root  wheel   10 Sep 16 20:49 MacOSX10.12.sdk -> MacOSX.sdk

If this unversioned path is used CMake cannot detect the SDK
version. To work around the problem we always invoke the code path
that translates short SDK names like "macosx10.12" into a path.
That way we always end up with a versioned SDK path in
_CMAKE_OSX_SYSROOT_PATH which is later used to determine the version.

Closes: #16323
2016-09-25 13:06:23 +02:00
Brad King 4feba34d02 GNU: Do not use -fvisibility on AIX or HP-UX
Use of `-fvisibility=hidden` warns:

  warning: visibility attribute not supported in this configuration; ignored
2016-09-05 09:45:13 -04:00
Brad King 7b637ebdc9 Android: Add `ANDROID` variable to indicate the target
Allow projects to use `if(ANDROID)` to condition their Android-specific
code paths.
2016-08-23 13:10:51 -04:00
Brad King d7d4083025 Android: Select the STL type for NDK builds
Populate standard include directories and link libraries for the
platform.  Select the STL corresponding to CMAKE_ANDROID_STL_TYPE and
matching the current ABI and toolchain to be used.  Refer to the NDK
sources/cxx-stl/*/Android.mk files for the needed file locations.
2016-08-23 12:53:10 -04:00
Brad King b22294bc41 Android: Populate compiler flags for current ABI
Initialize the CMAKE_{C,CXX}_FLAGS{,_<CONFIG>} cache entries with
flags for each ABI as specified by NDK toolchain `setup.mk` files.
2016-08-23 12:51:58 -04:00
Brad King b6a3102a9f Android: Add a CMAKE_BUILD_TYPE default
Android NDK builds are always `debug` or `release`.  We may populate
flags for these configurations that are needed to produce compatible
binaries.  Ensure they are used by default.
2016-08-12 10:40:54 -04:00
Brad King d1e3cec2aa Android: Add Clang -target option for current ABI 2016-08-12 10:40:54 -04:00
Brad King 504db72d99 Android: Add placeholders for compiler/abi-specific settings
The Android NDK source repository at

  https://android.googlesource.com/platform/ndk.git

has `<ndk>/build/core/toolchains/*/setup.mk` files that store tables of
information for their build system.  Add an equivalent file for each
compiler/abi combination.
2016-08-12 10:40:54 -04:00
Brad King fa63257821 Android: Avoid interfering with common pre-existing toolchain files
Commonly used Android toolchain files that pre-date CMake upstream
support may need to be updated to work with our new functionality.
They typically set CMAKE_SYSTEM_VERSION to 1, so detect that and
skip our upstream Android settings.  When such toolchain files are
updated to account for our upstream support, they can then set
CMAKE_SYSTEM_VERSION to a valid Android API and get new behavior.
2016-08-12 10:40:54 -04:00
Brad King 6299693f8a Android: Search for NDK and standalone toolchain in more places
Commonly used Android toolchain files that pre-date CMake upstream
support use a few environment and CMake variables as search locations.
Use them too to aid transition.
2016-08-12 10:40:53 -04:00
Brad King 29b51379de Android: Detect and save a standalone toolchain without the NDK 2016-08-12 10:40:53 -04:00
Brad King 7d9b49fbdf Android: Detect settings from the CMAKE_SYSROOT if it is set 2016-08-12 10:40:53 -04:00
Brad King 4389664a26 Android: Detect and save a toolchain from the NDK 2016-08-12 10:40:53 -04:00
Brad King 328191f65f Android: Set CMAKE_SYSROOT automatically
Compute CMAKE_SYSROOT automatically for the current API and architecture
selection.  This causes the --sysroot option to be passed to GNU and
Clang compilers.
2016-08-12 10:40:52 -04:00
Brad King 9e032304ea Android: Detect and save the architecture, ABI, and processor
Add new CMakeSystem.cmake entries for the architecture and ABI.
Store the processor in CMAKE_SYSTEM_PROCESSOR.
2016-08-12 10:40:52 -04:00
Brad King fde59c4d88 Android: Detect and save the API level
Store the Android API level in CMAKE_SYSTEM_VERSION.  If it is not
provided by the user, initialize it from CMAKE_ANDROID_API or fall back
to finding the latest available in the NDK.
2016-08-12 10:40:52 -04:00
Brad King 52b6effd81 Android: Detect and save the NDK directory
Add a new CMakeSystem.cmake entry for the NDK location.
2016-08-12 10:40:52 -04:00
Brad King 8e0cb45e55 Android: Suppress new functionality with Nsight Tegra in VS IDE builds
Support for NVIDIA Nsight Tegra Visual Studio Edition was previously
implemented in the CMake VS IDE generators.  Avoid interfering with
that functionality for now.  Later we may try to integrate this.
2016-08-12 10:40:52 -04:00
Brad King d5e7d5f3eb Android: Add placeholders for platform-specific initialization
Add infrastructure modules to be loaded when initializing builds
targeting Android platforms.
2016-08-12 10:40:51 -04:00
Brad King 64be1ae4a3 Android: Add placeholders for platform-specific compiler selection
Add infrastructure modules to be loaded for determining a compiler
selection when targeting Android platforms.
2016-08-12 10:40:51 -04:00
Brad King 47866770ce Android: Add placeholders for platform-specific compiler settings
Add infrastructure modules to be loaded for Clang and GNU compilers
when targeting Android platforms.
2016-08-12 10:40:51 -04:00
Brad King 314a953982 Merge topic 'update-cle-version-info'
e52302d6 CrayLinuxEnvironment: Add alternative methods to get version info
2016-08-08 10:02:11 -04:00
Chuck Atkins e52302d6cb CrayLinuxEnvironment: Add alternative methods to get version info
Closes: #16229
2016-08-05 09:01:43 -04:00
Patrick Welche 56539d89da SCO_SV: Enable so filename versioning
Take changes used by pkgsrc [1]:

* so filename versioning requires CMAKE_SHARED_LIBRARY_SONAME_C_FLAG.

[1] http://cdn.netbsd.org/pub/pkgsrc/current/pkgsrc/devel/cmake/patches/
2016-08-02 10:09:52 -04:00
Daniel Pfeifer 5d0d980d99 Use string(APPEND) in Modules
Automate with:

find Modules -type f -print0 | xargs -0 perl -i -0pe \
's/set\(([a-zA-Z0-9_]+)(\s+)"\$\{\1\}([^"])/string(APPEND \1\2"\3/g'
2016-07-28 00:41:13 +02:00
Brad King 8a98cf6432 Honor CMAKE_*_LINKER_FLAGS[_<CONFIG>]_INIT set in toolchain files
Document these variables.

Change our convention for setting these variables from:

    set(CMAKE_EXE_LINKER_FLAGS_INIT "...")

to

    string(APPEND CMAKE_EXE_LINKER_FLAGS_INIT " ...")

so that any value previously set by a toolchain file will be used.
2016-07-14 15:47:32 -04:00
Brad King 37d15c399e MSVC: Set all CMAKE_*_LINKER_FLAGS_INIT directly
Avoid copying CMAKE_EXE_LINKER_FLAGS_INIT to the others.
2016-07-13 15:05:32 -04:00
Brad King 55c884ed3b Embarcadero: Set all CMAKE_*_LINKER_FLAGS_INIT directly
Avoid copying CMAKE_EXE_LINKER_FLAGS_INIT to the others.
2016-07-13 15:01:26 -04:00
Brad King a66004bee0 Honor CMAKE_<LANG>_FLAGS[_<CONFIG>]_INIT set in toolchain files
Document these variables.

Change our convention for setting these variables from:

    set(CMAKE_C_FLAGS_INIT "...")

to

    string(APPEND CMAKE_C_FLAGS_INIT " ...")

so that any value previously set by a toolchain file will be used.

Automate the conversion with:

    sed -i 's/set *(\(CMAKE_\(C\|CXX\|Fortran\|RC\|ASM\|${[^}]\+}\)_FLAGS\(_[^_]\+\)\?_INIT \+"\)/string(APPEND \1 /' \
      Modules/Compiler/*.cmake Modules/Platform/*.cmake

and follow up with some manual fixes (e.g. to cases that already
meant to append).  Also revert the automated changes to contexts
that are not protected from running multiple times.
2016-07-06 10:13:31 -04:00
Brad King cdde77e5f6 OpenWatcom: Partially modernize platform information modules
Migrate from the old `<os>-<cc>.cmake` layout to the modern
`<os>-<id>-<lang>.cmake` layout.  Keep settings common to C and C++ in a
`Windows-OpenWatcom.cmake` helper module with an include blocker.
For now just add both C and CXX settings in the helper module.
2016-07-06 10:10:10 -04:00
Brad King 5a3ed0d780 Intel: Do not use MSVC-like flags for Fortran
Teach `Modules/Platform/Windows-MSVC.cmake` not to use MSVC options
for Fortran.  We use the `__windows_compiler_msvc` for the Intel
Fortran compiler on Windows for other settings, but we do not want
the flags.

Previously this worked only because the options were later overridden
by `Modules/Platform/Windows-Intel*.cmake`, but it is cleaner to not
set the options in the first place.
2016-07-05 13:58:36 -04:00