MantisBT - CMake
View Issue Details
0007216CMakeCMakepublic2008-06-20 06:102009-09-01 16:56
Nils Gladitz 
Bill Hoffman 
normalminoralways
closedfixed 
CMake-2-6 
 
0007216: windows icl - manifests not embedded
I tried using the intel compiler (icl) as a replacement for the msvc2005 cl compiler (by setting CC and CXX to icl) in the intel build environment (which in turn is using the msvc build environment) while using the NMake Makefiles generator.

When using cl manifests are embedded into generated executables.
When using icl however external manifest are generated but not embedded into the executables.

The problem now is that those icl build executables will only work properly as long as the manifest file is kept next to the executable; it does not seem to be installed by "install(TARGET ..." though.

Personally I'd prefer it if manifests would be embedded to match the behaviour when using cl.
No tags attached.
? Windows-icl.cmake (3,936) 2008-10-06 03:20
https://public.kitware.com/Bug/file/1749/Windows-icl.cmake
Issue History
2008-06-20 06:10Nils GladitzNew Issue
2008-06-20 16:34Bill HoffmanNote Added: 0012450
2008-06-20 16:34Bill HoffmanStatusnew => assigned
2008-06-20 16:34Bill HoffmanAssigned To => Bill Hoffman
2008-06-23 03:50Nils GladitzNote Added: 0012455
2008-06-23 09:54Bill HoffmanNote Added: 0012460
2008-06-23 10:31Nils GladitzNote Added: 0012462
2008-06-23 10:37Bill HoffmanNote Added: 0012463
2008-06-23 10:48Nils GladitzNote Added: 0012464
2008-06-23 12:06Nils GladitzNote Added: 0012467
2008-06-24 07:34Nils GladitzNote Added: 0012498
2008-10-01 13:43Bill HoffmanNote Added: 0013657
2008-10-06 03:20Nils GladitzFile Added: Windows-icl.cmake
2008-10-06 03:25Nils GladitzNote Added: 0013726
2009-07-08 09:00Simon EvertsNote Added: 0016831
2009-08-06 16:27Bill HoffmanNote Added: 0017078
2009-09-01 16:56Bill HoffmanNote Added: 0017289
2009-09-01 16:56Bill HoffmanNote Added: 0017290
2009-09-01 16:56Bill HoffmanStatusassigned => closed
2009-09-01 16:56Bill HoffmanResolutionopen => fixed

Notes
(0012450)
Bill Hoffman   
2008-06-20 16:34   
Can you try moving the manifest stuff from Platforms/Windows-cl.cmake to Windows-icl.cmake?

 SET(CMAKE_CXX_CREATE_SHARED_LIBRARY "<CMAKE_COMMAND> -E vs_link_dll ${CMAKE_CXX_CREATE_SHARED_LIBRARY}")

instead of

SET(CMAKE_CXX_CREATE_SHARED_LIBRARY
 "link ${CMAKE_CL_NOLOGO} ${CMAKE_START_TEMP_FILE} /out:<TARGET> /dll <LINK_FLAGS> <OBJECTS> <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}")

I don't have an intel compiler to test this one. If it works I can put the change into CMake for you.
(0012455)
Nils Gladitz   
2008-06-23 03:50   
After replacing CMAKE_CXX_CREATE_SHARED_LIBRARY like suggested I get this during build of one of my libraries:

Linking CXX shared library somelib.dll
        "C:\Programme\CMake 2.6\bin\cmake.exe" -E vs_link_dll "C:\Programme\CMak
e 2.6\bin\cmake.exe" -E vs_link_dll
Visual Studio Non-Incremental Link
NMAKE : fatal error U1077: '"C:\Programme\CMake 2.6\bin\cmake.exe"' : return code '0xffffffff'
Stop.

I'm guessing I was actually supposed to replace CMAKE_CXX_LINK_EXECUTABLE etc. as well but that makes cmake segfault during compiler detection(?).
Last message is:
-- Check for working C compiler: C:/Programme/Intel/Compiler/C++/10.1.021/Ia32/B
in/icl.exe
(0012460)
Bill Hoffman   
2008-06-23 09:54   
Can you run make VERBOSE=1 so we can see more output?
(0012462)
Nils Gladitz   
2008-06-23 10:31   
That was already with VERBOSE=1.
Compilation is verbose but it doesn't seem to generate any additional output for the link command.
All that VERBOSE=1 seems to do is to echo the actual program calls with arguments, which for the link above is "C:\Programme\CMake 2.6\bin\cmake.exe" -E vs_link_dll "C:\Programme\CMake 2.6\bin\cmake.exe" -E vs_link_dll".

I tried "cmake -E help" to find out what the command actually does or how to make it more verbose but it seems to be undocumented.
(0012463)
Bill Hoffman   
2008-06-23 10:37   
I think it is in here somewhere:
(do you think you could build cmake from source a debug it?)

