MantisBT - CMake
View Issue Details
0015175CMakeCMakepublic2014-09-28 14:262015-03-02 08:57
Ian Harvey 
Brad King 
normalfeaturesometimes
closedfixed 
CMake 3.0.2 
CMake 3.1CMake 3.1 
0015175: Add support for Intel Fortran 15.0 Visual Studio
A change to the behaviour of the Visual Studio integration with ifort 15.0 means that executable and DLL projects that have the base part of the output filename different to the name of the project need to have the TargetName property set for the project, or the integration will issue warnings during the build and the manifest tool will fail (an EXE or DLL may still be produced).
With the following Fortran source in a file named HelloWorld.f90:

  IMPLICIT NONE
  PRINT "('Hello world')"
  END


and the following CMakeLists.txt in the same directory as above:

  cmake_minimum_required(VERSION 3.0.2)
  project(helloworld Fortran)
  add_executable(helloworld "HelloWorld.f90")
  set_target_properties(helloworld PROPERTIES OUTPUT_NAME foobar)


From within an Intel Fortran command prompt in a build subdirectory run cmake:

  >"c:\Program Files (x86)\CMake\bin\cmake.exe" ..
  -- Building for: Visual Studio 10 2010
  -- The Fortran compiler identification is Intel
  -- Check for working Fortran compiler using: Visual Studio 10 2010
  -- Check for working Fortran compiler using: Visual Studio 10 2010 -- works
  -- Detecting Fortran compiler ABI info
  -- Detecting Fortran compiler ABI info - done
  -- Determine Intel Fortran Compiler Implicit Link Path
  -- Determine Intel Fortran Compiler Implicit Link Path -- done
  -- Checking whether C:/Program Files (x86)/Intel/Composer XE 2015/bin/ia32/ifort.exe supports Fortran 90
  -- Checking whether C:/Program Files (x86)/Intel/Composer XE 2015/bin/ia32/ifort.exe supports Fortran 90 -- yes
  -- Configuring done
  -- Generating done
  -- Build files have been written to: H:/Projects/cmake-test/build


Use cmake to then build the generated solution:

>"c:\Program Files (x86)\CMake\bin\cmake.exe" --build .
1>------ Build started: Project: ZERO_CHECK, Configuration: Debug Win32 ------
1> Checking Build System
1> CMake does not need to re-run because H:/Projects/cmake-test/build/CMakeFiles/generate.stamp is up-to-date.
2>------ Build started: Project: helloworld, Configuration: Debug Win32 ------
2>helloworld: warning: TargetPath(H:\Projects\cmake-test\build\Debug\helloworld.exe) does not match the Linker's OutputF
ile property value (H:\Projects\cmake-test\build\Debug\foobar.exe). This may cause your project to build incorrectly. To
 correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified
 in %(Link.OutputFile).
2>Compiling with Intel(R) Visual Fortran Compiler XE 15.0.0.108 [IA-32]...
2>HelloWorld.f90
2>Compiling manifest to resources...
2>Microsoft (R) Windows (R) Resource Compiler Version 6.1.7600.16385
2>Copyright (C) Microsoft Corporation. All rights reserved.
2>Linking...
2>Microsoft (R) Incremental Linker Version 10.00.40219.01
2>Copyright (C) Microsoft Corporation. All rights reserved.
2>/OUT:H:\Projects\cmake-test\build\Debug\foobar.exe
2>/VERSION:0.0
2>/MANIFEST
2>/MANIFESTFILE:helloworld.dir\Debug\helloworld.exe.intermediate.manifest
2>"/MANIFESTUAC:level='asInvoker' uiAccess='false'"
2>/DEBUG
2>/PDB:H:\Projects\cmake-test\build\Debug/foobar.pdb
2>/SUBSYSTEM:CONSOLE
2>/IMPLIB:H:\Projects\cmake-test\build\Debug\foobar.lib
2>user32.lib
2>/machine:X86
2>/debug
2>/INCREMENTAL
2>helloworld.dir\Debug\HelloWorld.obj
2>helloworld.dir\Debug\helloworld.exe.embed.manifest.res
2>Embedding manifest...
2>mt.exe : general error c10100b1: Failed to load file "H:\Projects\cmake-test\build\Debug\helloworld.exe". The system c
annot find the file specified.
2>
2>Build log written to "file://H:\Projects\cmake-test\build\helloworld.dir\Debug\BuildLog.htm" [^]
2>helloworld - 1 error(s), 1 warning(s)
3>------ Build started: Project: ALL_BUILD, Configuration: Debug Win32 ------
3> Building Custom Rule H:/Projects/cmake-test/CMakeLists.txt
3> CMake does not need to re-run because H:\Projects\cmake-test\build\CMakeFiles\generate.stamp is up-to-date.
3> Build all projects
========== Build: 3 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
This patch applied to cmLocalVisualStudio7Generator.cxx is a crude fix.

