Commit Graph

132 Commits

Author SHA1 Message Date
Kitware Robot
1772622772 LICENSE: Replace references to Copyright.txt with LICENSE.rst
```
git grep -lz 'Copyright.txt or https://cmake.org/licensing ' |
  while IFS= read -r -d $'\0' f ; do
    sed -i '/Copyright.txt or https:\/\/cmake.org\/licensing / {
              s/Copyright.txt/LICENSE.rst/
            }' "$f" ; done
```
2025-03-03 10:43:35 -05:00
Alan Phipps
9ba0a54554 TIClang: Add support for TI Clang-based compilers, including tiarmclang
Add TIClang compiler ID and support in compiler modules.  Update
documentation.  Add rudimentary RunCMake test for TIClang to test
basic functionality.

Fixes: #24619
2024-02-09 15:54:40 -05:00
Dan McGregor
6a82852dc2 Allow toolchain suffix without leading dash
FreeBSD installs both LLVM and gcc with tools named after the
major version, in the form "clang<major>", such as "clang16".

Detect compilers named this way, and find the related toolchain
tools.
2023-05-08 18:09:27 -06:00
Brad King
21e13f2416 CMakeDetermineCXXCompiler: Avoid if() quoted auto-dereference
This was missed by commit 29c3edb87a (Avoid if() quoted
auto-dereference, 2014-10-14, v3.2.0-rc1~501^2).

Fixes: #24859
2023-04-27 12:13:22 -04:00
Michael Hirsch
8834e4d6a5 IntelLLVM: Avoid finding not-yet-supported icpx on Windows
Intel oneAPI 2023.0 added the `icpx` compiler front-end on Windows.
It uses a GNU-like command-line, and is not yet supported by CMake.
Avoid finding `icpx` as the CXX compiler on Windows until support
is added.

Fixes: #24266
Issue: #24314
2023-01-12 10:23:38 -05:00
makise-homura
e5d9fce03f LCC: Add dedicated support for MCST LCC compiler
Divert LCC compiler as a new one, instead of treating it as GNU.

Since old times, Elbrus C/C++/Fortran Compiler (LCC) by MCST has been
passing checks for GNU compilers, so it has been identified as GNU.
Now, with intent of seriously upstreaming its support, it has been
added as a separate LCC compiler, and its version displays not a
supported GCC version, but LCC version itself (e.g. LCC 1.25.19 instead
of GNU 7.3.0).

This commit adds its support for detection, and also converts basically
every check like 'is this compiler GNU?' to 'is this compiler GNU or
LCC?'. The only places where this check is untouched, is where it
regards other platforms where LCC is unavailable (primarily non-Linux),
and where it REALLY differs from GNU compiler.

Note: this transition may break software that are already ported to
Elbrus, but hardly relies that LCC will be detected as GNU; still such
software is not known.
2021-10-15 05:05:19 +03:00
Brad King
a136b6ec98 MINGW: Define variable only when targeting Windows platforms
The `MINGW` variable indicates that the compiler targets MinGW, a GNU
ABI on Windows.  Since commit aff3147917 (Modernize GNU compiler info on
Windows, 2009-12-02, v2.8.2~636), we load the `Platform/Windows-GNU`
module for compilers targetin MinGW, so set the variable there instead.
This is equivalent to `Platform/Windows-MSVC` setting the `MSVC`
variable.  Also remove `if(MINGW)` checks from the module, which have
not been necessary since the enclosed logic was moved to that module.

The undocumented `CMAKE_COMPILER_IS_MINGW` internal variable is now
unused, so remove it too.

Fixes: #22647
2021-09-17 12:17:35 -04:00
Brad King
0b7ae84a96 Cygwin: Remove redundant definitions of CYGWIN and UNIX variables
These are set by modules loaded for `CMAKE_SYSTEM_NAME`.  We do not
need to set them again if the compiler defines `__CYGWIN__`.

