xmake-io / xmake

🔥 A cross-platform build utility based on Lua
https://xmake.io
Apache License 2.0
9.84k stars 776 forks source link

Having a directory with spaces as an include directory doesn't quite work. #1235

Closed SirLynix closed 3 years ago

SirLynix commented 3 years ago

Describe the bug

I'm using

add_sysincludedirs([[C:\Program Files\Azure Kinect SDK v1.4.1\sdk/include]])

to use Azure Kinect SDK.

The problem is that xmake generate that command-like:

[ 11%]: compiling.debug src\obs-kinect-azuresdk\AzureKinectDevice.cpp
"C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.28.29333\\bin\\HostX64\\x64\\cl.exe" -c /EHsc -nologo -Zi -FS -Fdbin\windows_x64_debug\compile.obs-kinect-azuresdk.pdb -W4-Od -std:c++17 -MDd -Iinclude -DNOMINMAX -DWIN32_LEAN_AND_MEAN -experimental:external -external:W0 -external:I..\obs-studio\libobs "-external:I\"C:\\\\Program Files\\\\Azure Kinect SDK v1.4.1\\\\sdk\\\\include\"" /Zc:__cplusplus /Zc:referenceBinding /Zc:throwingNew /w44062 /wd4251 -Fobuild\.objs\obs-kinect-azuresdk\windows\x64\debug\src\obs-kinect-azuresdk\AzureKinectDevice.cpp.obj src\obs-kinect-azuresdk\AzureKinectDevice.cpp

Which leads to errors:

error: @programdir\modules\private\async\runjobs.lua:217: @programdir\modules\private\action\build\object.lua:78: @programdir\modules\core\tools\cl.lua:455: AzureKinectPlugin.cpp
c1xx: warning C5044: An argument to command-line option /external:I points to a path 'c:\projets\obs-kinect\obs-kinect\"c:\program files\azure kinect sdk v1.4.1\sdk\include"' that does not exist
C:\Projets\obs-kinect\obs-kinect\src\obs-kinect-azuresdk\AzureKinectDevice.hpp(25): fatal error C1083: cannot open include file: 'k4a/k4a.hpp' : No such file or directory

Notice how cl.exe seems to understand the path as a relative one (c:\projets\obs-kinect\obs-kinect is my working folder).

I managed to fix this by replacing this part

"-external:I\"C:\\\\Program Files\\\\Azure Kinect SDK v1.4.1\\\\sdk\\\\include\""

to

"-external:IC:\\Program Files\\Azure Kinect SDK v1.4.1\\sdk\\include\\"

And of course the files exist on my computer: image

Expected behavior

That xmake generates a working argument when spaces are used.

Related Environment

Please provide compiling and running environment information:

waruqi commented 3 years ago

I will fix it in these days.

waruqi commented 3 years ago

I have fixed it on space branch. you can try it first. I will merge into dev If it works.

SirLynix commented 3 years ago

It works! Thank you.

waruqi commented 3 years ago

Ok, I have merged into dev.