Commit Graph

1161 Commits

Author SHA1 Message Date
Brad King
1a5c1a68b6 macOS: Add /opt/homebrew to CMAKE_SYSTEM_PREFIX_PATH on Apple Silicon
According to https://brew.sh/2020/12/01/homebrew-2.6.0/ the `/opt/homebrew`
directory is recommended for installing ARM architecture brew packages.

Fixes: #21585
2020-12-11 13:07:17 -05:00
Brad King
5f882f6ce5 macOS: Offer control over host architecture on Apple Silicon hosts
Since commit b6c60f14b6 (macOS: Default to arm64 architecture on Apple
Silicon hosts, 2020-09-28, v3.19.0-rc1~63^2) we use `sysctl` to detect
that we are running on Apple Silicon in a way that pierces Rosetta.
This always sets `CMAKE_HOST_SYSTEM_PROCESSOR` to be `arm64` on such
hosts.  However, macOS offers strong support for running processes under
an emulated `x86_64` architecture.

Teach CMake to select either `arm64` or `x86_64` as the host
architecture on Apple Silicon based on the architecture of its own
process.  When CMake is built as a universal binary, macOS will select
whichever slice (architecture) is appropriate under the user's shell,
and `CMAKE_HOST_SYSTEM_PROCESSOR` will match.

Also offer a `CMAKE_APPLE_SILICON_PROCESSOR` variable and environment
variable to provide users with explicit control over the host
architecture selection regardless of CMake's own architecture.

Finally, if `CMAKE_OSX_ARCHITECTURES` is not set, pass explicit flags to
the toolchain to use selected host architecture instead of letting the
toolchain pick.

Fixes: #21554
2020-12-10 12:08:13 -05:00
Thomas Bernard
f7ff0d34f0 llvm-rc: Force C language for the clang gnu frontend
When preprocessing the rc file using the clang gnu front end we need to
force the source file type to a c file for the preprocessing to take
place.

Fixes: #21472
2020-12-02 08:19:44 -05:00
Marc Chevrier
9ac9876757 Clang on Windows: 'LINKER:' prefix must be honored
Fixes: #21094
2020-11-30 15:31:45 +01:00
Haibo Huang
a585b75df9 Android: Use NDK_KNOWN_DEVICE_ABI{32,64}S instead of NDK_DEFAULT_ABIS
Revise logic from commit 1ab574a0f4 (Android: Add support for NDK r22,
2020-10-07, v3.19.0-rc1~18^2) that loads ABI tables from the NDK.

`NDK_DEFAULT_ABIS` means the abis to build by default.
Use `NDK_KNOWN_DEVICE_ABI{32,64}S` instead.

In practise they have never been different. Fix to make it more precise.
2020-11-10 11:05:36 -08:00
Tor Arne Vestbø
4c6797e03e Apple: Update SDK architecture detection for tbd file version 4
Extend the `.tbd` parsing from commit 170e598add (iOS: Fix detection of
supported SDK architectures, 2020-04-16, v3.17.2~11^2) to support `.tbd`
file version 4.
2020-11-05 10:21:23 -05:00
Haibo Huang
8e4aa63c7b Android: show supported API level in error message 2020-10-13 08:40:44 -04:00
Haibo Huang
5c2f9e3eeb Android: Fatal if ABI is not supported by NDK 2020-10-09 09:49:19 -04:00
Haibo Huang
1ab574a0f4 Android: Add support for NDK r22
NDK r22 removed platforms and sysroot directory.
NDK r18+ provides `.cmake` files with tables of platforms and abis.
2020-10-07 16:18:10 -07:00
Haibo Huang
91a362d2fa Android: Drop redundant setting of CMP0057 in Android-Determine
A module-wide setting was added by commit 8ede35523e (IN_LIST: Ensure
policy allows if(IN_LIST) if used by a module, 2018-09-12,
v3.13.0-rc1~95^2), so our local setting is no longer needed.
2020-10-07 16:17:36 -07:00
Haibo Huang
0b082c5253 Android: Select Android API after ABI is determined
API level depends on ABI. E.g. for LP64 the minimum API level should be 21 instead of 16 for others.
2020-10-07 16:13:56 -07:00
Brad King
b6c60f14b6 macOS: Default to arm64 architecture on Apple Silicon hosts
Detect `arm64` hardware using a method that pierces Rosetta.  If
`CMAKE_OSX_ARCHITECTURES` is not set, pass explicit flags to the
toolchain to use `arm64` instead of letting the toolchain pick.