Also remove the now-unused undocumented `CMAKE_COMPILER_IS_CYGWIN`
internal variable.
2021-09-16 09:55:26 -04:00
Brad King
e93245ec64 DetermineCompiler: Restore identification of MSVC with no INCLUDE or LIB
Update the change from commit c6aaaf066a (DetermineCompiler: Restore
identification of MSVC with no INCLUDE dirs, 2021-06-29,
v3.21.0-rc2~6^2) to also work with no `LIB` dirs.  Add the `-c` flag to
compile an object file without linking.
2021-07-01 13:04:16 -04:00
Brad King
c6aaaf066a DetermineCompiler: Restore identification of MSVC with no INCLUDE dirs
Since commit bd844387df (ROCMClang: Add the ROCm toolkit derived clang
compiler to CMake, 2020-08-28, v3.21.0-rc1~66^2~6), our generated
compiler id source file contains a preprocessor condition of the form

    #elif ... && __has_include(...)

When MSVC is invoked with no include directories in the `INCLUDE`
environment variable or in `-I` flags, its implementation of
`__has_include` errors out immediately.  This breaks identification of
the compiler.

Work around the problem by adding a fallback attempt to compile the
identification source using a dummy include directory.
2021-06-29 12:55:35 -04:00
Lihua Zhao
4c741d945a BinUtils: Restore toolchain prefix detection from compiler name 'c++'
Since commit b12aec6c8d (BinUtils: prefer bin utils matching the
compiler version extension, 2020-12-11, v3.20.0-rc1~171^2) we recognize
`clangg++` and `g++` but not `c++`.  Restore `[gc]` in place of `g`
in the regex, as we had before that change.

Fixes: #22069
2021-04-16 09:20:16 -04:00
William R. Dieter
a90d2a9eed IntelLLVM: Add support for Intel LLVM-based compilers
Using a single ID 'IntelLLVM' for the suite of Intel compilers based on
the LLVM backend.  The 'IntelLLVM' ID are used for C, C++, and Fortran.
Data Parallel C++ will be handled in a separate commit.

The C and C++ definitions are based on the Clang definitions.  The Intel
LLVM-based C and C++ compilers are based on the Clang front end, so
existing Clang options are more likely to be a good match than options
for the older Intel compilers.

Fortran is based on the older Fortran front end with the LLVM backend.
It has a similar interface to the older versions, though many options
are shared with the C and C++ compilers.

Fixes: #21561
Signed-off-by: William R. Dieter <william.r.dieter@intel.com>
2021-01-28 09:05:35 -05:00
Thomas Bernard
b12aec6c8d BinUtils: prefer bin utils matching the compiler version extension 2021-01-11 11:33:37 -05:00
Brad King
72f8237422 Merge topic 'xcode-compiler-id-path'
bcbae3f71e Xcode: Extract CMAKE_<LANG>_COMPILER from compiler id with multiple archs

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5506
2020-11-13 09:41:25 -05:00
Brad King
bcbae3f71e Xcode: Extract CMAKE_<LANG>_COMPILER from compiler id with multiple archs
When targeting a platform that supports multiple architectures, Xcode
may choose to build all of them in our small compiler id project.
Update the regex we use to extract the path to the compiler from
the Xcode output to account for this.

Fixes: #21425
2020-11-12 12:20:34 -05: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
Thomas Bernard
10d7445dd8 clang: Fix the typo for CMAKE_CXX_COMPILER_ID_TEST_FLAGS
Fix typo from commit 270e0d9c4d (Detect the correct target architecture
for clang compilers., 2020-07-28).

