[CMake] WORKING_DIRECTORY from add_custom_target() not setting current directory on windows

Martin Weber m.weber at razorcat.com
Wed Aug 24 09:05:16 EDT 2011


Hi all,

the WORKING_DIRECTORY from add_custom_target() does change the current 
directory properly on windows, if the current directory and the 
directory specified in WORKING_DIRECTORY reside on different drives.
I experienced that with the following command:

add_custom_target(doc
    echo "*** CD-ing:" cd && ${DOXYGEN_EXECUTABLE} 
${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
     WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
     COMMENT "Generating API documentation" VERBATIM
)

which is executed as

[  0%] Generating API documentation
cd D:\develop\ITE\client_automation\src\itecrc-lib && echo "*** CD-ing:" 
&& cd && "C:/Program Files (x86)/doxygen/bin/doxygen.exe" 
C:/Users/m.weber/Documents/.eclipsews/ITE/client_automation/src/itecrc-lib/Doxyfile
"*** CD-ing:"
C:\Users\m.weber\Documents\.eclipsews\ITE\client_automation

I expect
D:\develop\ITE\client_automation\src\itecrc-lib
here.
There problem is caused by the cd-command on windows: To change the 
current directory _and_ the drive, the /D option must be specified.
So 'WORKING_DIRECTORY Z://foo' should translate to
'cd /D  Z://foo' on windows to make it work.

Regards,
  Martin

-- 
E-Mails sollten Text sein, Text und nur Text.
Wenn Gott gewollt hätte, dass E-Mails in HTML geschrieben würden,
endeten Gebete traditionell mit </amen>.


More information about the CMake mailing list