Fixes: #20989
2020-09-30 11:58:44 -04:00
Thomas Bernard
cf83758b24 Clang: Implement CMAKE_${LANG}_COMPILER_TARGET for all variants on windows
Fixes: #21097
2020-09-11 09:05:03 -04:00
Brad King
6d77487eb7 Merge topic 'ios-pch-x-lang-header'
8d61294c3e PCH: Mark CMake PCH source files as -x <lang>-header

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5188
2020-09-09 11:23:34 -04:00
Cristian Adam
8d61294c3e PCH: Mark CMake PCH source files as -x <lang>-header
Fixes: #21163
2020-09-04 19:23:17 +02:00
Brad King
f10682b796 Merge topic 'ispc_lang_support'
5ece12b7e4 gitlab-ci: add ISPC to the Fedora CI image
8976817d6d ISPC: Update help documentation to include ISPC
2368f46ba4 ISPC: Support building with the MSVC toolchain
e783bf8aa6 ISPC: Support ISPC header generation byproducts and parallel builds
34cc6acc81 Add ISPC compiler support to CMake
419d70d490 Refactor some swift only logic to be re-used by other languages

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5065
2020-09-01 09:15:39 -04:00
Robert Maynard
2368f46ba4 ISPC: Support building with the MSVC toolchain 2020-08-28 11:21:31 -04:00
Thomas Bernard
0ccd256787 llvm-rc: Enable preprocessing for all Windows usage variants
Fixes: #21096
2020-08-27 12:25:59 -04:00
Thomas Bernard
7e72fe2ec9 llvm-rc: Refactor the preprocessing logic 2020-08-27 12:25:20 -04:00
Brad King
6cbaa8eb93 Merge topic 'clang-cl-restore-preprocess'
7b083d59c2 clang-cl: Restore rules to create preprocessed and assembly output

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5142
2020-08-21 09:31:08 -04:00
Brad King
7b083d59c2 clang-cl: Restore rules to create preprocessed and assembly output
In commit d993ebd4ca (clang-cl: Add '--' before source file, 2020-07-28)
we accidentally replaced these rules with those to compile an object
file.
2020-08-19 10:53:48 -04:00
Brad King
447dfddb20 Merge branch 'backport-3.18-llvm-rc-quote-cmake' into llvm-rc-quote-cmake 2020-08-18 17:18:38 -04:00
Thomas Bernard
3937536d16 llvm-rc: Fix quoting of path to cmake in CMAKE_RC_COMPILE_OBJECT
When the installation path to cmake includes spaces, the
`<CMAKE_COMMAND>` is required to have proper quotation of the cmake
call.

Fixes: #21095
2020-08-18 17:15:34 -04:00
Thomas Bernard
d993ebd4ca clang-cl: Add '--' before source file
On Linux and macOS, absolute paths start with `/` which may be
interpreted by clang-cl as an option.  To avoid this, we separate the
source file path from preceding options with `--` to tell `clang-cl` it
is not an option.
2020-08-07 11:48:48 -04:00
Thomas Bernard
a94672b919 cmake: Change cmake_llvm_rc separator from -- to ++ to avoid conflict 2020-08-07 11:47:15 -04:00
Thomas Bernard
270e0d9c4d Detect the correct target architecture for clang compilers.
During compiler identification, if CMAKE_{C,CXX}_COMPILER_TARGET is
defined, the corresponding clang target flag is used to guaranty proper
target architecture detection.
2020-07-28 19:48:47 +02:00
Jean-Christophe Fillion-Robin
207373802e Fix typos identified using codespell
See https://github.com/codespell-project/codespell#readme

The following command was used:

