MantisBT - CMake
View Issue Details
0008817CMakeCMakepublic2009-03-30 11:302016-06-10 14:30
Derek Bruening 
Bill Hoffman 
normalfeaturealways
closedmoved 
CMake-2-6 
 
0008817: support MSYS shell with MSVC: use - instead of / for cl params
It's not possible to use any of "NMake Makefiles", "Unix Makefiles", or "MSYS Makefiles" from the MSYS shell with the Microsoft compiler (cl.exe). This is due to the MSYS "automagic path conversion" where any command-line string beginning with "/" has the MSYS drive prefix prepended. While ideally MSYS would provide an option to disable the conversion, that's not the case today, and if CMake provided an option to use "-" instead of "/" as a parameter delimiter then everything would work just fine.

The "/" leads to errors like the following in an MSYS shell:

  cl : Command line warning D9027 : source file 'C:/msys/1.0/nologo' ignored

It causes errors in configuration which are fatal for nmake (due to /nologo being passed to nmake, I believe) but only show up in ABI testing for Unix or MSYS Makefiles (shown below). The ABI errors are not fatal and running cmake again results in a "successful" configuration. However in order to build I have to replace all the / param delimiters with -:

  perl -pi.bak -e 's| /| -|g' `find . -name \*.make`
  perl -pi.bak -e 's| -bin| /bin|g' `find . -name \*.make`

Furthermore, cmake has hardcoded strings that expect / instead of -.
cmake::ParseVisualStudioLinkCommand hardcodes "/out:". Also in cmake.cxx: /INCREMENTAL:YES, etc. So I eliminated the vs_link_dll command in order for linking to actually occur (is a nop with "-out" instead of "/out"):

  perl -pi.bak -e 's|"C:/Program Files \(x86\)/CMake 2.6/bin/cmake.exe" -E vs_link_dll||' `find . -name \*.make`

With these changes I can build using "Unix Makefiles". I have to make further changes to use "MSYS Makefiles" because of another issue: MSYS Makefiles use unix paths even when using MSVC. The (one-sentence) documentation for "MSYS Makefiles" implies that its only difference from "Unix Makefiles" is in using the MSYS shell but clearly that's not the case.

The errors in configuration with Unix or MSYS Makefiles:

-- The C compiler identification is MSVC
-- The CXX compiler identification is MSVC
-- Check for CL compiler version
-- Check for CL compiler version - 1400
-- Check if this is a free VC compiler
-- Check if this is a free VC compiler - yes
-- Check CL platform
-- Check CL platform - 64 bit
-- Check for working C compiler: c:/PROGRA~2/MICROS~2/VC/Bin/cl.exe
-- Check for working C compiler: c:/PROGRA~2/MICROS~2/VC/Bin/cl.exe -- works
-- Detecting C compiler ABI info
CMake Error: Could not COPY_FILE.
  OutputFile: ''
    copyFile: 'C:/derek/opensource/build_msys/CMakeFiles/CMakeDetermineCompilerABI_C.bin'

-- Detecting C compiler ABI info - done
CMake Error at C:/Program Files (x86)/CMake 2.6/share/cmake-2.6/Modules/CMakeDetermineCompilerABI.cmake:23 (FILE):
  file STRINGS file
  "C:/derek/opensource/build_msys/CMakeFiles/CMakeDetermineCompilerABI_C.bin"
  cannot be read.
Call Stack (most recent call first):
  C:/Program Files (x86)/CMake 2.6/share/cmake-2.6/Modules/CMakeTestCCompiler.cmake:51 (CMAKE_DETERMINE_COMPILER_ABI)
  CMakeLists.txt:69 (project)


-- Check for working CXX compiler: c:/PROGRA~2/MICROS~2/VC/Bin/cl.exe
-- Check for working CXX compiler: c:/PROGRA~2/MICROS~2/VC/Bin/cl.exe -- works
-- Detecting CXX compiler ABI info
CMake Error: Could not COPY_FILE.
  OutputFile: ''
    copyFile: 'C:/derek/opensource/build_msys/CMakeFiles/CMakeDetermineCompilerABI_CXX.bin'

-- Detecting CXX compiler ABI info - done
CMake Error at C:/Program Files (x86)/CMake 2.6/share/cmake-2.6/Modules/CMakeDetermineCompilerABI.cmake:23 (FILE):
  file STRINGS file
  "C:/derek/opensource/build_msys/CMakeFiles/CMakeDetermineCompilerABI_CXX.bin"
  cannot be read.
Call Stack (most recent call first):
  C:/Program Files (x86)/CMake 2.6/share/cmake-2.6/Modules/CMakeTestCXXCompiler.cmake:44 (CMAKE_DETERMINE_COMPILER_ABI)
  CMakeLists.txt:69 (project)
No tags attached.
Issue History
2009-03-30 11:30Derek BrueningNew Issue
2009-03-31 14:00Bill HoffmanNote Added: 0015865
2009-03-31 14:00Bill HoffmanStatusnew => assigned
2009-03-31 14:00Bill HoffmanAssigned To => Bill Hoffman
2009-03-31 14:24Derek BrueningNote Added: 0015869
2009-03-31 14:36Bill HoffmanNote Added: 0015871
2016-06-10 14:27Kitware RobotNote Added: 0041533
2016-06-10 14:27Kitware RobotStatusassigned => resolved
2016-06-10 14:27Kitware RobotResolutionopen => moved
2016-06-10 14:30Kitware RobotStatusresolved => closed

Notes
(0015865)
Bill Hoffman   
2009-03-31 14:00   
MSYS makfiles are meant to be used with the msys compiler. There are just too many odd things about msys to support it for the ms compilers. I use ms compilers with the cygwin gmake, and that works well.
(0015869)
Derek Bruening   
2009-03-31 14:24   
I don't think there is an msys compiler: it's usually coupled with the MinGW version of gcc, and you have a separate MinGW makefile target, hence the confusion. If you intend not to support MSVC from the MSYS shell then I would suggest augmenting the --help and documentation for MSYS makefiles to indicate that: I thought at first glance that the MSYS makefile target, as opposed to Unix makefiles, was meant for use in the msys shell and would thus have workarounds for /param issues.

For my project the /param issue was the only one I encountered: substituting -param enabled me to build just fine from the msys shell using MSVC. Doing so is 15%-25% faster than using cygwin gmake with MSVC, which makes it worthwhile.
(0015871)
Bill Hoffman   
2009-03-31 14:36   
Does the msys gmake handle parallel builds?
(0041533)
Kitware Robot   
2016-06-10 14:27   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.