MantisBT - CMake
View Issue Details
0015808CMakeCMakepublic2015-10-25 22:242016-03-07 09:12
ovz 
 
highblockalways
closedno change required 
Windows 8.1
 
 
0015808: POST_BUILD command for "Visual Studio 14 2015" generates superfluous "C:"
If I specify WORKING_DIRECTORY in add_custom_command(... POST_BUILD ..) the following snippet is generated in Post-Build event code. Note that extra command specifying just "C:" after expected cd command.

setlocal
cd C:\__temp\src\cmake\post_build_work_dir\build\working_dir
if %errorlevel% neq 0 goto :cmEnd
C:
if %errorlevel% neq 0 goto :cmEnd


* Unpack post_build_work_dir.zip in attachment.

* You can inspect contents of the build directory. These are CMake generated files I get on my machine.

* Clean up build directory

* Run commands

cd build
cmake -G "Visual Studio 14 2015" ..

* Open build/post_build_work_dir.sln

* In Visual Studio right-click on post_build_work_dir project. Select Properties

* Navigate to Configuration Properties > Build Events > Post-Build Event

* Note the extra "C:" command in the post-build event text



Here is full text of Post-Build event generated after following steps of reproduction

setlocal
cd C:\__temp\src\cmake\post_build_work_dir\build\working_dir
if %errorlevel% neq 0 goto :cmEnd
C:
if %errorlevel% neq 0 goto :cmEnd
some_command
if %errorlevel% neq 0 goto :cmEnd
:cmEnd
endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
:cmErrorLevel
exit /b %1
:cmDone
if %errorlevel% neq 0 goto :VCEnd
No tags attached.
zip post_build_work_dir.zip (106,879) 2015-10-25 22:24
https://public.kitware.com/Bug/file/5558/post_build_work_dir.zip
Issue History
2015-10-25 22:24ovzNew Issue
2015-10-25 22:24ovzFile Added: post_build_work_dir.zip
2015-10-25 22:26ovzNote Added: 0039674
2015-10-26 08:41Brad KingNote Added: 0039675
2015-10-26 11:24ovzNote Added: 0039678
2015-10-26 12:03Brad KingStatusnew => resolved
2015-10-26 12:03Brad KingResolutionopen => no change required
2015-10-27 15:02Gregor JasnyNote Added: 0039685
2015-10-27 15:08Brad KingNote Added: 0039686
2016-03-07 09:12Robert MaynardNote Added: 0040627
2016-03-07 09:12Robert MaynardStatusresolved => closed

Notes
(0039674)
ovz   
2015-10-25 22:26   
Reproduced with both CMake 3.3.2 and CMake 3.4.0-rc2
(0039675)
Brad King   
2015-10-26 08:41   
The "C:" command ensures that the current working drive is correct. The "cd c:\..." command only changes the working directory for the given drive.
(0039678)
ovz   
2015-10-26 11:24   
Makes sense. Haven't worked with multiple drives for some time already.

We can close this issue.
(0039685)
Gregor Jasny   
2015-10-27 15:02   
You could use /d switch for cd command to also change drive: http://ss64.com/nt/cd.html [^]
(0039686)
Brad King   
2015-10-27 15:08   
Re 0015808:0039685: That's not portable to older cmd versions.
(0040627)
Robert Maynard   
2016-03-07 09:12   
Closing resolved issues that have not been updated in more than 4 months.