Skip to content

[CMake][Visual Studio] Fails to build on source directories containing whitespaces #4268

Closed
@luau-project

Description

@luau-project

Describe the bug
On MSVC dev command prompt (vcvarsall.bat for x64), the build fails when the source directory contains whitespaces.

To Reproduce
Steps to reproduce the behavior:

  1. Open a x64 MSVC dev prompt
  2. Execute the commands below to reproduce the issue
    SET MY_SRC_DIR=%TEMP%\zstd with spaces
    SET MY_BUILD_DIR=%TEMP%\zstd-build-dir
    SET MY_INSTALL_DIR=%TEMP%\zstd-install-dir
    git clone https://github.com/facebook/zstd "%MY_SRC_DIR%"
    cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release --install-prefix "%MY_INSTALL_DIR%" -S "%MY_SRC_DIR%\build\cmake" -B "%MY_BUILD_DIR%"
    cmake --build "%MY_BUILD_DIR%" --config Release

Expected behavior
The build should succeed.

Screenshots and charts

Image

Desktop (please complete the following information):

  • OS: Windows
  • Version: Windows 11, 24H2, OS Build 26100.2894
  • Compiler: MSVC (19.42.34436) for x64 from Visual Studio 2022 Community edition
  • Flags: default from vcvarsall.bat for x64
  • Other relevant hardware specs: N/A
  • Build system: CMake

Additional context
A similar issue has been reported previously #3999, and users told that #4019 fixed it. However, at the time of writing, since the include directory containing whitespaces is unquoted, and the directory is passed AS IS to the command line, the resource compiler fails to work properly.

set(CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS} /I ${LIBRARY_DIR}")

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions