Skip to content

CMake can't find C or CXX compiler if Xcode has a space in the name

I thought I should note this down as it confused me. If you have Xcode with a space in the name (e.g. "Xcode-beta 2.app") then the compiler detection cannot find the paths. I used xcode-select -s to set my default xcode to "Xcode-beta 2.app" in my downloads folder. I added a debug print to CMakeDetermineCompilerId.cmake and _comp came out as /Users/hmallon/Downloads/Xcode-beta\ (skipping everything after the escaped space).

% cmake -GXcode ../                                              
-- The C compiler identification is AppleClang 12.0.0.12000022
-- The CXX compiler identification is AppleClang 12.0.0.12000022
CMake Error at CMakeLists.txt:48 (project):
  No CMAKE_C_COMPILER could be found.



CMake Error at CMakeLists.txt:48 (project):
  No CMAKE_CXX_COMPILER could be found.



-- Configuring incomplete, errors occurred!
See also "/Users/hmallon/Development/hde/build/CMakeFiles/CMakeOutput.log".
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information