637a638,641
>
> // stolen from cmGlobalVisualStudio7Generator.cxx
> #define CM_INTEL_PLUGIN_GUID "{B68A201D-CB9B-47AF-A52F-7EEC72E217E4}"
>
651a656,677
> // ifort 15.0 integration uses TargetName property. Installed integration
> // version test lifted from cmGlobalVisualStudio7Generator.cxx.
> unsigned int intelVersionNumber = ~0u;
> if (this->FortranProject) {
> cmGlobalVisualStudio7Generator* gg =
> static_cast<cmGlobalVisualStudio7Generator *>(
> this->GlobalGenerator );
> std::string intel_registry_version;
> std::string vskey = gg->GetRegistryBase();
> vskey += "\\Packages\\" CM_INTEL_PLUGIN_GUID ";ProductVersion";
> cmSystemTools::ReadRegistryValue(vskey.c_str(), intel_registry_version,
> cmSystemTools::KeyWOW64_32);
> sscanf(intel_registry_version.c_str(), "%u", &intelVersionNumber);
> if (intelVersionNumber == 15) {
> std::string prefix;
> std::string base;
> std::string suffix;
> target.GetFullNameComponents(prefix, base, suffix);
> fout << "\t\t\tTargetName=\"" << this->EscapeForXML(base.c_str())
> << "\"\n";
> }
> }
No tags attached.
patch a22570ea+0001-VS-Fix-Intel-Fortran-15-.vfproj-TargetName-15175.patch (3,971) 2014-09-29 10:13
https://public.kitware.com/Bug/file/5264/a22570ea%2B0001-VS-Fix-Intel-Fortran-15-.vfproj-TargetName-15175.patch
? bazaar.vfproj-as-generated (19,931) 2014-09-29 21:56
https://public.kitware.com/Bug/file/5265/bazaar.vfproj-as-generated
? bazaar.vfproj-after-opening (17,592) 2014-09-29 21:56
https://public.kitware.com/Bug/file/5266/bazaar.vfproj-after-opening
Issue History
2014-09-28 14:26Ian HarveyNew Issue
2014-09-29 10:13Brad KingFile Added: a22570ea+0001-VS-Fix-Intel-Fortran-15-.vfproj-TargetName-15175.patch
2014-09-29 10:18Brad KingNote Added: 0036872
2014-09-29 10:19Brad KingAssigned To => Brad King
2014-09-29 10:19Brad KingSeverityminor => feature
2014-09-29 10:19Brad KingStatusnew => assigned
2014-09-29 10:19Brad KingTarget Version => CMake 3.1
2014-09-29 10:19Brad KingSummaryIntel Fortran 15.0 Visual Studio integration requires TargetName property for renamed targets => Add support for Intel Fortran 15.0 Visual Studio
2014-09-29 10:19Brad KingNote Edited: 0036872bug_revision_view_page.php?bugnote_id=36872#r1583
2014-09-29 21:56Ian HarveyFile Added: bazaar.vfproj-as-generated
2014-09-29 21:56Ian HarveyFile Added: bazaar.vfproj-after-opening
2014-09-29 22:01Ian HarveyNote Added: 0036874
2014-09-30 08:26Brad KingNote Added: 0036875
2014-09-30 08:26Brad KingStatusassigned => resolved
2014-09-30 08:26Brad KingResolutionopen => fixed
2014-09-30 08:26Brad KingFixed in Version => CMake 3.1
2015-03-02 08:57Robert MaynardNote Added: 0038133
2015-03-02 08:57Robert MaynardStatusresolved => closed

Notes
(0036872)
Brad King   
2014-09-29 10:18   
(edited on: 2014-09-29 10:19)
The error message talks about both TargetName and TargetExt. These are set in our VS >= 10 generator:

 http://www.cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmVisualStudio10TargetGenerator.cxx;hb=v3.0.2#l1249 [^]

I backported them to the .vfproj generator. Please try the attached a22570ea+0001-VS-Fix-Intel-Fortran-15-.vfproj-TargetName-15175.patch file. It is based on commit a22570ea in our Git 'master' branch (see http://cmake.org/cmake.git [^] ).

However, there may be a larger effort needed. It looks like Intel Fortran 15 for Visual Studio only supports VS >= 10, which leads me to guess that they have ported from the old devenv-driven .vfproj file format to a modern msbuild-driven .vcxproj file format. Can you check/confirm this, please? Their plugin may be updating automatically between the formats so the old generator appears to work except for the TargetName/TargetExt problem.

(0036874)
Ian Harvey   
2014-09-29 22:01   
A support range of the last three versions of Visual Studio is typical for ifort (if not policy). They are still using the devenv based file format. Automatic update (on opening a solution with the new integration) to existing vfproj files used with previous versions of the integration appears to be limited to the addition of TargetName and TargetExt and (perhaps unconditional) listing of the manifest tool. Example of the automatic changes made to a cmake generated project (with your patch applied attached).

Your patch works for me!
(0036875)
Brad King   
2014-09-30 08:26   
Thanks for testing. I've committed the patch here:

 VS: Support Intel Fortran 15 .vfproj generation
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a128129a [^]
(0038133)
Robert Maynard   
2015-03-02 08:57   
Closing resolved issues that have not been updated in more than 4 months.