summaryrefslogtreecommitdiffstats
path: root/Modules/CMakeDetermineCompilerId.cmake
Commit message (Collapse)AuthorAgeFilesLines
* Xcode: Detect architecture(s) using ARCHS instead of CURRENT_ARCHBrad King2018-06-181-3/+5
| | | | | | | | | 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
* VS: Add option to select the version of the toolset used by VS 2017Basil Fierz2018-05-291-0/+4
| | | | | | | | Add new `version=` parameter in the toolset setting to select the version. Add variable `CMAKE_VS_PLATFORM_TOOLSET_VERSION` to hold the version, if one is set (blank indicates default). Fixes: #17549
* CUDA: Add compiler detection for CUDA < 7.5Henry Schreiner2018-04-231-0/+16
| | | | | | | If the CUDA version macros are not defined, run `nvcc --version` and extract the version from its output. Fixes: #17920
* Clang: Do not mistake clang-cl 6.0 for GNU-like clangİsmail Dönmez2017-11-281-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | The check added by commit v3.10.0-rc2~2^2 (Clang: Diagnose unsupported GNU-like clang targeting MSVC ABI, 2017-10-10) is incorrectly detecting clang-cl 6.0 as GNU-like. Currently cmake is testing if the clang compiler accepts `--version` to see if it accepts GNU style flags. However, with the latest llvm snapshot this also works for clang-cl: > clang-cl --version clang version 6.0.0 (trunk) Target: x86_64-pc-windows-msvc Thread model: posix InstalledDir: C:\Program Files\LLVM\bin So instead we should use the `/?` flag which fails with clang but works with clang-cl: > clang-cl /? &> /dev/null; echo $? 0 > clang /? &> /dev/null; echo $? 1 Fixes: #17518
* Clang: Diagnose unsupported GNU-like clang targeting MSVC ABIBrad King2017-10-101-0/+35
| | | | | | | | | | 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
* Add infrastructure to detect secondary compiler version informationBrad King2017-10-031-0/+8
| | | | | | | | | | | Create a `CMAKE_<LANG>_COMPILER_VERSION_INTERNAL` variable to hold a secondary/internal compiler version number detected at the same time as the primary compiler version. This will be useful for some compilers where we need such a number to determine correct usage. Inspired-by: Stefan Andersson <tfosm@hotmail.com> Suggested-by: Norbert Lange <norbert.lange@andritz.com> Issue: #17264
* Xcode: Add team to compiler-id projectGregor Jasny2017-09-191-0/+6
| | | | Closes #16839
* Xcode: Add tvOS and watchOS toolchain file supportGregor Jasny2017-09-191-1/+2
| | | | Issue #16839
* MSVC: Add support for ARM64 architectureMinmin Gong2017-09-121-1/+3
| | | | | | Visual Studio 15.4 adds support for this architecture. Fixes: #17213
* Merge topic 'ninja-cl-intl'Brad King2017-08-241-0/+1
|\ | | | | | | | | | | | | de9840d1 Ninja: Fix support for MSVC with non-English output Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !1179
| * Ninja: Fix support for MSVC with non-English outputBrad King2017-08-231-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With MSVC the Ninja generator extracts the `cl -showIncludes` prefix. When MSVC is configured to have non-English output, e.g. via `VSLANG=2052` in the environment, then `cl` prints the prefix encoded for the current code page, which is not necessarily UTF-8 encoding. Currently we fail to convert the prefix to our internal UTF-8 encoding, but assume it is UTF-8 later. While writing `rules.ninja`, the Ninja generator converts our internal UTF-8 encoding to the current code page. The `msvc_deps_prefix =` line needs to be encoded as the current code page so that `ninja` can match in the output from `cl -showIncludes` during the build. Prior to commit v3.9.0-rc1~47^2 (codecvt: Re-implement do_out and do_unshift, 2017-05-25), the non-UTF-8 prefix extracted above was written without noticing its incorrect internal encoding. The `rules.ninja` file was successfully written, but possibly with a mangled `msvc_deps_prefix`. Since that commit the output stream correctly rejects the non-UTF-8 byte sequence and writing `rules.ninja` fails. Fix this by correctly converting the `cl -showIncludes` output from the current code page to our internal UTF-8 encoding. Fixes: #17191
* | IAR: Improve support for IAR ARM CompilerNorbert Lange2017-06-291-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Add a CMAKE_<LANG>_COMPILER_ARCHITECTURE_ID variableNorbert Lange2017-06-291-0/+3
|/ | | | | | | | | | 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.
* Xcode: Drop support for Xcode versions below 3Brad King2017-04-221-12/+2
|
* Xcode: Detect CURRENT_ARCH for use by generatorBrad King2017-03-311-0/+4
| | | | | | | 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.
* Merge topic '16742-swift-3.0'Brad King2017-03-301-1/+7
|\ | | | | | | | | | | | | | | 77139e32 Swift: Simplify mixed test case to make it version agnostic c03141c0 Swift: Default to Swift 3.0 with Xcode 8.3 and later Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !638
| * Swift: Default to Swift 3.0 with Xcode 8.3 and laterGregor Jasny2017-03-281-1/+7
| | | | | | | | | | | | | | Xcode 8.3 has dropped support for Swift 2.3 so that compiler and feature detection failed. Closes #16742
* | VS: Add support for determining CUDA compiler idBrad King2017-03-101-0/+14
| | | | | | | | | | Teach `CMakeDetermineCompilerId` how to generate a vcxproj file using the `CMAKE_VS_PLATFORM_TOOLSET_CUDA`.
* | VS: Add more placeholders to compiler id detection project file templateBrad King2017-03-101-0/+4
| |
* | VS: Refactor compiler id detection project file templateBrad King2017-03-101-0/+2
| | | | | | | | | | | | Make the `ClCompile` element name and `PostBuildEvent/Command` value configurable. Move the current content into default values for the corresponding variables.
* | CMakeDetermineCompilerId: check with and without user-specified flagsMichael Maltese2017-02-061-19/+28
|/ | | | | | | | | | | Clang may raise an error when passed a `-march=` option that doesn't correspond to the current target triple. CMake cannot pass the target triple when determining the compiler id because it doesn't know how yet, but it does pass along user-specified flags. This breaks when those user-specified flags include `-march=`. Fix this use case by also trying to find the compiler id without the user-specified flags. Fixes: #16587
* CUDA: Detect implicit link information on WindowsBrad King2017-01-121-0/+1
| | | | | The `nvcc -v` output on Windows uses response files, so load the one we need to extract the full link line.
* C# support: add compiler detection for MSVCMichael Stürmer2016-12-151-1/+9
|
* CUDA: Use the host compiler for linking CUDA executables and shared libs.Robert Maynard2016-11-141-1/+5
|
* VS: Provide an option to use x64 host toolsBrad King2016-10-141-0/+5
| | | | | | | | | | Visual Studio provides toolchains that are themselves built for 32-bit or 64-bit host architectures. By default it uses the 32-bit tools, but it can be told to prefer the 64-bit tools on 64-bit hosts. Extend the `CMAKE_GENERATOR_TOOLSET` specification to provide a way to request use of the 64-bit host tools. Closes: #15622
* Simplify CMake per-source license noticesBrad King2016-09-271-12/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Xcode: Port rudimentary Swift support to Xcode 8Brad King2016-09-231-0/+5
| | | | | | The `.pbxproj` file must now specify a `SWIFT_VERSION` value. Set it to the legacy value of "2.3" for now. Later this can be made configurable (e.g. to "3.0").
* Use string(APPEND) in ModulesDaniel Pfeifer2016-07-271-3/+3
| | | | | | | 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'
* CMakeDetermineCompilerId: Fix compiler id with square brackets in the pathBrad King2016-06-021-2/+3
| | | | | | | | | | We use file(GLOB) to load the list of files produced by compiling the compiler identification source. Encode square brackets in the path to the directory so that they are not treated as special characters in the globbing expression. Otherwise we fail to find any files when the path contains square brackets and the compiler id is unknown. Reported-by: Esch Nigma <eschnigma@openmailbox.org>
* Ninja: Fix clang-cl /showIncludes prefix detectionBrad King2016-05-031-2/+2
| | | | | | | | | We run MSVC-like compilers with the `/showIncludes` option and match the output to extract the corresponding message. Fix the matching to support compilers like `clang-cl` that print the message on the first line such that it is not preceded by a newline. LLVM-Issue: https://llvm.org/bugs/show_bug.cgi?id=27226
* Merge topic 'remove-vs6-generator'Brad King2016-03-101-11/+2
|\ | | | | | | | | | | b42866a3 Drop Visual Studio 6 generator cd9ba3ec cmLocalVisualStudio7Generator: Fix name of helper function
| * Drop Visual Studio 6 generatorBrad King2016-03-091-11/+2
| | | | | | | | | | | | This generator has been deprecated since CMake 3.3. Remove it. Update documentation, modules, and tests to drop content specific to this generator.
* | CMakeDetermineCompilerId: Add detection of clang.exe bundled with VSMariusz Pluciński2016-03-101-1/+5
|/ | | | | When using a clang toolset we need to find `clang.exe` instead of `cl.exe`.
* Merge topic 'vs-compiler-id-itanium'Brad King2016-01-071-3/+0
|\ | | | | | | | | d9bf5206 CMakeDetermineCompilerId: Fix VS Itanium platform name (#15889)
| * CMakeDetermineCompilerId: Fix VS Itanium platform name (#15889)Brad King2015-12-211-3/+0
| | | | | | | | | | | | | | VS expects the platform to be just `Itanium`, so drop the incorrect special case mapping it to `ia64`. This platform name has been wrong since the logic was added by commit v2.8.10~148^2~8 (VS: Detect the compiler id and tool location, 2012-08-16).
| * Merge branch 'revert-compiler-links-statically' into releaseBrad King2015-11-231-8/+0
| |\
* | | Compiler: Add infrastructure for detecting compiler wrappersChuck Atkins2015-12-071-0/+6
| | |
* | | Merge topic 'revert-compiler-links-statically'Brad King2015-11-241-8/+0
|\ \ \ | |/ / |/| / | |/ | | 9682de56 Revert "Disable shared library support when compiler links statically" (#15855)
| * Revert "Disable shared library support when compiler links statically" (#15855)Brad King2015-11-231-8/+0
| | | | | | | | | | | | | | | | In commit v3.4.0-rc1~18^2 (Disable shared library support when compiler links statically, 2015-09-30) we tried to detect when the compiler is not capable of linking shared libraries (possibly due to flags in use). However, the approach is not robust against flags like `-nostdlib`. Revert it for now pending another solution to the original problem.
* | Merge topic 'vs-win10-sdk'Brad King2015-10-021-0/+3
|\ \ | |/ |/| | | | | | | | | 3f077996 VS: Add support for selecting the Windows 10 SDK (#15670) 5dfc4c5f VS: Add hook to initialize Windows platform settings 61c472a2 cmSystemTools: Add VersionCompareGreater helper
| * VS: Add support for selecting the Windows 10 SDK (#15670)Gilles Khouzam2015-10-021-0/+3
| | | | | | | | | | | | | | | | | | Teach the VS 2015 generator to produce a WindowsTargetPlatformVersion value. Use the CMAKE_SYSTEM_VERSION to specify the version and if not set choose a default based on available SDKs. Activate this behavior when targeting Windows 10. Co-Author: Brad King <brad.king@kitware.com>
* | Disable shared library support when compiler links staticallyBrad King2015-09-301-0/+8
|/ | | | | | | | | When a user or a compiler wrapper adds '-static' to the compiler flags then it will always link static binaries. Detect this from the compiler id binary and disable TARGET_SUPPORTS_SHARED_LIBS. This will prevent projects from accidentally adding shared libraries when the toolchain does not support them. It also helps CMake avoid linking with flags that require shared libraries to be supported.
* Ninja: Detect MSVC /showIncludes prefix with compiler flags (#15596)Brad King2015-09-181-0/+31
| | | | | | | | 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.
* CMakeDetermineCompilerId: Drop unused code pathBrad King2015-09-181-23/+11
| | | | | The execute_process command always exists so we never need to fall back on exec_program.
* Project: Determine default language dialect for the compiler.Stephen Kelly2015-09-181-0/+5
| | | | | | Use the __cplusplus and __STDC_VERSION__ macros to automatically determine the default dialect for the compiler while determining its id and version.
* CMakeDetermineCompilerId: Use per-language regex to match Xcode compiler toolBrad King2015-06-301-9/+6
| | | | | | 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.
* CMakeDetermineCompilerId: Simplify src reference in IDE projectsBrad King2015-06-251-2/+2
| | | | | | | | When constructing the "id_src" value for substitution into VS or Xcode compiler id projects, the input "src" variable already contains the file name with no path so we do not need get_filename_component. We know this because CMAKE_DETERMINE_COMPILER_ID_WRITE already references "${src}" with this assumption.
* CMakeDetermineCompilerId: Try matching compiler output to detect idBrad King2015-06-181-0/+19
| | | | | | Some compilers can only be distinguished by their compilation output rather than preprocessor symbols or special flags. Add infrastructure to determine the compiler id by matching output.
* CMakeDetermineCompilerId: Refactor id build/check loop logicBrad King2015-06-181-5/+6
| | | | | | | | Callers of CMAKE_DETERMINE_COMPILER_ID initialize the CMAKE_${lang}_COMPILER_ID to unset so we can check it at the end of each loop iteration instead of the beginning. This approach allows us to break out of the loop as soon as we succeed. It will also allow checks to be added in more places within the loop later.
* CMakeDetermineCompilerId: Optionally try some flags before no flagsBrad King2015-06-181-1/+3
| | | | | | | | 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.