```
codespell -q6 --skip="\
.git,\
*.json,\
./Copyright.txt,\
./Help/command/foreach.rst,\
./Help/prop_test/REQUIRED_FILES.rst,\
./Help/variable/CTEST_COVERAGE_COMMAND.rst,\
./Modules/CMakeCheckCompilerFlagCommonPatterns.cmake,\
./Modules/CMakeRCInformation.cmake,\
./Modules/Internal/CPack/NSIS.template.in,\
./Modules/FindMatlab.cmake,\
./Modules/MatlabTestsRedirect.cmake,\
./Modules/Platform/Windows-Clang.cmake,\
./Modules/Platform/Windows-Intel-Fortran.cmake,\
./Modules/Platform/Windows-MSVC.cmake,\
./Source/CMakeVersion.cmake,\
./Source/cmConvertMSBuildXMLToJSON.py,\
./Source/cmCreateTestSourceList.cxx,\
./Source/cmGlobalVisualStudio10Generator.cxx,\
./Source/cmExportBuildFileGenerator.cxx,\
./Source/cmExportInstallAndroidMKGenerator.cxx,\
./Source/cmExportInstallFileGenerator.cxx,\
./Source/cmExportSet.cxx,\
./Source/cmExportTryCompileFileGenerator.cxx,\
./Source/cmFindPackageCommand.cxx,\
./Source/cmInstallCommand.cxx,\
./Source/cmGeneratorExpressionLexer.cxx,\
./Source/cmLocalVisualStudio7Generator.cxx,\
./Source/cmOrderDirectories.cxx,\
./Source/cmTarget.cxx,\
./Source/kwsys/*,\
./Source/QtDialog/CMakeSetupDialog.ui,\
./Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx,\
./Source/CTest/cmParseCoberturaCoverage.h,\
./Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in,\
./Tests/RunCMake/CPack/tests/DMG_SLA/English.license.rtf,\
./Tests/RunCMake/CPack/tests/DMG_SLA/German.license.txt,\
./Tests/RunCMake/CPack/tests/DMG_SLA/German.menu.txt,\
./Tests/RunCMake/GoogleTest/xml_output.cpp,\
./Tests/RunCMake/Make/TargetMessages*,\
./Utilities/*,\
" \
-L "\
dependees,\
endwhile,\
fo,\
filetest,\
helpfull,\
nd,\
objext,\
stoll,\
supercedes,\
superceded,\
vas,\
varn,\
"
```
2020-07-22 12:44:47 -04:00
Tor Arne Vestbø
17e13fb6d0 macOS: Always pick latest SDK if user has not set one explicitly
Apple tech note QA1806 recommends always building against the latest
SDK.

Fixes: #20949
2020-07-14 15:43:45 +02:00
Chuck Cranor
2af6857562 Darwin: prefix internal osx variables with "_" to hide them from users
A simple CMakeLists.txt on osx shows that variable "d" is set
(but empty) by the system modules.  this pollutes the user's
variable namespace.  I noticed this when I created a library
target "d" and got unexpected policy CMP0054 warnings when
trying to find_package(d CONFIG REQUIRED) (triggered from the
generated "d-targets.cmake" ...).   Note that non-"_" prefixed
internal variables are ok within functions due to scoping rules.

Fixes: #20898
2020-07-03 07:33:25 -04:00
Kyle Edwards
6051a49c78 Visual Studio: Add Android support 2020-06-24 08:41:09 -04:00
Saleem Abdulrasool
444dbd40de Darwin: honour CMAKE_OSX_SYSROOT more faithfully
The libraries in the SDK should be given precedence over the system
libraries.  Check for the default library search path (in default order)
of `/usr/lib` and `/usr/local/lib` and use these as system prefix paths
for libraries when performing the link step against a specified SDK.
2020-05-30 20:32:38 -07:00
Brad King
a7b3102e00 Merge topic 'support_conda_env'
50879ce412 Conda: Add CONDA_PREFIX as an acceptable system prefix path
cd9c3c000f Tests: Update QtAutogen codeeditor test only include headers needed
d806bd2e8c Tests: Update test suite to run in an Anaconda environment

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4773
2020-05-22 08:12:24 -04:00
Brad King
d8eee80e30 Merge branch 'backport-cuda-default-runtime' into cuda-default-runtime 2020-05-22 06:50:19 -04:00
Robert Maynard
50879ce412 Conda: Add CONDA_PREFIX as an acceptable system prefix path 2020-05-21 11:32:36 -04:00
Robert Maynard
e55b21e24e CUDA: Compute CMAKE_CUDA_RUNTIME_LIBRARY default from toolchain
Since commit 0d0145138f (CUDA: Add abstraction for cuda runtime
selection, 2019-11-29, v3.17.0-rc1~83^2) we add CUDA runtime library
selection flags by default.

To maintain backwards compatibility the default CUDA runtime
library needs to be computed based on what libraries are found
on the initial compiler invocation. For example a toolchain
could establish initial flags that have all CUDA compilations
using the runtime version, and if we don't detect this we will
try to link to both the static and shared runtime.

Co-Author: Brad King <brad.king@kitware.com>
Fixes: #20708
2020-05-21 11:15:03 -04:00
Craig Scott
ddcc5a350c Merge topic 'doc-CMAKE_SYSTEM_PREFIX_PATH'
6b3d8f281e Document which environment variables effect CMAKE_SYSTEM_PREFIX_PATH

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4748
2020-05-20 06:28:11 -04:00
Robert Maynard
6b3d8f281e Document which environment variables effect CMAKE_SYSTEM_PREFIX_PATH 2020-05-19 10:57:09 -04:00
Raul Tambre
5df21adf46 CUDA: Add support for Clang compiler
When crosscompiling we pass the sysroot.

