Using the WORKING_DIRECTORY option in add_custom_command completely breaks the generated build step. For an unknown reason, CMake generates an extra line which is usually just “driveletter:” (C:, D:, E:, …).
setlocal
cd C:\Tools
if %errorlevel% neq 0 goto :cmEnd
C: // <-- This is the problem, where does it even come from?
if %errorlevel% neq 0 goto :cmEnd
"C:\Program Files\LLVM\bin\clang-tidy.exe" D:\Projects\Xaymar\obs-studio\build\64\UI\frontend-plugins\streamfx\source\module.cpp
if %errorlevel% neq 0 goto :cmEnd
:cmEnd
endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
:cmErrorLevel
exit /b %1
:cmDone
target_binary_dir only contains “C:\Tools”, no other entries.
CLANG_TIDY_BIN is the path to clang-tidy.exe
_target is the current target name.
_el is the target source file
Anyone have any idea why this happens, and how to actually solve it?
It is also advised to always double-quote paths, since some function might interpret a single path containing spaces as several space-separated arguments.
Neither cmake-style paths or native paths work unfortunately, it was one of the first things I tried. Even manually giving it “…/Tools” (autoformatting turns it into …, but its two .) still added a nonsense C: to it.
cd C:\Tools changes the working directory of the C: drive to C:\Tools. But if the current drive is X: then an addition C: has to be done to switch the drive.
Is it really adding C: //? Because that would be a problem.
Otherwise why would having C: be a problem at all?
Hi McMartin, you can achieve the same with “cd /D”. The second D: there actually returns a failure, so the script aborts at that moment. Which is my current problem.
Did some additional testing now. The commands start working when the drive is not a network mounted drive, or an NTFS mounted directory. I suppose that is an acceptable limitation, though ‘cd /D’ doesn’t seem have this limitation. Will just move the project and necessary files to local directories instead.
/D is an option that must be passed to the directory-changing cd command, and means “also change the drive if applicable.” So the correct syntax would be