meganz / iOS

MEGA for iOS
https://apps.apple.com/app/mega/id706857885?mt=8
Other
342 stars 95 forks source link

cmake: command not found, but I've installed it. #79

Closed 0x-matt closed 1 year ago

0x-matt commented 1 year ago

General Information

What happened?

Xcode throw an error 'cmake: command not found' of PhaseScriptExecution when compiling.

/Users/saint/Library/Developer/Xcode/DerivedData/iMEGA-bccgbbxukiqsjtfbnctkbkynqylr/Build/Intermediates.noindex/Karere.build/Debug-iphonesimulator/Karere.build/Script-A838B2231E96860900875D96.sh: line 3: cmake: command not found
Command PhaseScriptExecution failed with a nonzero exit code

But I've installed cmake command which can be confirmed by which cmake in iTerm.

$ which cmake
/opt/homebrew/bin/cmake

What did you expect to happen?

Xcode can compile successfully.

0x-matt commented 1 year ago

@jnavarrom can you help me please?

jnavarrom commented 1 year ago

It seems you installed it using brew and the /opt/homebrew/bin/cmake is not in your PATH.

You can manually add the install directory (e.g. /opt/homebrew/bin/cmake) to the PATH

0x-matt commented 1 year ago

Appreciate your reply. I did install cmake using brew. And I manually add the /opt/homebrew/bin/cmake to the PATH, which is like this in my ~/.zshrc file:

PATH="/opt/homebrew/bin/cmake:$PATH"
PATH="/opt/homebrew/bin:$PATH"
PATH="/opt/homebrew/sbin:$PATH"
PATH="$PATH:$HOME/bin"
PATH="$PATH:/usr/local/go/bin"
PATH="~/.cargo/bin:$PATH"

# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
PATH="$PATH:$HOME/.rvm/bin"
export PATH

Unfortunately, the same error still exists. Is that my .zshrc file config isn't correct? Or do I need to do something else, like add the path to .bashrc file?

jnavarrom commented 1 year ago

If you open a terminal and run cmake, is it found?

I didn't install it using brew, I downloaded the precompiled binary from here: https://cmake.org/download/ and then followed install instructions from here: https://cmake.org/install/

which cmake                 
/usr/local/bin/cmake
Screenshot 2022-11-07 at 10 07 59
jnavarrom commented 1 year ago

PATH="/opt/homebrew/bin/cmake:$PATH"

I feel you missed here two double quotes (")

PATH="/opt/homebrew/bin/cmake":"$PATH"

0x-matt commented 1 year ago

Appreciate your patience and reply again! It really helped me a lot. At last, I resolved and compiled it successfully by using the following key way:

$ sudo "/Applications/CMake.app/Contents/bin/cmake-gui" --install

Linked: '/usr/local/bin/cmake' -> '/Applications/CMake.app/Contents/bin/cmake'
Linked: '/usr/local/bin/ctest' -> '/Applications/CMake.app/Contents/bin/ctest'
Linked: '/usr/local/bin/cpack' -> '/Applications/CMake.app/Contents/bin/cpack'
Linked: '/usr/local/bin/cmake-gui' -> '/Applications/CMake.app/Contents/bin/cmake-gui'
Linked: '/usr/local/bin/ccmake' -> '/Applications/CMake.app/Contents/bin/ccmake'

which is inspired by your replied image. It is estimated that Xcode use /usr/local/bin/*** as its command path, so we must link these soft chains to installed third-party tools.

In addition, I guess PATH="/opt/homebrew/bin/cmake:$PATH" vs. PATH="/opt/homebrew/bin/cmake":"$PATH" is the same thing, just written in two different ways.