Issue: #21097
2020-08-18 17:23:54 -04:00
Brad King
4daf76e10a Merge topic 'compiler_flags'
f76c20da63 Toolchain: Test compiler initial settings
db486da265 Toolchain: Update documentation for initial compiler flags
deec2f587c Toolchain: Take CMAKE_<lang>_FLAGS_INIT into account during compiler detection
ca899af3e2 Toolchain: Handle repeated invocations of CMake with -DCMAKE_C_COMPILER
12ba89e142 Toolchain: Make `/path/comp;-argn' behave the same as 'comp;-argn'
6f1af899db Toolchain: Capture all arguments from CMAKE_<LANG>_COMPILER
ec1d3bc0b6 cmake: avoid exception when printing "changed variables" message

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4136
2020-08-06 11:00:12 -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
Fred Baksik
6f1af899db Toolchain: Capture all arguments from CMAKE_<LANG>_COMPILER
Capture CMAKE_<LANG>_COMPILER_ARG1 from CMAKE_<LANG>_COMPILER in the
same fashion that it is from $ENV{<LANG>}.

Since get_filename_component() returns a single string of all the
arguments from $ENV{<LANG>}, a single string of arguments will be
constructed from the items contained in CMAKE_<LANG>_COMPILER.

Fixes #20089
2020-07-23 14:52:48 -04:00
Brad King
eb705b9531 Update links to gitlab.kitware.com repos to add -/
GitLab now uses a `/-/` component between the `group/project` part of
the URL and the `{issues,merge_requests,tree}` part so that it can
support `group/subgroup/project` with arbitrary depth.
2020-05-26 11:38:01 -04:00
Robert Maynard
8cc384f629 Compilers: Add paths from -print-sysroot to system prefix path 2020-04-14 13:48:28 -04:00
Robert Maynard
c5dd2ca538 DetermineCompiler: Relax _CMAKE_TOOLCHAIN_PREFIX detection
Now detect _CMAKE_TOOLCHAIN_PREFIX whenever a compilers
name matches the heuristics, instead of only doing it
when cross compiling
2020-03-30 17:08:01 -04:00
Brad King
a245479372 clang: Work around toolchain file use of internal CMake variables
Since commit d44c0db0b2 (clang: setup correct configuration in gnu mode,
2019-02-20, v3.15.0-rc1~41^2~5) our Clang compiler information modules
need the `CMAKE_<LANG>_COMPILER_FRONTEND_VARIANT` variable that we
compute during compiler detection.  However, some existing toolchain
files set our internal `CMAKE_<LANG>_COMPILER_ID_RUN` variables and
block that detection, but do not set the new frontend variant variable.
Help them out by setting `CMAKE_<LANG>_COMPILER_FRONTEND_VARIANT` anyway.

Fixes: #19515, #19539
2019-08-05 09:43:00 -04:00
Brad King
067a4f484b Merge topic 'clang-gnulike-support'
74829f01b1 Help: Add notes for topic 'clang-gnulike-support'
19669abe1d Tests: handle string escaping differences with NMake+clang
a2a90f41e3 Tests: require C++14 for the Tutorial
4819ff9647 Tests: fix failures with gnu mode clang on windows
26af0b25e7 cmake: use correct stack size with gnu mode clang on windows
d44c0db0b2 clang: setup correct configuration in gnu mode
b7d5ef23e9 cmGlobalNinjaGenerator: use gnu compatible paths with clang in gnu mode
3d0210d8dc binutils: add the llvm-* variants to the tool lists.
...

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Francesco Bertolaccini <francesco@bertolaccini.dev>
Acked-by: Stanislav Ershov <digital.stream.of.mind@gmail.com>
Acked-by: Saleem Abdulrasool <compnerd@compnerd.org>
Merge-request: !2992
2019-05-29 09:22:12 -04:00
Zsolt Parragi
53fbe23f3f clang: introduce CMAKE_<lang>_COMPILER_FRONTEND_VARIANT
This variable is set to GNU on Windows when clang.exe ar clang++.exe is
used, and set to MSVC for clang-cl.exe.

CMAKE_<lang>_SIMULATE_ID is set to MSVC in both cases, as clang defaults
to -fms-compatibility for all command lines on windows.
2019-05-17 19:11:34 +02:00
Johan Stridkvist
7b0abaac31 ARMClang: Add support for Clang-based ARM compiler
Fixes: #18215
2019-05-14 14:59:55 -04:00
Regina Pfeifer
42825fc220 MinGW: Fix locating BinUtils when compiler has a suffix
While all executables from a mingw toolchain share a common prefix,
only the ones provided with the compiler have a suffix, the binutils
do not.

Fixes: #18879
2019-02-06 17:43:55 +01:00
Gregor Jasny
11da882a12 Apple: Introduce separate system name for iOS, tvOS, and watchOS
- Remove code signing requirements for non-macOS
- Do not set deployment target for non-macOS
- Build static library for compiler feature detection for non-macOS
- Use framework to run CompilerId tests for watchOS
- Port tests to new SDK handling
- Add new Apple cross-compiling section to toolchain documentation

Closes: #17870
2019-02-04 09:03:35 -05:00
Fred Baksik
72e0c115b7 GHS: Add Compiler ID detection
-- Detect GHS compiler and version
   Detect ARCHITECTURE_ID for PPC / ARM / 86 targets
   Detect PLATFORM_ID for Integrity and Integrity178 platforms
   Using defines specified in the documents for the compilers: 201416 PPC / 201754 ARM / 201714 86
-- Fallback C/CXX compiler ID to GHS if not otherwise detected and using GHS MULTI generator
   Works around issue with some GHS compilers not setting __ghs__ compiler define
-- Tweak Compiler ID checking so major id of 002017 is not replaced with 217
-- Prefer try_compile() library targets when testing for working GHS compilers
-- Avoid CMake errors if reading past end of file for checking if file is PE executable
2019-01-16 10:42:04 -05:00
Cristian Adam
243b7c40d4 QNX: Compiler and feature detection fixes
Tested compiler detection with the QNX 7.0 list of compiler targets:
 * gcc_ntoaarch64le
 * gcc_ntoaarch64le_cxx
 * gcc_ntoarmv7le
 * gcc_ntoarmv7le_cxx
 * gcc_ntox86_cxx
 * gcc_ntoaarch64le_gpp
 * gcc_ntox86_64_gpp
 * gcc_ntoarmv7le_gpp
 * gcc_ntox86_64_cxx
 * gcc_ntox86
 * gcc_ntox86_gpp
 * gcc_ntox86_64

This commit fixes some of the problems described in:
https://cristianadam.eu/20181202/a-better-qnx-cmake-toolchain-file/
2018-12-03 23:18:43 +01:00
Brad King
bc5bcad45e Xcode: Detect architecture(s) using ARCHS instead of CURRENT_ARCH
Xcode 10 no longer populates `CURRENT_ARCH` with the current
architecture in shell scripts and instead uses `undefined_arch`.
Instead we must use `ARCHS`.  It lists all architectures separated by
spaces.

Fixes: #18085
2018-06-18 13:44:43 -04:00
Brad King
acb4cb9500 CMakeFindBinUtils: Improve switch between MSVC- and GNU-like tools
The switch was not considering some languages, such as `ASM`.
Instead of memorizing the list of languages in the condition,
use a language specified by the includer.

Fixes: #17510
2017-11-28 07:57:58 -05:00
Brad King
b6d3a1c09a Clang: Diagnose unsupported GNU-like clang targeting MSVC ABI
The LLVM/Clang installer on Windows provides a `LLVM/bin` directory
containing `clang.exe` and `clang++.exe` command-line tools that have a
GNU-like command-line but target the MSVC ABI (instead of MinGW).  We
do not support this combination, so diagnose and reject it explicitly.
Tell users what to do to use the `clang-cl.exe` tool instead.

Issue: #16439
2017-10-10 14:56:43 -04:00
Norbert Lange
d8e6cd9ed8 IAR: Improve support for IAR ARM Compiler
Make the implementation for this compiler more complete.

IAR has multiple C++ modes, historically they were reduced c++ versions
for embedded that gradually improved to the full standard (which can be
reduced again by e.g. disabling rtti and exceptions).  The new
implementation picks the best available, but the c++ mode can also be
overridden by defining `CMAKE_IAR_CXX_FLAG`.

Add C/C++ standard flags so that all modes up to and including the last
supported standard are defined.

Fixes: #16826
2017-06-29 13:25:58 -04:00
Norbert Lange
0b1a2876c8 Add a CMAKE_<LANG>_COMPILER_ARCHITECTURE_ID variable
Compilers such as MSVC and IAR may have variants that target different
architectures.  We have been using a `MSVC_<LANG>_ARCHITECTURE_ID`
variable to hold this information for MSVC.  Add an alternative with a
more general name (later we can port MSVC to it too).

This additional information may be needed to generate proper invocations
of the compiler based on its architecture variant.
2017-06-29 13:25:57 -04:00
Brad King
a122190509 Xcode: Detect CURRENT_ARCH for use by generator
During compiler identification, extract the Xcode `CURRENT_ARCH` value
and save it for later use by the Xcode generator in an internal compiler
information variable.  This will be useful to know the locations of
object files when only one architecture is built.
2017-03-31 11:26:08 -04:00
Ruslan Baratov
b9d36826c5 Add 'CMAKE_GCC_AR' and 'CMAKE_GCC_RANLIB' variables 2017-03-09 04:28:01 +08: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
Ben Boeckel
2bdba83e4b issues: update references to the CMake issue tracker
References to specific comments are left as-is since comments were not
migrated.
2016-08-15 09:34:06 -04:00
Brad King
f6c2189495 Modules: Rename internal platform-specific compiler determination modules
Rename Modules/Platform/<os>-<lang>.cmake files to
Modules/Platform/<os>-Determine-<lang>.cmake to clarify their role.
For compatibility with user-provided modules, load the old names
if they exist.
2016-06-02 09:51:43 -04:00
Brad King
da7276cf94 Replace http://www.cmake.org URLs with https://cmake.org
The latter is now the preferred URL for visiting cmake.org with a
browser.  Convert using the shell code:

 git ls-files -z | xargs -0 sed -i 's|http://www\.cmake|https://cmake|g'
2015-09-25 15:47:39 -04:00
Brad King
109a7a245a Ninja: Detect MSVC /showIncludes prefix with compiler flags (#15596)
Move detection over to the compiler id logic where we have already
constructed the list of compiler flags from ARG1 and CMAKE_<LANG>_FLAGS.
Pass the flags when we execute "cl" with "/showIncludes".  Also pass "/c"
because we only need to compile, not link.  Check the compiler process
exit code before trusting its output.
2015-09-18 10:02:53 -04:00
Brad King
162e7b5675 Merge topic 'determine-compiler-CMP0054'
dc8822f0 CMakeDetermine{C,CXX}Compiler: Avoid if() auto-dereferene in quoted arguments
2015-08-21 09:28:50 -04:00
Matt McCormick
dc8822f0a7 CMakeDetermine{C,CXX}Compiler: Avoid if() auto-dereferene in quoted arguments
Exposed by a CMP0054 warning with code like:

  cmake_minimum_required(VERSION 2.8.9 FATAL_ERROR)
  project(MyProj NONE)
  enable_language(C)
  enable_language(CXX)

While at it, use STREQUAL for testing the compiler id against "GNU".

Suggested-by: Rolf Eike Beer <eike@sf-mail.de>
2015-08-20 09:35:16 -04:00
Brad King
99d160385e CMakeDetermineCompilerId: Use per-language regex to match Xcode compiler tool
Move the Ld invocation match expression from CMakeDetermineCompilerId
into CMakeDetermine{C,CXX,Fortran}Compiler so that it can be specified
on a per-language basis.
2015-06-30 10:14:08 -04:00
Brad King
c65a060e1b CMakeDetermineCompilerId: Optionally try some flags before no flags
Teach CMAKE_DETERMINE_COMPILER_ID to optionally try detecting the
compiler id using some given flags before trying to detect it with no
special flags.  This will be useful for Fortran detection to distinguish
some compilers that use the preprocessors of others but have no macro of
their own by getting verbose output.
2015-06-18 10:59:35 -04:00
Brad King
d11a19528e Merge topic 'fix-clang-cross-compile-find-binutils'
72d66818 Fix finding binutils when cross-compiling with Clang
2014-09-08 12:57:01 -04:00
Brad King
72d6681826 Fix finding binutils when cross-compiling with Clang
Since commit v3.0.0-rc1~342^2~2 (Add compiler target compile options,
2013-05-19) we use CMAKE_<LANG>_COMPILER_TARGET as the binutils prefix
when cross-compiling with Clang.  Fix the implementation to use the
compiler target as the prefix only when it is set.  Otherwise toolchain
files not using CMAKE_<LANG>_COMPILER_TARGET cause the logic to use
a prefix of just "-" and of course cannot find "-ar" or "-ld".
2014-09-05 12:06:27 -04:00
Rolf Eike Beer
7eacbaed4d Replace MATCHES ".+" tests with NOT STREQUAL "" 2014-04-14 18:17:23 +02:00