[CMake] CMake [nmake target] is adding backslash at end of cd command

André Netzeband netbandit at gmx.de
Fri Sep 4 10:17:17 EDT 2015


Hi

I have a very strange issue with generated nmake makefiles from cmake 3.3.1
In a very complex project with many sub-cmake files (Ogre3D) the 
generated nmake makefiles (build.make) contain backslashes at the end of 
some cd commands. Like this:

lib\OgreSamplesCommon_d.lib: 
Samples\2.0\Common\CMakeFiles\OgreSamplesCommon.dir\src\BaseSystem.cpp.obj
lib\OgreSamplesCommon_d.lib: 
Samples\2.0\Common\CMakeFiles\OgreSamplesCommon.dir\src\CameraController.cpp.obj
lib\OgreSamplesCommon_d.lib: 
Samples\2.0\Common\CMakeFiles\OgreSamplesCommon.dir\src\GameEntityManager.cpp.obj
lib\OgreSamplesCommon_d.lib: 
Samples\2.0\Common\CMakeFiles\OgreSamplesCommon.dir\src\GraphicsSystem.cpp.obj
lib\OgreSamplesCommon_d.lib: 
Samples\2.0\Common\CMakeFiles\OgreSamplesCommon.dir\src\LogicSystem.cpp.obj
lib\OgreSamplesCommon_d.lib: 
Samples\2.0\Common\CMakeFiles\OgreSamplesCommon.dir\src\SdlInputHandler.cpp.obj
lib\OgreSamplesCommon_d.lib: 
Samples\2.0\Common\CMakeFiles\OgreSamplesCommon.dir\src\Threading\MessageQueueSystem.cpp.obj
lib\OgreSamplesCommon_d.lib: 
Samples\2.0\Common\CMakeFiles\OgreSamplesCommon.dir\src\TutorialGameState.cpp.obj
lib\OgreSamplesCommon_d.lib: 
Samples\2.0\Common\CMakeFiles\OgreSamplesCommon.dir\src\Utils\HdrUtils.cpp.obj
lib\OgreSamplesCommon_d.lib: 
Samples\2.0\Common\CMakeFiles\OgreSamplesCommon.dir\build.make
lib\OgreSamplesCommon_d.lib: 
Samples\2.0\Common\CMakeFiles\OgreSamplesCommon.dir\objects1.rsp
     @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green 
--bold 
--progress-dir=D:\Projects\CPP\Libraries\Ogre3D\ogre\build-vc64\CMakeFiles 
--progress-num=$(CMAKE_PROGRESS_10) "Linking CXX static library 
..\..\..\lib\OgreSamplesCommon_d.lib"
     cd Samples\2.0\Common
     $(CMAKE_COMMAND) -P 
CMakeFiles\OgreSamplesCommon.dir\cmake_clean_target.cmake
     cd ..\..\..\
     cd Samples\2.0\Common
     D:\Compiler\MVS14.0\VC\bin\amd64\link.exe /lib 
/out:..\..\..\lib\OgreSamplesCommon_d.lib 
@CMakeFiles\OgreSamplesCommon.dir\objects1.rsp
     cd ..\..\..\

Unfortunately these backslashes at the end of cd ..\..\..\ are 
interpreted as multi-line backslashes. Thus the makefile will not do this:
cd ..\..\..
cd Samples\2.0\Common

But it will do this:
cd ..\..\.. cd Samples\2.0\Common

And of course this is not a correct command.
I searched a lot in the internet to find a hint, how to prevent such a 
behaviour, but I was not able to find any answer. Also all the other 
projects I have compiled that uses cmake do not have a single cd in the 
build.make file. So I was not able to check if this is a general issue 
of cmake.

Is this an error of cmake or is something wrong configured in the project?
What forces cmake in this project to change the directory so often and 
why does cmake not add any cd commands to other project using cmake? Is 
there an option to prevent cd-command generation and using absolute 
paths for all files?

Best regards,
André


More information about the CMake mailing list