Ninja not found by CMake

后端 未结 3 1075
醉话见心
醉话见心 2020-12-17 16:09

I\'m trying to build some code I got from GitHub using CMake, but keep getting the followings errors:

CMake Error: CMake was unable to find a build program c         


        
3条回答
  •  無奈伤痛
    2020-12-17 17:06

    My solution: symlink "ninja-build" to "ninja".

    # ln -s /usr/bin/ninja /usr/bin/ninja-build
    

    This only works on very old versions of CMake, which I will explain below.

    I had already dropped my fresh "ninja" binary into /usr/bin and checked it had 0755 permissions. I was stumped until I ran an strace on the generator command.

    # strace cmake -GNinja .. | grep -i ninja
    access("ninja-build", R_OK)             = -1 ENOENT (No such file or directory)
    access("/usr/local/sbin/ninja-build", R_OK) = -1 ENOENT (No such file or directory)
    access("/usr/local/bin/ninja-build", R_OK) = -1 ENOENT (No such file or directory)
    access("/sbin/ninja-build", R_OK)       = -1 ENOENT (No such file or directory)
    access("/bin/ninja-build", R_OK)        = -1 ENOENT (No such file or directory)
    access("/usr/sbin/ninja-build", R_OK)   = -1 ENOENT (No such file or directory)
    access("/usr/bin/ninja-build", R_OK)    = -1 ENOENT (No such file or directory)
    access("/opt/texlive/2016/bin/i386-linux/ninja-build", R_OK) = -1 ENOENT (No such file or directory)
    access("/root/bin/ninja-build", R_OK)   = -1 ENOENT (No such file or directory)
    

    It was looking for "ninja-build", not "ninja"!

    I use CMake with Ninja extensively at work and at home, on Windows and Linux. So why haven't I seen this bug before?

    Well... in this instance I'm using a very old version of CMake, version 2.8.12. It's so old it's almost fossilised. So presumably it's either a CMake bug which was fixed later, or the Ninja project changed the name of the binary at some point.

提交回复
热议问题