Using Intel Fortran on Windows with NMake generator fails to detect the linker version
When using an installation of Intel Fortran 12.0 in Windows that does not have the MS C/C++ compiler available, the feature detection code is not able to tell the feature level of the linker. In particular, I use ifort 12.0 with VS2008, so the linker used is able to generate and embed a manifest into binaries. However, since the activation of this feature depends on MSVC_VERSION and this variable gets a "wrong", low value, the manifest embedding is not enabled and instead, the linker generates both my out.exe and an out.exe.manifest file. By contrast, if the VS 2008 generator is used instead of the "NMake Makefiles" generator, the rules for manifest embedding are generated.
The problem can be reproduced as follows:
- Environment: Windows computer with Intel Fortran 12.0 with MS Visual Studio 2008 shell - it has link.exe (9.0) but not the corresponding cl.exe (15.0)
- Project: any simple "hello world" Fortran project will do. I am just doing
project(out Fortran)and then
- Configuration: I configure and generate the project with two generators, "Visual Studio 9 2008" and "NMake Makefiles" (the latter from the command line created by the Intel Fortran-provided equivalent to vcvars.bat)
- Result: the VS project generates out.exe, which has an embedded manifest; while the makefile version generates out.exe without an embedded manifest and an out.exe.manifest alongside it. In order for the latter executable to be usable, the manifest file must either be copied alongside the binary, or manually embedded with a call to mt.exe.
- Expected result: both generators result in executable files with embedded manifests.
I traced the problem to the fact that
Modules/Platforms/Windows-MSVC.cmake (which is included by
Windows-Intel.cmake) tests the
MSVC_VERSION variable (the version of cl.exe) and only enables the manifest embedding if it at least 1400, the version of cl that comes with VS 2005.
This variable is defined above in the same file; in this case it is set from the value of the
CMAKE_Fortran_SIMULATE_VERSION variable, which comes from data extracted from the Intel Fortran compiler by building and running
CMakeFortranCompilerId.F.in. The problem is that, while Intel Fortran in Windows does report the _MSC_VER macro, it reports the same version reported by cl.exe. Since in my case there is no cl.exe to be found, ifort reports _MSC_VER=1020, which is so old that it is stored by CMake as 1300. Thus, the manifest embedding feature is not enabled.
Since having the Intel Fortran compiler without the MS C compiler is a valid configuration, the condition for the manifest embedding feature should depend on detecting features from the linker itself, not the C compiler.