We need to try various architecture flags. Clang doesn't automatically
select one that works.  First try the ones that are more likely to work
for modern installations:

* <=sm_50 is deprecated since CUDA 10.2, try sm_52 first for
          future compatibility.
* <=sm_20 is removed since CUDA 9.0, try sm_30.

Otherwise fallback to Clang's current default. Currently that's `sm_20`,
the lowest it supports.

Separable compilation isn't supported yet.

Fixes: #16586
2020-05-15 17:46:51 +03:00
Brad King
91dd23d3d5 Merge topic 'pch-msvc-pragma' into release-3.17
6c2514dabe MSVC: Use 'pragma system_header' in PCH only on cl 19.13 and above

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4736
2020-05-12 06:52:40 -04:00
Brad King
cd89ebdda2 Merge topic 'pch-msvc-pragma'
6c2514dabe MSVC: Use 'pragma system_header' in PCH only on cl 19.13 and above

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4736
2020-05-12 06:52:40 -04:00
Brad King
6c2514dabe MSVC: Use 'pragma system_header' in PCH only on cl 19.13 and above
VS 2017 15.6 introduced support for this pragma.  Older MSVC versions
warn that it is unknown.

Fixes: #20692
2020-05-11 13:31:15 -04:00
Jiri Malak
4adfd2a3aa OpenWatcom: Add cross-compilation support for Windows
Add system header files directories for cross-compilation
2020-05-06 13:10:43 -04:00
Jiri Malak
43c3243c2d OpenWatcom: Fix Linux support file
Fix CMAKE_SHARED_LINKER_FLAGS_INIT macro
Fix executable file name for Linux to be without extension
Add system header files directory for cross-compilation
2020-05-06 13:09:58 -04:00
Jiri Malak
d26eea220a OpenWatcom: Add OS/2 target support
OS/2 16-bit and 32-bit target support files for cross-compilation by
OpenWatcom.

It is used if CMAKE_SYSTEM_NAME=OS2 is defined.

If CMAKE_SYSTEM_PROCESSOR=I86 is defined then 16-bit OS/2 target is
used, otherwise 32-bit OS/2 target is used.
2020-05-06 13:09:28 -04:00
Jiri Malak
0ab583d787 OpenWatcom: Add DOS target support
DOS 16-bit and 32-bit target support files for cross-compilation by
OpenWatcom.

It is used if CMAKE_SYSTEM_NAME=DOS is defined.

If CMAKE_SYSTEM_PROCESSOR=I86 is defined then 16-bit DOS target is used,
otherwise 32-bit DOS target is used.
2020-05-06 13:09:00 -04:00
Jiri Malak
4197aadecb OpenWatcom: Add Linux support
It is native Linux support for Linux host executable only (only static
library support, no shared library support).
2020-04-29 07:56:15 -04:00
Jiri Malak
7aa9e89b1c OpenWatcom: Move non-Windows settings to Modules/Compiler
Restructure OpenWatcom toolchain support files to simplify adding of new
targets DOS, OS/2 and Linux including cross-compilation.
2020-04-28 09:36:04 -04:00
Marc Chevrier
4248bb452a CUDA: Device linking use now link options
properties LINK_OPTIONS and INTERFACE_LINK_OPTIONS are propagated
to the device link step.

To control which options are selected for normal link and device link steps,
the $<DEVICE_LINK> and $<HOST_LINK> generator expressions can be used.

Fixes: #18265
2020-04-19 15:53:11 +02:00
Brad King
ea2f95f4b9 Merge topic 'ios_multi_arch_fix'
170e598add iOS: Fix detection of supported SDK architectures

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Alexander Köplinger <alex.koeplinger@outlook.com>
Merge-request: !4615
2020-04-17 08:07:29 -04:00
Alexandru Croitor
170e598add iOS: Fix detection of supported SDK architectures
Instead of relying on SDKSettings.plist which does not contain the
certain architectures, deduce the supported architectures by
inspecting libSystem.tbd and libSystem.dylib.

.tbd files are text files, so just parse out the archs string.
.dylib files can be fat or non-fat, so use lipo -info to extract
the architectures and parse lipo output.

Fixes: #20588
2020-04-16 07:51:03 -04:00