int cmake::ParseVisualStudioLinkCommand(std::vector<std::string>& args,
                                        std::vector<cmStdString>& command,
                                        std::string& targetName)
{
  std::vector<std::string>::iterator i = args.begin();
  i++; // skip -E
  i++; // skip vs_link_dll or vs_link_exe
  command.push_back(*i);
  i++; // move past link command
  for(; i != args.end(); ++i)
    {
    command.push_back(*i);
    if(i->find("/Fe") == 0)
      {
      targetName = i->substr(3);
      }
    if(i->find("/out:") == 0)
      {
      targetName = i->substr(5);
      }
    }
  if(targetName.size() == 0 || command.size() == 0)
    {
    return -1;
    }
  return 0;
}
(0012464)
Nils Gladitz   
2008-06-23 10:48   
I tried building a small sample with both msvc and intel to compare output:

msvc:
Linking CXX shared library test.dll
        "C:\Programme\CMake 2.6\bin\cmake.exe" -E vs_link_dll C:\PROGRA~1\MICROS~3\VC\bin\link.exe /nologo @CMakeFiles\test.dir\objects.rsp @C:\DOKUME~1\ngladitz\LOKALE~1\Temp\nm153.tmp
Visual Studio Incremental Link

intel:
Linking CXX shared library test.dll
        "C:\Programme\CMake 2.6\bin\cmake.exe" -E vs_link_dll "C:\Programme\CMake 2.6\bin\cmake.exe" -E vs_link_dll
Visual Studio Non-Incremental Link

I'll give building cmake from source a try.
(0012467)
Nils Gladitz   
2008-06-23 12:06   
I included Platform\cl in Windows-icl.cmake since that seems to be where the linker options seem to come from in Windows-cl.cmake.
The output looks much closer to that of the msvc build now:

"C:\Programme\CMake 2.6\bin\cmake.exe" -E vs_link_dll C:\MinGW\bin\ld.exe /nologo @CMakeFiles\test.dir\objects.rsp @C:\DOKUME~1\ngladitz\LOKALE~1\Temp\nm4E4.tmp
Visual Studio Incremental Link

But the linker should be link.exe not ld.exe.
I'm guessing SET(CMAKE_LINKER link) in cl.cmake should have set that correctly ... I've got no clue why it is using ld instead.
(0012498)
Nils Gladitz   
2008-06-24 07:34   
Apparently CMAKE_LINKER is set to ld.exe before Windows-icl.cmake is run.
Setting CMAKE_LINKER to "link" before the cl.cmake include solves that problem though.
(0013657)
Bill Hoffman   
2008-10-01 13:43   
So, exactly what works here?

SET(CMAKE_CXX_CREATE_SHARED_LIBRARY "<CMAKE_COMMAND> -E vs_link_dll ${CMAKE_CXX_CREATE_SHARED_LIBRARY}")

and where do you set CMAKE_LINKER?
(0013726)
Nils Gladitz   
2008-10-06 03:25   
I attached my modified Windows-icl.cmake (original was included with CMake 2.6.2).
I only made and tested the changes required to properly build c++ executables; the changes for shared libraries would have to be done equivalently.
(0016831)
Simon Everts   
2009-07-08 09:00   
I while ago i had this issue, i resolved it with the Windows-icl.cmake modification and forgot about it.
Just updated to 2.6.4 and my program was crashing again. After searching for a while, i saw that i had added the following to Windows-icl.cmake

--- Windows-icl_original.cmake Tue Apr 28 13:27:58 2009
+++ Windows-icl.cmake Thu Feb 5 08:38:37 2009
@@ -42,6 +42,18 @@
 SET(CMAKE_CXX_LINK_EXECUTABLE
     "<CMAKE_CXX_COMPILER> ${CMAKE_CL_NOLOGO} ${CMAKE_START_TEMP_FILE} <FLAGS> <OBJECTS> /Fe<TARGET> -link <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES>${CMAKE_END_TEMP_FILE}")
 
+IF (${RUNTIME} MATCHES "vc90")
+ SET(CMAKE_CXX_CREATE_SHARED_LIBRARY "<CMAKE_COMMAND> -E vs_link_dll ${CMAKE_CXX_CREATE_SHARED_LIBRARY}")
+ SET(CMAKE_CXX_CREATE_SHARED_MODULE "<CMAKE_COMMAND> -E vs_link_dll ${CMAKE_CXX_CREATE_SHARED_MODULE}")
+ # create a C shared library
+ SET(CMAKE_C_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY}")
+ # create a C shared module just copy the shared library rule
+ SET(CMAKE_C_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_MODULE}")
+ SET(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_COMMAND> -E vs_link_exe ${CMAKE_CXX_LINK_EXECUTABLE}")
+ SET(CMAKE_C_LINK_EXECUTABLE "<CMAKE_COMMAND> -E vs_link_exe ${CMAKE_C_LINK_EXECUTABLE}")
+ENDIF (${RUNTIME} MATCHES "vc90")
+
+
 SET(CMAKE_CREATE_WIN32_EXE /subsystem:windows)
 SET(CMAKE_CREATE_CONSOLE_EXE /subsystem:console)


The "(${RUNTIME} MATCHES "vc90")" is because i use the Intel compiler both in vc6 and in vc9 mode.
(0017078)
Bill Hoffman   
2009-08-06 16:27   
Who sets the RUNTIME thing? What happens if I do this all the time?
(0017289)
Bill Hoffman   
2009-09-01 16:56   
OK, I have this fixed now, works for Fortran, C, and CXX, just did a commit to CVS.
(0017290)
Bill Hoffman   
2009-09-01 16:56   
This is fixed in CVS CMake Sept 1. 2009