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).
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.
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
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>
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.
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.
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.
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.
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).