GNUtoMS_lib.bat.in appears broken for Visual Studio 2017 Community (15.3.3)
Conditions to reproduce:
- CMake 3.9.1
- Visual Studio 2017 and MinGW are on drive c:
- My project is on drive e:
- CMake generates
GNUtoMS_lib.bat
from$CMAKE_ROOT/share/cmake-3.9/Modules/Platform/GNUtoMS_lib.bat.in
with the following content
@echo off
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars32.bat"
lib /machine:"x86" %*
- Sourcing
vcvars32.bat
changes my current working directory toC:\Users\%USERNAME%\source
and the arguments given to the batch file (filenames w/o path) are not longer valid.
Proposed fix:
- Modify
$CMAKE_ROOT/share/cmake-3.9/Modules/Platform/GNUtoMS_lib.bat.in
to save and restore the current working directory beforelib
is executed:
@echo off
+ set CWD=%CD% &rem save the current directory
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars32.bat"
+ chdir /d %CWD% &rem restore current working directory
lib /machine:"x86" %*
I just stumbled across this:
- Possibly fixed by f362052b