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.
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.
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.
Fortran does not offer syntax to compose a string literal at
preprocessing time from numeric compuations. Instead encode each digit
of each component as a separate INFO string and compose them in CMake
code after extraction. Support MAJOR, MINOR, PATCH, and TWEAK
components with up to 8 digits each.
In commit v3.1.0-rc1~113^2 (Use a more reliable regex for extracting
binary INFO strings, 2014-09-03) the matching of INFO: strings was made
more strict and no longer matches just "INFO:qnxnto". Use
"INFO:qnxnto[]" instead to conform to the new pattern.
The approach in commit v3.1.0-rc1~1^2 (Xcode: Fix compiler id detection
when code signing is required, 2014-10-22) still requires a code signing
key when targeting a real device. Instead set CODE_SIGNING_REQUIRED to
"NO" to tell Xcode not to sign at all. Drop the corresponding setting
of the code signing identity.
Since commit v3.1.0-rc1~1^2~1 (Xcode: Fix compiler id detection for iOS
tools, 2014-10-22) our compiler id detection project sets the product
type to 'com.apple.product-type.bundle.unit-test'. This causes the Ld
command line on which we match the path to the compiler to have a
'CompilerIdC.xctest/' component. The commit updated our regex to match
this, but placed it before the extra './' component that Xcode 5.0 and
below produce. Xcode <= 5.0 prints '/./CompilerIdC.xctest/', so switch
the order of the two components in the regex to match it.
The iOS product type 'com.apple.package-type.bundle.unit-test' requires
code signing on Xcode 6. Other iOS target types do too. Until CMake
learns to add the CODE_SIGN_IDENTITY build attribute itself, toolchain
files can set CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY to tell the Xcode
generator to add the attribute. Teach CMakeDetermineCompilerId to
recognize this variable and add the CODE_SIGN_IDENTITY build attribute
to the compiler id project.
Since commit 0cce556b (Xcode: Use sysroot and deployment target to
identify compiler, 2014-04-29) our compiler id detection project uses
the target platform SDK in case Xcode selects a different compiler based
on it. Now the compiler id project actually compiles with the target
compiler and SDK when cross-compiling.
The iOS tools do not support the 'com.apple.product-type.tool' product
type we use in our compiler id detection project. When targeting
iPhone, use product type 'com.apple.product-type.bundle.unit-test'
instead.
When testing CMAKE_<LANG>_COMPILER_ID values, do not explicitly
dereference or quote the variable. We want if() to auto-dereference the
variable and not its value. Also replace MATCHES with STREQUAL where
equivalent.
Teach CMakeDetermineCompilerId to recognize the Tegra-Android platform
and generate a test project for Nsight Tegra tools. Locate the full
path to CMAKE_<LANG>_COMPILER by computing it within the test project
build environment.
Also teach CMakeFindBinUtils that this variant of the Visual Studio
generator uses UNIX-like instead of MS-like archiving and linking tools.
A few different regular expressions were being used in various
places to extract info strings from binaries. This uses a
consistent regex amongst all of them now. This also fixes the
broken ABI detection for Cray compilers.
Add WindowsSDKDesktopARMSupport to the compiler id .vcxproj to
avoid 'error MSB8022: Compiling Desktop applications for the ARM
platform is not supported.' from VS.
Inspired-by: Minmin Gong <minmin.gong@gmail.com>
Inspired-by: Gilles Khouzam <gillesk@microsoft.com>
When CMAKE_SYSTEM_NAME is set to target one of these, add
ApplicationType and ApplicationTypeRevision elements to the .vcxproj
file used to identify the compiler so that the WindowsPhone or
WindowsStore toolchains can work.
Co-Author: Brad King <brad.king@kitware.com>
This will allow sharing of the logic of the order to test compilers in
and the preprocessor macros used to do that and to determine the
version components.
Use CMAKE_OSX_SYSROOT and CMAKE_OSX_DEPLOYMENT_TARGET to set the Xcode
SDKROOT and MACOSX_DEPLOYMENT_TARGET build settings. This is necessary
because some versions of Xcode select a different compiler based on
these settings. We need to make sure the compiler identified during
language initialization matches what will be used for the actual build.
The matches have already been calculated and can simply be taken from
CMAKE_MATCH_n variables. This avoids multiple compilations of the same or very
similar regular expressions.
Introduce policy CMP0047 to control resetting the id for
compatibility.
De-duplicate content in the QNX platform file by including the GNU
one. QNX is a form of GNU platform.
Do not clear CMAKE_SHARED_LIBRARY_${lang}_FLAGS variables. They
are populated again later by the Compiler/GNU.cmake file anyway.
Modify the CMAKE_CXX_COMPILE_OBJECT variable only when the QCC
compiler id is in use, and the language is CXX. Use the QNX
recommended flag for QCC instead of the gcc compatible -x flag.
Populate new module files to handle system includes and depfiles
when using the QCC compiler.
Remove code which unsets the system include and depfiles related
variables. When a GNU driver is used instead of the QCC one, the
appropriate flags will be used. These variables were previously
cleared for lowest-common-denominator compatibility with both
drivers.
Xcode 5.1 output no longer puts "./" in the path to the linker output
for the CompilerId test binary. Update our regex to match the path
with or without the component.
In the code path for launching the VS IDE tools, avoid using
CMAKE_MAKE_PROGRAM. Instead use the variables CMAKE_VS_DEVENV_COMMAND,
CMAKE_VS_MSBUILD_COMMAND, and CMAKE_VS_MSDEV_COMMAND to lookup the
location of the build tool needed. Choose the proper tool based on
availability and necessity for the language (e.g. Intel Fortran must
build with devenv.com and not MSBuild.exe).
The find_file this module uses to locate the compiler id source file
must always look on the host and never in CMAKE_FIND_ROOT_PATH, even
when a toolchain file has
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
Add NO_CMAKE_FIND_ROOT_PATH to the find_file call to avoid rerooting.
Since commit 7d47c693 (Drop compatibility with CMake < 2.4, 2013-10-08)
we no longer need to use the configure_file IMMEDIATE option to support
compatibility modes less than 2.0.
When compiler id detection also provides a CMAKE_<LANG>_COMPILER
value, use it unconditionally. It is known to be the compiler
that is actually in use by IDE builds in VS and Xcode. Do not
let a stray cache entry try to say otherwise.
Even though this variable gets set to CMAKE_<LANG>_COMPILER-NOTFOUND when
the compiler is not found, CMake<LANG>Compiler.cmake gets removed by
cmGlobalGenerator::EnableLanguage so in try compiles the value is empty.
Quote references to the variable in
Modules/CMake(C|CXX|Fortran)Information.cmake
Modules/CMakeDetermineCompilerId.cmake
to avoid dropping arguments from commands that expect them.
Teach CMakeDetermineCompilerId to skip trying to build a .vfproj
file for Intel Fortran under Visual Studio 6. The msdev command-line
build produces a popup error dialog that hangs the configuration.
The Intel Fortran compiler needs the /fpp option to enable C
preprocessing. Without the option the compiler may warn and ignore
preprocessor lines instead of failing with an error. Detect the
warning and treat it as failure so that we move on to try /fpp and
detect the correct id. Without this it works only by luck because
Intel is the first compiler id in our detection source file.
3d8356d Clang: Support Windows variants for GNU and MSVC (#13035, #14458)
51ab85c CMakeDetermineCompilerId: Add notion of "simulated" id/version
be10826 CMakeDetermineCompilerId: Fix local var init
Some compilers try to simulate other compilers as a drop-in replacement
supporting all the same command-line options and predefined preprocessor
macros. In such cases it will be useful to have CMake load the compiler
information files for the simulated compiler instead of duplicating the
information. Teach CMakeDetermineCompilerId to extract the simulated
compiler id and version when the compiler id detection provides it.
The subsystem must be set to WINDWOSCE for some SDKs to link an
executable. Set it to 9 for VS2005 and to 8 for VS2008, since the
value differs between the different Visual Studio versions.
When the VS IDE build output setting
Tools -> Options -> Projects and Solutions ->
Build and Run -> MSBuild project output verbosity
is set to "Diagnostic" the build output contains a " (TaskId:###)"
suffix on the CMAKE_<lang>_COMPILER= line used to extract the compiler
executable location. Strip this suffix before checking that the
reported location exists.