I'm a newbie to CMake and am trying to understand how to configure CMake to use Ninja as the build tool. The specific problem I'm having is I'm trying to install YouCompleteMe plugin for vim using their install.py. I get the following error:
Searching Python 3.8 libraries...
Found Python library: /usr/lib64/libpython3.8.so
Found Python headers folder: /usr/include/python3.8
CMake Error: CMake was unable to find a build program corresponding to "Unix Makefiles". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
See also "/tmp/ycm_build__dy3xdvd/CMakeFiles/CMakeOutput.log".
ERROR: the build failed.
After looking similar errors up on the internet I realise that I can fix this by installing Make. But, I'm wondering if I can actually use Ninja instead of Make which I have already installed and is in the path. Is there a way I can set CMAKE_MAKE_PROGRAM
to my Ninja installation so that I can get past this error or do I have to use Make because CMAKE_MAKE_PROGRAM
can only be set from within the project?
EDIT:
When I say set the CMAKE_MAKE_PROGRAM
, I mean at the machine level like an environment variable. Not by modifying the build definition files in the actual project I'm trying to build.
You should set the environment variable CMAKE_GENERATOR
to Ninja
. CMake will read this variable to choose the generator, rather than picking the default "Unix Makefiles" you are seeing. This is useful when you are not calling cmake
directly and cannot pass the -G
command line option to set the generator.
The CMAKE_GENERATOR
variable will end up setting the CMAKE_MAKE_PROGRAM
variable for you, so you should not have to modify this manually.