系统环境:
$ lsb_release -a
LSB Version: :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: CentOS
Description: CentOS release 6.8 (Final)
Release: 6.8
Codename: Final
$ getconf LONG_BIT $ which cmake
/usr/bin/cmake
$ cmake --version
cmake version 2.8.12.2
$ which ninja
/usr/bin/ninja
$ ninja --version
1.7.
问题:使用cmake工具且选用Ninja作为编译工具(build program)时,报错,找不到Ninja的程序,具体信息如下:
CMake Error: CMake was unable to find a build program corresponding to "Ninja". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_C_COMPILER
CMake Error: Could not find cmake module file: /home/jgeng/avs2-build/CMakeFiles/2.8.12.2/CMakeCCompiler.cmake
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_CXX_COMPILER_ENV_VAR
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_CXX_COMPILER
CMake Error: Could not find cmake module file: /home/jgeng/avs2-build/CMakeFiles/2.8.12.2/CMakeCXXCompiler.cmake
-- Configuring incomplete, errors occurred!
解决方法:
# ln -s /usr/bin/ninja /usr/bin/ninja-build
# strace cmake -GNinja .. | grep -i ninja
access("ninja-build", R_OK) = - ENOENT (No such file or directory)
access("/usr/local/sbin/ninja-build", R_OK) = - ENOENT (No such file or directory)
access("/usr/local/bin/ninja-build", R_OK) = - ENOENT (No such file or directory)
access("/sbin/ninja-build", R_OK) = - ENOENT (No such file or directory)
access("/bin/ninja-build", R_OK) = - ENOENT (No such file or directory)
access("/usr/sbin/ninja-build", R_OK) = - ENOENT (No such file or directory)
access("/usr/bin/ninja-build", R_OK) = - ENOENT (No such file or directory)
cmake 在设置build program的时候找的是ninja-build程序,而不是ninja程序。
参考:https://*.com/questions/38658014/ninja-not-found-by-cmake