CMake generated Makefiles don't work when the "make" program resides in a directory containing spaces.
The various Makefiles generated by CMake (version 3.15.3) frequently make use of the $(MAKE)
variable to call into the make
program. For example, in the main Makefile, the generated main all
target looks like this:
# The main all target
all: cmake_check_build_system
$(CMAKE_COMMAND) -E cmake_progress_start "/path/to/CMakeFiles" "/path/to/CMakeFiles/progress.marks"
$(MAKE) -f CMakeFiles/Makefile2 all
$(CMAKE_COMMAND) -E cmake_progress_start "/path/to/CMakeFiles" 0
.PHONY : all
When the path to the make
program contains spaces (e.g., when using custom toolchains), these calls seem to not be properly quoted when $(MAKE)
is invoked, leading to errors as the program is not found. This can be visualized by setting CMAKE_VERBOSE_MAKEFILE
to 1
. Note that $(CMAKE_COMMAND)
invocations are handled correctly, it is only the $(MAKE)
invocations that lack quotes.
In this particular example, by quoting $(MAKE)
, as in "$(MAKE)" -f CMakeFiles/Makefile2 all
, the make
step succeeds, but compilation fails shortly after as $(MAKE)
is used in quite a few places.