Mihai Neacsu
Mihai Neacsu

Reputation: 2115

CMAKE_BINARY_DIR not expanded correctly if build path contains spaces

How can I solve issues with building a project when the build path contains spaces?

The variable is set like this:

set(CMAKE_BINARY_DIR @CMAKE_BINARY_DIR@)

and is being used a lot specially for generating the build files

file(WRITE "${CMAKE_BINARY_DIR}/CMakeTmp/tcl_version.tcl")

It seems it doesn't escape the space characters (e.g. "~/My Project/").

Upvotes: 0

Views: 463

Answers (1)

configure_file() (as you've mentioned in comments that it's involved) works somewhat like the C preprocessor, in that it's textual substitution. So if you have CMAKE_BINARY_DIR equal to e.g. C:/Program Files, then the configured file will look like this:

set(CMAKE_BINARY_DIR C:/Program Files)

I believe it's obvious that will set CMAKE_BINARY_DIR to a 2-element list. In a normal CMake file, you'd add quotes; so do the same for the source file being configured:

set(CMAKE_BINARY_DIR "@CMAKE_BINARY_DIR@")

Upvotes: 1

Related Questions