cmaketerminalclion

Can I use cmake that bundled in CLion in my terminal?


So I have CLion IDE and I wonder if I can use Cmake that my CLion use straightly from terminal. Because the system tells me that cmake isn't installed so there is no cmake in /usr/bin.


Solution

  • Sure, all you need to do is find the absolute path to the CMake binary bundled with your CLion installation.

    # This can help you find the binary if you don't know where it is
    # Substitute <dir> for where you want to search on the system
    $ find <dir> -executable -type f -name cmake
    
    # It will give you can output like this
    /usr/foobar/baz/clion/cmake/3.24.0/bin/cmake
    

    Then you'll just need to add CMake to your path.

    Here is some bash code that does that:

    PATH="/usr/foobar/baz/clion/cmake/3.24.0/bin:$PATH"
    
    export PATH
    

    Place the above code in your .bash_aliases or your .bashrc whichever approach you prefer. So that the PATH is persistently modified in your terminal sessions.

    Then reload .bashrc

    $> source .bashrc
    

    Then you'll know you succeeded when you get a result like this:

    $ cmake --version
    cmake version 3.24.0
    
    CMake suite maintained and supported by Kitware (kitware.com/cmake).