Bash cmake command not found windows

This post helps you to fix the “cmake: command not found” error encountered during the build process of your software. There are two major reasons for getting cmake command errors, either cmake is not installed or Path is not correctly set up. It doesn’t matter, which operating system you have. Following this post step by step will get this issue resolved for sure.

Below mentioned are the types of errors that occur while working with the “cmake” command –

  1. cmake: command not found
  2. cmake command not found macOS
  3. autogen.sh cmake command not found
  4. /bin/sh cmake command not found
  5. ‘cmake’ is not recognized as an internal or external command, operable program or batch file
  6. command ‘cmake’ not found
  7. bash: /snap/bin/cmake: No such file or directory

Why am I getting the “cmake: command not found” error?

Following are the reason for getting the cmake command not found issue –

  • cmake is not installed in your operating system
  • cmake is installed but PATH or environmental variable is not setup correctly

Let’s assume you are trying to build software which is trying to run “build && cmake” commands and you are getting cmake errors. It means you don’t have the CMake package installed in your macOS.

To solve this CMake issue, we will follow 3 steps approach –

  • Check if CMake is installed or not
  • If it’s not installed, install the cmake using the right way.
  • If CMake is installed but not working, then look for the PATH variable.

The above-mentioned approach is applicable to all operating systems whether it’s Windows, Debian, RedHat or macOS.

How to check “CMake” package is installed or not

The best way is to run the CMake command –

  • Open a terminal in macOS
  • Run cmake command see the output
$ cmake

If it shows the cmake help, then cmake is installed in your system and your life is sorted, else you need to install cmake using the following command.

$ brew install cmake
  • Alternatively, you can also go to the cmake download page and download the precompiled binaries as disk image “.dmg” or “.tar.gz” (tarball) binary as per your macOS version.

Download cmake for macOS

  • Copy CMake.app into /Applications (or a custom location) and then double click to run it. Then follow the “How to Install For Command Line Use” menu item

Once you install the cmake it will automatically be available in the PATH. but in case you don’t have that automatically and get the cmake: command not found error, then you need to set up the cmake PATH manually using the following commands –

How to setup PATH for cmake in macOS

  • Open .bash_profile or .bashrc in your home directory using vim or nano editor.
  • Add the following line to the end of the file and save the file.

export PATH=”/Applications/CMake.app/Contents/bin”:”$PATH”

  • If you want to create symlinks to ‘/usr/local/bin’, run the following command from the terminal
$ sudo "/Applications/CMake.app/Contents/bin/cmake-gui" --install

How to fix command ‘cmake’ not found error in Linux

If you use Ubuntu or any other Debian-based Linux and get “cmake: command not found errors“, then follow these series of commands –

Step-1 check for existing cmake installation

cmake: command not found error

As shown in the above image, cmake is not installed in my Linux system.

Step2- Install cmake, if not installed already

How to install cmake in Linux – 4 Methods

There are 4 ways to install cmake in your Debian Linux system like Ubuntu, LinuxMint, Kubuntu, Kali Linux etc.

  • 1. Using the apt command

Run the following commands –

$ sudo apt update
$ sudo apt install cmake

Install cmake in Ubuntu using apt

  • 2. Using the snap command as the apt command is going to obsolete soon
$ sudo snap install cmake --classic

Install cmake in Debian based os using snap

  • By using pre-compiled binaries available on the make download page.

download precompiled binaries for cmake to install in Linux

  • 3. Download the cmake-3.24.2-linux-x86_64.sh file and execute it.
$ bash cmake-3.24.2-linux-x86_64.sh

run cmake.sh file to install it in Linux

  • Accept license by typing “y” and either accept the default location to install or provide your custom directory.

Accept license

** Note – whatever the directory location you will provide in the above step, the same path you need to include in $PATH manually if the cmake command gives you an error.

For example, in my case, I will add the following line to the last of .bashrc or .bash_profile file in the user’s home directory

$ export PATH=$PATH:/home/dev/Downloads/cmake-3.24.2-linux-x86_64/bin
  • Check the command "cmake" is running successfully

$ cmake

cmake: command not found error in linux fixed

How to fix ‘cmake’ is not recognized as an internal or external command, operable program or batch file error in Windows

In the case of the Windows operating system, if you get cmake command errors, then follow the below-mentioned process to fix it.

  • Download cmake binaries from the cmake website

Download cmake command for Windows

  • Double-click on the installer and click “next” on the welcome page
  • Accept the license and hit next in the wizard

Accept EULA

  • Important step – Select the option to add the CMake directory to the system PATH.

You will get 3 options –

  1. Do not add CMake to the system PATH – If you have selected this option, then you need to add the CMake path manually in the system after installation. That is one of the reasons when you have cmake installed and still, you get “‘cmake’ is not recognized as an internal or external command” error. So don’t select this option.
  2. Add CMake to the system PATH for all users – If you log in with different users to your system, then you can select this option. It will set up the cmake PATH variable for all users, who is present on the system.
  3. Add CMake to the system PATH for the current user – If you are the only user, then this is the recommended option.

You can select either option 2 or 3 based on your requirement, both will set up the PATH variable in your environment and will fix the cmake command errors.

Setup PATH variable to fix cmake' is not recognized as an internal or external command error

  • Select custom or leave it to default for the cmake installation directory.

how to install cmake in Windows

  • Then Click Install and accept select “Yes” in case of user control dialogue box permission
  • Click Finish, once the cmake installation is done

finish cmake installation wizard

  • Open the command prompt and run the cmake command to validate.
c:\> cmake

run cmake command

How to install CMake in Docker

Add this line to install CMake in the Docker file –

#!/bin/bash
wget -qO- "https://github.com/Kitware/CMake/releases/download/v3.24.2/cmake-3.24.2-linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C /usr/local

Change the version with your required version, I have shown an example of v3.24.2 latest available while writing this article. If you get the error wget command not found, then add appt update && apt install wget in your file.

End note

The fundamental approach is the same to troubleshoot the CMake command not found error in all operating systems –

  1. Check for cmake installation
  2. Install cmake as shown in this post for your operating systems
  3. setup PATH or Environment variable, if required
  4. Run cmake and build apps

Leave your feedback or comments, if you face any other issues in the cmake command.

Other helpful articles

  • Yarn command not found error
  • Sudo command not found error
  • Fix “mkvirtualenv command not found” error
  • Nodemon command not found
  • Nodemon app crashed – Waiting for file changes before starting
  • Keytool command issues
  • Cmake command errors

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement. We’ll occasionally send you account related emails.

Already on GitHub?
Sign in
to your account

Closed

Sola1991 opened this issue

Jan 2, 2019

· 12 comments

Comments

@Sola1991

This my 1st time trying to compile a project.
I’m following building instructions of MSYS2 Method Building-on-Windows
but I’m facing this error.
Cmake command is not found

$ cmake .. -G 'Unix Makefiles' -DUSE_SDL2_LIBS=1
bash: cmake: command not found

make should have been downloaded & installed as part of:pacman --noconfirm --needed -Sy pkg-config make mingw-w64-i686-toolchain mingw-w64-i686-cmake mingw-w64-i686-zlib mingw-w64-i686-SDL2 mingw-w64-i686-SDL2_image mingw-w64-i686-SDL2_mixer

I’m using Windows 10×64-bit.

@mmatyas

Hm CMake should have been installed by mingw-w64-i686-cmake, did you see any related errors when you run pacman? It’s also possible that it comes from a different package now; try installing mingw-w64-cmake or just cmake to see if it works.

@Sola1991

MSYS2 still report the same error once I run the cmake argument.

This what I get after running thees code

$ pacman -Sy mingw-w64-cmake make
:: Synchronizing package databases...
 mingw32 is up to date
 mingw64 is up to date
 msys is up to date
error: target not found: mingw-w64-cmake
warning: make-4.2.1-1 is up to date -- reinstalling
$ pacman --noconfirm --needed -Sy pkg-config make mingw-w64-i686-toolchain mingw-w64-i686-cmake mingw-w64-i686-zlib mingw-w64-i686-SDL2 mingw-w64-i686-SDL2_image mingw-w64-i686-SDL2_mixer
:: Synchronizing package databases...
 mingw32 is up to date
 mingw64 is up to date
 msys is up to date
warning: pkg-config-0.29.2-1 is up to date -- skipping
warning: make-4.2.1-1 is up to date -- skipping
:: There are 17 members in group mingw-w64-i686-toolchain:
:: Repository mingw32
   1) mingw-w64-i686-binutils  2) mingw-w64-i686-crt-git  3) mingw-w64-i686-gcc  4) mingw-w64-i686-gcc-ada  5) mingw-w64-i686-gcc-fortran  6) mingw-w64-i686-gcc-libgfortran
   7) mingw-w64-i686-gcc-libs  8) mingw-w64-i686-gcc-objc  9) mingw-w64-i686-gdb  10) mingw-w64-i686-headers-git  11) mingw-w64-i686-libmangle-git  12) mingw-w64-i686-libwinpthread-git
   13) mingw-w64-i686-make  14) mingw-w64-i686-pkg-config  15) mingw-w64-i686-tools-git  16) mingw-w64-i686-winpthreads-git  17) mingw-w64-i686-winstorecompat-git

Enter a selection (default=all):
warning: mingw-w64-i686-binutils-2.30-5 is up to date -- skipping
warning: mingw-w64-i686-crt-git-7.0.0.5285.7b2baaf8-1 is up to date -- skipping
warning: mingw-w64-i686-gcc-7.4.0-1 is up to date -- skipping
warning: mingw-w64-i686-gcc-ada-7.4.0-1 is up to date -- skipping
warning: mingw-w64-i686-gcc-fortran-7.4.0-1 is up to date -- skipping
warning: mingw-w64-i686-gcc-libgfortran-7.4.0-1 is up to date -- skipping
warning: mingw-w64-i686-gcc-libs-7.4.0-1 is up to date -- skipping
warning: mingw-w64-i686-gcc-objc-7.4.0-1 is up to date -- skipping
warning: mingw-w64-i686-gdb-8.2.1-1 is up to date -- skipping
warning: mingw-w64-i686-headers-git-7.0.0.5285.7b2baaf8-1 is up to date -- skipping
warning: mingw-w64-i686-libmangle-git-7.0.0.5230.69c8fad6-1 is up to date -- skipping
warning: mingw-w64-i686-libwinpthread-git-7.0.0.5273.3e5acf5d-1 is up to date -- skipping
warning: mingw-w64-i686-make-4.2.1-2 is up to date -- skipping
warning: mingw-w64-i686-pkg-config-0.29.2-1 is up to date -- skipping
warning: mingw-w64-i686-tools-git-7.0.0.5272.d66350ea-1 is up to date -- skipping
warning: mingw-w64-i686-winpthreads-git-7.0.0.5273.3e5acf5d-1 is up to date -- skipping
warning: mingw-w64-i686-winstorecompat-git-7.0.0.5230.69c8fad6-1 is up to date -- skipping
warning: mingw-w64-i686-cmake-3.12.4-1 is up to date -- skipping
warning: mingw-w64-i686-zlib-1.2.11-5 is up to date -- skipping
warning: mingw-w64-i686-SDL2-2.0.9-1 is up to date -- skipping
warning: mingw-w64-i686-SDL2_image-2.0.4-1 is up to date -- skipping
warning: mingw-w64-i686-SDL2_mixer-2.0.4-1 is up to date -- skipping

@mmatyas

Checked the mingw-w64-i686-cmake package, it does provide CMake, but seems it’s not on your PATH for some reason (and probably the other 32-bit binaries aren’t either). Try installing mingw-w64-x86_64-cmake, it should add CMake and then we’ll see if it founds the other parts.

@Sola1991

Same issue; I see the pkg has been installed tough.
here is the log

$ pacman -Sy mingw-w64-x86_64-cmake
:: Synchronizing package databases...
 mingw32 is up to date
 mingw64 is up to date
 msys is up to date
resolving dependencies...
looking for conflicting packages...

Packages (38) mingw-w64-x86_64-brotli-1.0.7-1  mingw-w64-x86_64-bzip2-1.0.6-6  mingw-w64-x86_64-c-ares-1.15.0-1  mingw-w64-x86_64-ca-certificates-20180409-1  mingw-w64-x86_64-curl-7.63.0-1
              mingw-w64-x86_64-expat-2.2.6-1  mingw-w64-x86_64-gcc-libs-8.2.1+20181214-1  mingw-w64-x86_64-gettext-0.19.8.1-7  mingw-w64-x86_64-gmp-6.1.2-1  mingw-w64-x86_64-jansson-2.12-1
              mingw-w64-x86_64-jemalloc-5.1.0-3  mingw-w64-x86_64-jsoncpp-1.8.4-3  mingw-w64-x86_64-libarchive-3.3.3-2  mingw-w64-x86_64-libffi-3.2.1-4  mingw-w64-x86_64-libiconv-1.15-3
              mingw-w64-x86_64-libidn2-2.0.5-1  mingw-w64-x86_64-libmetalink-0.1.3-3  mingw-w64-x86_64-libpsl-0.20.2-1  mingw-w64-x86_64-libssh2-1.8.0-3  mingw-w64-x86_64-libsystre-1.0.1-4
              mingw-w64-x86_64-libtasn1-4.13-1  mingw-w64-x86_64-libtre-git-r128.6fb7206-2  mingw-w64-x86_64-libunistring-0.9.10-1  mingw-w64-x86_64-libuv-1.24.1-1
              mingw-w64-x86_64-libwinpthread-git-7.0.0.5273.3e5acf5d-1  mingw-w64-x86_64-lz4-1.8.3-1  mingw-w64-x86_64-lzo2-2.10-1  mingw-w64-x86_64-mpc-1.1.0-1  mingw-w64-x86_64-mpfr-4.0.1-2
              mingw-w64-x86_64-nettle-3.4.1-1  mingw-w64-x86_64-nghttp2-1.35.1-1  mingw-w64-x86_64-openssl-1.1.1.a-1  mingw-w64-x86_64-p11-kit-0.23.14-1  mingw-w64-x86_64-rhash-1.3.6-2
              mingw-w64-x86_64-xz-5.2.4-1  mingw-w64-x86_64-zlib-1.2.11-5  mingw-w64-x86_64-zstd-1.3.8-1  mingw-w64-x86_64-cmake-3.12.4-1

Total Download Size:    21.79 MiB
Total Installed Size:  156.76 MiB

:: Proceed with installation? [Y/n] y
:: Retrieving packages...
 mingw-w64-x86_64-gmp-6.1.2-1-any                                                           486.0 KiB   266K/s 00:02 [#####################################################################] 100%
 mingw-w64-x86_64-mpfr-4.0.1-2-any                                                          338.3 KiB   512K/s 00:01 [#####################################################################] 100%
 mingw-w64-x86_64-mpc-1.1.0-1-any                                                            78.9 KiB  1924K/s 00:00 [#####################################################################] 100%
 mingw-w64-x86_64-libwinpthread-git-7.0.0.5273.3e5acf5d-1-any                                43.3 KiB  1445K/s 00:00 [#####################################################################] 100%
 mingw-w64-x86_64-gcc-libs-8.2.1+20181214-1-any                                             578.6 KiB   559K/s 00:01 [#####################################################################] 100%
 mingw-w64-x86_64-c-ares-1.15.0-1-any                                                        98.1 KiB  68.0K/s 00:01 [#####################################################################] 100%
 mingw-w64-x86_64-brotli-1.0.7-1-any                                                        329.2 KiB   254K/s 00:01 [#####################################################################] 100%
 mingw-w64-x86_64-expat-2.2.6-1-any                                                         158.7 KiB   630K/s 00:00 [#####################################################################] 100%
 mingw-w64-x86_64-libiconv-1.15-3-any                                                       616.3 KiB   561K/s 00:01 [#####################################################################] 100%
 mingw-w64-x86_64-gettext-0.19.8.1-7-any                                                      3.1 MiB   597K/s 00:05 [#####################################################################] 100%
 mingw-w64-x86_64-libunistring-0.9.10-1-any                                                 625.6 KiB   565K/s 00:01 [#####################################################################] 100%
 mingw-w64-x86_64-libidn2-2.0.5-1-any                                                       114.0 KiB  1932K/s 00:00 [#####################################################################] 100%
 mingw-w64-x86_64-libmetalink-0.1.3-3-any                                                    61.1 KiB  1970K/s 00:00 [#####################################################################] 100%
 mingw-w64-x86_64-libpsl-0.20.2-1-any                                                       101.9 KiB  1756K/s 00:00 [#####################################################################] 100%
 mingw-w64-x86_64-libtasn1-4.13-1-any                                                       186.3 KiB   773K/s 00:00 [#####################################################################] 100%
 mingw-w64-x86_64-libffi-3.2.1-4-any                                                         44.9 KiB  1953K/s 00:00 [#####################################################################] 100%
 mingw-w64-x86_64-p11-kit-0.23.14-1-any                                                     296.0 KiB   664K/s 00:00 [#####################################################################] 100%
 mingw-w64-x86_64-ca-certificates-20180409-1-any                                            356.3 KiB   769K/s 00:00 [#####################################################################] 100%
 mingw-w64-x86_64-bzip2-1.0.6-6-any                                                          81.3 KiB  1891K/s 00:00 [#####################################################################] 100%
 mingw-w64-x86_64-zlib-1.2.11-5-any                                                         177.8 KiB   330K/s 00:01 [#####################################################################] 100%
 mingw-w64-x86_64-openssl-1.1.1.a-1-any                                                       4.7 MiB   598K/s 00:08 [#####################################################################] 100%
 mingw-w64-x86_64-libssh2-1.8.0-3-any                                                       232.3 KiB   526K/s 00:00 [#####################################################################] 100%
 mingw-w64-x86_64-jansson-2.12-1-any                                                         65.8 KiB  1530K/s 00:00 [#####################################################################] 100%
 mingw-w64-x86_64-jemalloc-5.1.0-3-any                                                      306.3 KiB   633K/s 00:00 [#####################################################################] 100%
 mingw-w64-x86_64-nghttp2-1.35.1-1-any                                                      201.0 KiB   280K/s 00:01 [#####################################################################] 100%
 mingw-w64-x86_64-curl-7.63.0-1-any                                                        1144.9 KiB   486K/s 00:02 [#####################################################################] 100%
 mingw-w64-x86_64-jsoncpp-1.8.4-3-any                                                       284.3 KiB   618K/s 00:00 [#####################################################################] 100%
 mingw-w64-x86_64-lz4-1.8.3-1-any                                                           133.7 KiB   541K/s 00:00 [#####################################################################] 100%
 mingw-w64-x86_64-lzo2-2.10-1-any                                                           101.1 KiB  3.40M/s 00:00 [#####################################################################] 100%
 mingw-w64-x86_64-libtre-git-r128.6fb7206-2-any                                              84.2 KiB  75.4K/s 00:01 [#####################################################################] 100%
 mingw-w64-x86_64-libsystre-1.0.1-4-any                                                      24.0 KiB  0.00B/s 00:00 [#####################################################################] 100%
 mingw-w64-x86_64-nettle-3.4.1-1-any                                                        419.4 KiB   466K/s 00:01 [#####################################################################] 100%
 mingw-w64-x86_64-xz-5.2.4-1-any                                                            297.7 KiB   595K/s 00:01 [#####################################################################] 100%
 mingw-w64-x86_64-zstd-1.3.8-1-any                                                          369.4 KiB   557K/s 00:01 [#####################################################################] 100%
 mingw-w64-x86_64-libarchive-3.3.3-2-any                                                    647.4 KiB   492K/s 00:01 [#####################################################################] 100%
 mingw-w64-x86_64-libuv-1.24.1-1-any                                                        187.6 KiB   439K/s 00:00 [#####################################################################] 100%
 mingw-w64-x86_64-rhash-1.3.6-2-any                                                         163.9 KiB   656K/s 00:00 [#####################################################################] 100%
 mingw-w64-x86_64-cmake-3.12.4-1-any                                                          4.7 MiB   439K/s 00:11 [#####################################################################] 100%
(38/38) checking keys in keyring                                                                                     [#####################################################################] 100%
(38/38) checking package integrity                                                                                   [#####################################################################] 100%
(38/38) loading package files                                                                                        [#####################################################################] 100%
(38/38) checking for file conflicts                                                                                  [#####################################################################] 100%
(38/38) checking available disk space                                                                                [#####################################################################] 100%
:: Processing package changes...
( 1/38) installing mingw-w64-x86_64-gmp                                                                              [#####################################################################] 100%
( 2/38) installing mingw-w64-x86_64-mpfr                                                                             [#####################################################################] 100%
( 3/38) installing mingw-w64-x86_64-mpc                                                                              [#####################################################################] 100%
( 4/38) installing mingw-w64-x86_64-libwinpthread-git                                                                [#####################################################################] 100%
( 5/38) installing mingw-w64-x86_64-gcc-libs                                                                         [#####################################################################] 100%
( 6/38) installing mingw-w64-x86_64-c-ares                                                                           [#####################################################################] 100%
( 7/38) installing mingw-w64-x86_64-brotli                                                                           [#####################################################################] 100%
( 8/38) installing mingw-w64-x86_64-expat                                                                            [#####################################################################] 100%
( 9/38) installing mingw-w64-x86_64-libiconv                                                                         [#####################################################################] 100%
(10/38) installing mingw-w64-x86_64-gettext                                                                          [#####################################################################] 100%
(11/38) installing mingw-w64-x86_64-libunistring                                                                     [#####################################################################] 100%
(12/38) installing mingw-w64-x86_64-libidn2                                                                          [#####################################################################] 100%
(13/38) installing mingw-w64-x86_64-libmetalink                                                                      [#####################################################################] 100%
(14/38) installing mingw-w64-x86_64-libpsl                                                                           [#####################################################################] 100%
(15/38) installing mingw-w64-x86_64-libtasn1                                                                         [#####################################################################] 100%
(16/38) installing mingw-w64-x86_64-libffi                                                                           [#####################################################################] 100%
(17/38) installing mingw-w64-x86_64-p11-kit                                                                          [#####################################################################] 100%
(18/38) installing mingw-w64-x86_64-ca-certificates                                                                  [#####################################################################] 100%
(19/38) installing mingw-w64-x86_64-bzip2                                                                            [#####################################################################] 100%
(20/38) installing mingw-w64-x86_64-zlib                                                                             [#####################################################################] 100%
(21/38) installing mingw-w64-x86_64-openssl                                                                          [#####################################################################] 100%
(22/38) installing mingw-w64-x86_64-libssh2                                                                          [#####################################################################] 100%
(23/38) installing mingw-w64-x86_64-jansson                                                                          [#####################################################################] 100%
(24/38) installing mingw-w64-x86_64-jemalloc                                                                         [#####################################################################] 100%
(25/38) installing mingw-w64-x86_64-nghttp2                                                                          [#####################################################################] 100%
(26/38) installing mingw-w64-x86_64-curl                                                                             [#####################################################################] 100%
(27/38) installing mingw-w64-x86_64-jsoncpp                                                                          [#####################################################################] 100%
(28/38) installing mingw-w64-x86_64-lz4                                                                              [#####################################################################] 100%
(29/38) installing mingw-w64-x86_64-lzo2                                                                             [#####################################################################] 100%
(30/38) installing mingw-w64-x86_64-libtre-git                                                                       [#####################################################################] 100%
(31/38) installing mingw-w64-x86_64-libsystre                                                                        [#####################################################################] 100%
(32/38) installing mingw-w64-x86_64-nettle                                                                           [#####################################################################] 100%
(33/38) installing mingw-w64-x86_64-xz                                                                               [#####################################################################] 100%
(34/38) installing mingw-w64-x86_64-zstd                                                                             [#####################################################################] 100%
(35/38) installing mingw-w64-x86_64-libarchive                                                                       [#####################################################################] 100%
(36/38) installing mingw-w64-x86_64-libuv                                                                            [#####################################################################] 100%
(37/38) installing mingw-w64-x86_64-rhash                                                                            [#####################################################################] 100%
(38/38) installing mingw-w64-x86_64-cmake                                                                            [#####################################################################] 100%
Optional dependencies for mingw-w64-x86_64-cmake
    mingw-w64-x86_64-qt5: CMake Qt GUI
Sola@Sola MSYS /c/supermariowar/build
$ cmake .. -G 'Unix Makefiles' -DUSE_SDL2_LIBS=1
bash: cmake: command not found

@mmatyas

Ah there’s the issue:

Sola@Sola MSYS /c/supermariowar/build

You should launch the «MSYS2 MinGW 32-bit» command prompt, which adds /mingw32/bin to your PATH.

@Sola1991

Thanks @mmatyas,
You are totally correct. Now I’m able to run cmake & make arguments.

@Je55ie

Hi. My situation is similar with Sola1991, but after I finish the steps above I had another error.
je55i@LAPTOP-JFI2G606 MINGW32 /d/Master/zacros/zacros_2.0/build
$ cmake .. -G»MSYS Makefiles»
CMake Error: CMake was unable to find a build program corresponding to «MSYS Makefiles». CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
CMake Error: CMake was unable to find a build program corresponding to «MSYS Makefiles». CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
CMake Error: CMAKE_Fortran_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_AR was not found, please set to archive program.
— Configuring incomplete, errors occurred!

@mmatyas

Hi, have you tried running CMake with -G 'Unix Makefiles'? I’m not sure «MSYS Makefiles» works.

@Xagarsan

Hi! Im new at this also and when I put what you said (MSYS2 MinGW 32-bit), it says this

$ MSYS2 MinGW 32-bit
-bash: MSYS2: command not found

@mmatyas

Hi! MSYS2 MinGW 32-bit is a program installed by the MSYS installer (or, at least it did 3 years ago). You can access it from the Start menu, and you should see a slightly different command prompt when you launch it.

@mmatyas

Just checked, it’s called MSYS2 MINGW32 now. You should see MINGW32 in the prompt.

@LuisEvaristo

Just an update, I try to run cmake on MSYS2 MINGW32 and it doesn´t work, So I try with MSYS2 MINGW64 and is working

If you are a developer or someone who frequently works with code, you may have come across the frustrating ‘cmake command not found’ error. CMake is a popular cross-platform tool used for building, testing, and packaging software projects. This error can occur for various reasons and can halt your development process. But fret not, in this article, we will delve into the common causes of this error and provide you with quick and efficient fixes to get you back on track with your project.

CMake is a powerful tool widely used in the software development community due to its ability to simplify the build process and ensure cross-platform compatibility. However, encountering the ‘cmake command not found’ error can hinder productivity and lead to confusion. In this article, we will explore the possible reasons for this error and present effective solutions to resolve it.

CMake is an open-source build system generator that facilitates the build process of software projects across different platforms and compilers. It generates platform-specific build files, such as Makefiles or project files for IDEs, based on a single, unified CMake configuration. This approach allows developers to write platform-independent build scripts and ensures consistency across various environments.

Understanding the ‘cmake command not found’ Error

The ‘cmake command not found’ error typically occurs when the system cannot locate the CMake executable, leading to the inability to run CMake commands in the terminal or command prompt

Potential Causes of the Error:

  • Incomplete or Incorrect Installation: If CMake is not installed correctly, or the installation process encountered issues, the ‘cmake command not found’ error may arise.
  • System Path Configuration: If the CMake executable’s path is not included in the system’s PATH environment variable, the system will be unable to locate it.
  • Environment Variables: Specific environment variables required by CMake might be misconfigured or missing, causing the error.
  • Outdated CMake Version: Using an outdated version of CMake may result in compatibility issues, leading to the error.
  • Corrupted Installation: If the CMake installation is corrupted or damaged, the command may not function as expected.

Now, let’s dive into the solutions to resolve the ‘cmake command not found’ error:

Fix 1: Verify CMake Installation

The first step is to ensure that CMake is installed on your system. To verify the installation, open your terminal or command prompt and run the following command:

If CMake is installed correctly, this command will display the installed version of CMake. If not, proceed to install CMake following the official CMake installation instructions for your operating system.

Fix 2: Add CMake to System Path

To execute CMake commands from any directory, you need to add the CMake executable’s path to the system’s PATH environment variable. This enables the system to find and execute CMake from any location.

On Windows:

  1. Find the directory path where CMake is installed (e.g., C:\Program Files\CMake\bin).
  2. Go to “Control Panel” > “System” > “Advanced system settings” > “Environment Variables.”
  3. Under “System variables,” find the “Path” variable and click “Edit.”
  4. Click “New” and add the path to the CMake executable directory.
  5. Click “OK” to save the changes.

On macOS and Linux:

  1. Open a terminal window.
  2. Locate the CMake executable directory (e.g., /usr/local/bin).
  3. Edit the shell configuration file (e.g., ~/.bashrc, ~/.bash_profile, ~/.zshrc) using a text editor.
  4. Add the following line to the file:
export PATH="/path/to/cmake/bin:$PATH"
  1. Save the file and execute the command:
source /path/to/modified/file

Fix 3: Check Environment Variables

Ensure that any environment variables required by CMake are correctly set. These variables may include CC for the C compiler, CXX for the C++ compiler, and CMAKE_PREFIX_PATH for custom library paths. Check your system’s environment variables and make necessary adjustments if needed.

Fix 4: Update CMake Version

Outdated CMake versions might lack critical features or have compatibility issues with your system. Visit the CMake website to download the latest stable version and install it.

Fix 5: Reinstall CMak

If none of the above fixes work, consider reinstalling CMake to resolve potential corruption or installation issues. Uninstall CMake completely and then reinstall it following the official instructions for your platform.

To make the most of CMake, consider implementing the following best practices:

  • Organize Your Project Structure: Arrange your project files and directories logically to ensure a clean and maintainable CMake configuration.
  • Use External Projects Sparingly: Rely on external projects and libraries when necessary, but try to avoid excessive dependencies to keep your project lightweight.
  • Maintain CMakeLists.txt Regularly: Keep your CMakeLists.txt file up-to-date and refactor it when significant changes occur in your project.

Troubleshooting Other Common CMake Issues

While the ‘cmake command not found’ error is one of the more common CMake-related issues, other problems may also arise during development. Here are some additional CMake issues and their potential solutions:

Issue 1: ‘CMakeLists.txt’ File Errors

Frequent errors in the CMakeLists.txt file can lead to build failures. Regularly check for syntax errors, missing dependencies, and target configurations.

Issue 2: Compiler Compatibility

Ensure that CMake is compatible with your chosen compiler, and set the appropriate compiler flags in your CMake configuration.

Issue 3: Conflicts with Other Tools

Sometimes, conflicts between CMake and other build tools may occur. Be mindful of any potential conflicts and address them accordingly

In conclusion, the ‘cmake command not found’ error can be a roadblock during software development. By following the quick fixes and best practices outlined in this article, you can resolve the issue and effectively utilize CMake to build and manage your projects seamlessly.

  1. Q: Can I use CMake on Windows, macOS, and Linux simultaneously?
    • A: Yes, CMake is designed to work on multiple platforms, including Windows, macOS, and Linux. It allows you to maintain a single CMake configuration that generates platform-specific build files.
  2. Q: How often should I update CMake to avoid compatibility issues?
    • A: It is advisable to update CMake regularly to ensure compatibility with the latest software and libraries. Check the CMake website for new stable releases and update accordingly.
  3. Q: Is CMake suitable for small projects as well?
    • A: Absolutely! CMake is flexible and can be used for projects of all sizes. It helps simplify the build process, whether your project is small or large.

Ahmad Raza

Greetings! I am Ahmad Raza, and I bring over 10 years of experience in the fascinating realm of operating systems. As an expert in this field, I am passionate about unraveling the complexities of Windows and Linux systems. Through WindowsCage.com, I aim to share my knowledge and practical solutions to various operating system issues. From essential command-line commands to advanced server management, my goal is to empower readers to navigate the digital landscape with confidence.

Join me on this exciting journey of exploration and learning at WindowsCage.com. Together, let’s conquer the challenges of operating systems and unlock their true potential.

CMake command not found error points towards an incomplete CMake installation or a missing CMake tool on your PC. So, it’s all about CMake not being found, resulting in its command not being found.CMake Command Not Found

Although the problem is quite simple and the solutions are easy, too, this post goes into the details of the error and highlights a lot of things that are worth noticing. So, start reading to see how this article can guide you in sorting out the error instantly with the help of categorized solutions.

Contents

  • What Are the Causes of the Cmake Command Not Found Error?
    • – You Forgot To Install CMAKE
    • – You Haven’t Set the PATH Environment Variable To the CMAKE Path
  • What Are the Best Solutions to Cmake Command Not Found Error?
    • – Install CMAKE on Windows
    • – CMAKE Installation on Linux or Unix
    • – Say Yes To CMAKE on macOS
    • – Let the build-essential or Homebrew Package Do the Work
  • FAQs
    • 1. How To Confirm If CMake Is Installed Successfully on Your PC?
    • 2. What Is the Purpose of the cmake install Command?
    • 3. What Are Some Great Alternatives to CMake?
  • Conclusion

What Are the Causes of the Cmake Command Not Found Error?

The CMake command not found Debian error is caused by including the missing CMake tool on your machine. Another problem can be the CMake directory path not assigned to the PATH environment variable. So, in case of any of the given situations, you’ll receive the stated error.

– You Forgot To Install CMAKE

Installing CMAKE is essential for running the CMAKE commands efficiently. Thus, it might be possible that you have forgotten to install CMAKE, giving a chance to the same error to pop up on your screen. This cause is valid for a variety of operating systems available. So, whichever operating system you are using currently, the absence of CMAKE will give you the same error irrespective of your OS.CMake Command Not Found Causes

– You Haven’t Set the PATH Environment Variable To the CMAKE Path

Not setting the PATH environment variable to your CMAKE directory can result in the given error. Although initializing the given variable with the CMAKE path is usually included in the CMAKE installation steps, it is possible that you have missed it, making the said error appear on your system.

Note that this problem relates to the above error when it occurs on Windows or macOS operating systems. Thus, if you are a Windows or mac user, you might find it relevant.

What Are the Best Solutions to Cmake Command Not Found Error?

The best solutions for the CMake: command not found CentOS error include installing CMake on your PC and ensuring that the path of the CMake directory is assigned to the PATH environment variable in Windows and mac.



Remember that the way to install CMake may vary among different systems.

– Install CMAKE on Windows

You should install CMAKE on Windows to get rid of the CMAKE command not found Windows error. You’ll need to begin by visiting the download page of the CMAKE official website, downloading the precompiled binary or the source code distribution for Windows, and installing the same.

If you choose to download the binary distribution, you’ll see that it’s available as an MSI package and a ZIP file. Opting for the MSI package will give you the option to update the PATH variable with the CMAKE directory path. However, if you don’t use that option, you’ll need to execute the set command to manually set the given variable to the directory path that might look like C:\ProgramFiles\CMake\bin.

Remember that if you would like to go with building CMAKE from the source distribution, then downloading the source release won’t be enough. You’ll need to install the latest binary version of CMAKE to proceed with the building process. After installing the binary version, you’ll have to select CMAKE as the source directory before choosing a binary directory for the resulting executables to make things work.

– CMAKE Installation on Linux or Unix

As the missing CMAKE is the cause, it would be best to install CMAKE on your Linux or Unix system to remove the error permanently. Similar to the Windows case, you can download the precompiled binary ZIP file/MSI package or a source release from the CMAKE official website.CMake Command Not Found Fixes

Next, you’ll only need to install the downloaded ZIP file/MSI package on your computer to have CMAKE and kick away the error.

However, for the source release criterion, you’ll need to run the following commands paired with a bootstrap script to complete the installation.

./bootstrap

make

make install

Furthermore, if you are using a compiler other than the GNU C++ compiler, you’ll have to inform it to the bootstrap script by setting the CC and CXX environment variables before running it. Preceding the bootstrap script execution with env CC=cc CXX=CC will tell which compiler you want to use. In such a situation, the script execution will look like env CC=cc CXX=CC ./bootstrap. Here are a few more points that you should always keep in mind:

  • Running the make install command is optional.
  • CMake will execute from the build directory.
  • Boostrap will build CMake without any optimization or debug flags by default.
  • You can enable the optimizations by tweaking the ./bootstrap script like ./bootstrap — -DCMAKE_BUILD_TYPE:STRING=Release.

Besides this, you can run sudo apt-get update && sudo apt-get upgrade, and sudo apt-get install cmake to fix the CMake command not found CentOS 7 and CMake command not found Raspberry Pi errors instantly.

– Say Yes To CMAKE on macOS

To resolve the CMake command not found mac error, you’ll have to welcome CMake on your macOS system. The CMake official website’s download page offers precompiled binaries and source distributions for the mac platform as well. So, you can download the file and install it to get things working.

Know that the binary files for macOS are available as tarballs and disk images. You can freely choose your preferred format. Moreover, after downloading and installing the precompiled binary, you’ll need to copy the CMake.app to your desired location, such as /Applications, and execute it. Next, if you talk about setting the PATH environment variable, you’ll either need to follow the instructions provided in the How to Install For Command Line Use menu item or go for manual variable setting process.

Please note that downloading and building CMake from the source release will require you to follow the same steps specified in the CMake installation on the Linux section.

– Let the build-essential or Homebrew Package Do the Work

The build-essential is commonly known as a meta-package, and Homebrew is a popular package manager. Thus, you can use any one of them to install CMake and, eventually, make the CMake command not found Ubuntu error go away without taking much of your time.

The command using the build-essential package has been attached here: sudo apt-get install build-essential cmake. However, to take help from the Homebrew package, you’ll need to run the brew install cmake command. Once you execute any one of the given commands, you won’t face the same error again while running the CMake commands.

FAQs

1. How To Confirm If CMake Is Installed Successfully on Your PC?

You can confirm if CMake is installed successfully on your PC by running the cmake command followed by the –version or -version option like cmake –version. If CMake is installed, you’ll get its version number in the output. If it’s not, you’ll see the above error again.

2. What Is the Purpose of the cmake install Command?

The purpose of the CMake install command is to specify the way a project should be installed. A project executes the said command in the CMakeLists file to inform CMake about the way the installation scripts can be generated. Next, the same scripts will be executed at the installation time.

3. What Are Some Great Alternatives to CMake?

Some great alternatives to CMake are GNU Make, GNU Automake, Leiningen, SCons, FinalBuilder, A-A-P, Apache Buildr, and Distcc. Furthermore, you can check out the features and functionalities offered by each software to see which one among these fits the best to your requirements.

Conclusion

After reading this post, it’s clear that the CMake command not found Linux error is nothing but a signal that will light up when you execute the CMake commands without ensuring that your machine has the CMake tool and the PATH is set to the CMake directory path. So, having the tool is the key and the one and only fixing technique for the same error. Here you go with some noteworthy points for a quick recap of the above guide.

  • You can download the CMake precompiled binary based on your operating system from the CMake official website.
  • You can download and build CMake from the source releases available on the CMake official website.
  • It would be safe to use a package manager, such as Homebrew or build-essential, to install CMake.
  • The advanced package tool (APT) can make it easier for you to install CMake on Linux systems.

It won’t be wrong to say that there are a bunch of ways to let CMake enter your PC and make it possible for the CMake commands to run flawlessly.

  • Author
  • Recent Posts

Position is Everything

Your Go-To Resource for Learn & Build: CSS,JavaScript,HTML,PHP,C++ and MYSQL. Meet The Team

Position is Everything

This post helps you to fix the «cmake: command not found» error encountered during the build process of your software. There are two major reasons for getting cmake command errors, either cmake is not installed or Path is not correctly set up. It doesn’t matter, which operating system you have. Following this post step by step will get this issue resolved for sure.

Below mentioned are the types of errors that occur while working with the «cmake» command —

  1. cmake: command not found
  2. cmake command not found macOS
  3. autogen.sh cmake command not found
  4. /bin/sh cmake command not found
  5. ‘cmake’ is not recognized as an internal or external command, operable program or batch file
  6. command ‘cmake’ not found
  7. bash: /snap/bin/cmake: No such file or directory

Table of Contents

  • 1 Why am I getting the «cmake: command not found» error?
  • 2 How to fix CMake: command not found error in macOS
  • 3 How to check «CMake» package is installed or not
  • 4 How to fix command ‘cmake’ not found error in Linux
  • 5 How to fix ‘cmake’ is not recognized as an internal or external command, operable program or batch file error in Windows
  • 6 How to install CMake in Docker
  • 7 End note
  • 8 Other helpful articles

Why am I getting the «cmake: command not found» error?

Following are the reason for getting the cmake command not found issue —

  • cmake is not installed in your operating system
  • cmake is installed but PATH or environmental variable is not setup correctly

Let’s assume you are trying to build software which is trying to run «build && cmake» commands and you are getting cmake errors. It means you don’t have the CMake package installed in your macOS.

To solve this CMake issue, we will follow 3 steps approach —

  • Check if CMake is installed or not
  • If it’s not installed, install the cmake using the right way.
  • If CMake is installed but not working, then look for the PATH variable.

The above-mentioned approach is applicable to all operating systems whether it’s Windows, Debian, RedHat or macOS.

How to check «CMake» package is installed or not

The best way is to run the CMake command —

  • Open a terminal in macOS
  • Run cmake command see the output
$ cmake

If it shows the cmake help, then cmake is installed in your system and your life is sorted, else you need to install cmake using the following command.

$ brew install cmake
  • Alternatively, you can also go to the cmake download page and download the precompiled binaries as disk image «.dmg» or «.tar.gz» (tarball) binary as per your macOS version.

Download cmake for macOS

  • Copy CMake.app into /Applications (or a custom location) and then double click to run it. Then follow the “How to Install For Command Line Use” menu item

Once you install the cmake it will automatically be available in the PATH. but in case you don’t have that automatically and get the cmake: command not found error, then you need to set up the cmake PATH manually using the following commands —

How to setup PATH for cmake in macOS

  • Open .bash_profile or .bashrc in your home directory using vim or nano editor.
  • Add the following line to the end of the file and save the file.

export PATH=»/Applications/CMake.app/Contents/bin»:»$PATH»

  • If you want to create symlinks to ‘/usr/local/bin’, run the following command from the terminal
$ sudo "/Applications/CMake.app/Contents/bin/cmake-gui" --install

How to fix command ‘cmake’ not found error in Linux

If you use Ubuntu or any other Debian-based Linux and get «cmake: command not found errors«, then follow these series of commands —

Step-1 check for existing cmake installation

cmake: command not found error

As shown in the above image, cmake is not installed in my Linux system.

Step2- Install cmake, if not installed already

How to install cmake in Linux — 4 Methods

There are 4 ways to install cmake in your Debian Linux system like Ubuntu, LinuxMint, Kubuntu, Kali Linux etc.

  • 1. Using the apt command

Run the following commands —

$ sudo apt update
$ sudo apt install cmake

Install cmake in Ubuntu using apt

  • 2. Using the snap command as the apt command is going to obsolete soon
$ sudo snap install cmake --classic

Install cmake in Debian based os using snap

  • By using pre-compiled binaries available on the make download page.

download precompiled binaries for cmake to install in Linux

  • 3. Download the cmake-3.24.2-linux-x86_64.sh file and execute it.
$ bash cmake-3.24.2-linux-x86_64.sh

run cmake.sh file to install it in Linux

  • Accept license by typing «y» and either accept the default location to install or provide your custom directory.

Accept license

** Note — whatever the directory location you will provide in the above step, the same path you need to include in $PATH manually if the cmake command gives you an error.

For example, in my case, I will add the following line to the last of .bashrc or .bash_profile file in the user’s home directory

$ export PATH=$PATH:/home/dev/Downloads/cmake-3.24.2-linux-x86_64/bin
  • Check the command "cmake" is running successfully

$ cmake

cmake: command not found error in linux fixed

How to fix ‘cmake’ is not recognized as an internal or external command, operable program or batch file error in Windows

In the case of the Windows operating system, if you get cmake command errors, then follow the below-mentioned process to fix it.

  • Download cmake binaries from the cmake website

Download cmake command for Windows

  • Double-click on the installer and click «next» on the welcome page
  • Accept the license and hit next in the wizard

Accept EULA

  • Important step — Select the option to add the CMake directory to the system PATH.

You will get 3 options —

  1. Do not add CMake to the system PATH — If you have selected this option, then you need to add the CMake path manually in the system after installation. That is one of the reasons when you have cmake installed and still, you get «‘cmake’ is not recognized as an internal or external command» error. So don’t select this option.
  2. Add CMake to the system PATH for all users — If you log in with different users to your system, then you can select this option. It will set up the cmake PATH variable for all users, who is present on the system.
  3. Add CMake to the system PATH for the current user — If you are the only user, then this is the recommended option.

You can select either option 2 or 3 based on your requirement, both will set up the PATH variable in your environment and will fix the cmake command errors.

Setup PATH variable to fix cmake' is not recognized as an internal or external command error

  • Select custom or leave it to default for the cmake installation directory.

how to install cmake in Windows

  • Then Click Install and accept select «Yes» in case of user control dialogue box permission
  • Click Finish, once the cmake installation is done

finish cmake installation wizard

  • Open the command prompt and run the cmake command to validate.
c:> cmake

run cmake command

How to install CMake in Docker

Add this line to install CMake in the Docker file —

#!/bin/bash
wget -qO- "https://github.com/Kitware/CMake/releases/download/v3.24.2/cmake-3.24.2-linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C /usr/local

Change the version with your required version, I have shown an example of v3.24.2 latest available while writing this article. If you get the error wget command not found, then add appt update && apt install wget in your file.

End note

The fundamental approach is the same to troubleshoot the CMake command not found error in all operating systems —

  1. Check for cmake installation
  2. Install cmake as shown in this post for your operating systems
  3. setup PATH or Environment variable, if required
  4. Run cmake and build apps

Leave your feedback or comments, if you face any other issues in the cmake command.

Other helpful articles

  • Yarn command not found error
  • Sudo command not found error
  • Fix «mkvirtualenv command not found» error
  • Nodemon command not found
  • Nodemon app crashed — Waiting for file changes before starting
  • Keytool command issues
  • Cmake command errors

I have installed CMake and cmake.exe is in C:Program Files (x86)CMakebin
But when I run call cmake %CMAKE_BUILD_OPTIONS% through a bat file I am getting an error message

‘cmake’ is not recognized as an internal or external command, operable program or batch file.

Should I set this path in environment variable?

usr1234567's user avatar

usr1234567

20.8k16 gold badges110 silver badges127 bronze badges

asked Jul 28, 2015 at 11:35

Nic's user avatar

3

It resolved after adding C:Program Files (x86)CMakebin to environment variable PATH.

usr1234567's user avatar

usr1234567

20.8k16 gold badges110 silver badges127 bronze badges

answered Jul 28, 2015 at 11:47

Nic's user avatar

NicNic

3872 gold badges5 silver badges16 bronze badges

1

Was able to resolve the issue by installing Chocolatey (on Windows 10) and running choco install cmake

answered Apr 2, 2020 at 3:27

monkrus's user avatar

monkrusmonkrus

1,36524 silver badges23 bronze badges

1

CMake command not found error points towards an incomplete CMake installation or a missing CMake tool on your PC. So, it’s all about CMake not being found, resulting in its command not being found.CMake Command Not Found

Although the problem is quite simple and the solutions are easy, too, this post goes into the details of the error and highlights a lot of things that are worth noticing. So, start reading to see how this article can guide you in sorting out the error instantly with the help of categorized solutions.

Contents

  • What Are the Causes of the Cmake Command Not Found Error?
    • – You Forgot To Install CMAKE
    • – You Haven’t Set the PATH Environment Variable To the CMAKE Path
  • What Are the Best Solutions to Cmake Command Not Found Error?
    • – Install CMAKE on Windows
    • – CMAKE Installation on Linux or Unix
    • – Say Yes To CMAKE on macOS
    • – Let the build-essential or Homebrew Package Do the Work
  • FAQs
    • 1. How To Confirm If CMake Is Installed Successfully on Your PC?
    • 2. What Is the Purpose of the cmake install Command?
    • 3. What Are Some Great Alternatives to CMake?
  • Conclusion

What Are the Causes of the Cmake Command Not Found Error?

The CMake command not found Debian error is caused by including the missing CMake tool on your machine. Another problem can be the CMake directory path not assigned to the PATH environment variable. So, in case of any of the given situations, you’ll receive the stated error.

– You Forgot To Install CMAKE

Installing CMAKE is essential for running the CMAKE commands efficiently. Thus, it might be possible that you have forgotten to install CMAKE, giving a chance to the same error to pop up on your screen. This cause is valid for a variety of operating systems available. So, whichever operating system you are using currently, the absence of CMAKE will give you the same error irrespective of your OS.CMake Command Not Found Causes

– You Haven’t Set the PATH Environment Variable To the CMAKE Path

Not setting the PATH environment variable to your CMAKE directory can result in the given error. Although initializing the given variable with the CMAKE path is usually included in the CMAKE installation steps, it is possible that you have missed it, making the said error appear on your system.

Note that this problem relates to the above error when it occurs on Windows or macOS operating systems. Thus, if you are a Windows or mac user, you might find it relevant.

What Are the Best Solutions to Cmake Command Not Found Error?

The best solutions for the CMake: command not found CentOS error include installing CMake on your PC and ensuring that the path of the CMake directory is assigned to the PATH environment variable in Windows and mac.

Remember that the way to install CMake may vary among different systems.

– Install CMAKE on Windows

You should install CMAKE on Windows to get rid of the CMAKE command not found Windows error. You’ll need to begin by visiting the download page of the CMAKE official website, downloading the precompiled binary or the source code distribution for Windows, and installing the same.

If you choose to download the binary distribution, you’ll see that it’s available as an MSI package and a ZIP file. Opting for the MSI package will give you the option to update the PATH variable with the CMAKE directory path. However, if you don’t use that option, you’ll need to execute the set command to manually set the given variable to the directory path that might look like C:ProgramFilesCMakebin.

Remember that if you would like to go with building CMAKE from the source distribution, then downloading the source release won’t be enough. You’ll need to install the latest binary version of CMAKE to proceed with the building process. After installing the binary version, you’ll have to select CMAKE as the source directory before choosing a binary directory for the resulting executables to make things work.

– CMAKE Installation on Linux or Unix

As the missing CMAKE is the cause, it would be best to install CMAKE on your Linux or Unix system to remove the error permanently. Similar to the Windows case, you can download the precompiled binary ZIP file/MSI package or a source release from the CMAKE official website.CMake Command Not Found Fixes

Next, you’ll only need to install the downloaded ZIP file/MSI package on your computer to have CMAKE and kick away the error.

However, for the source release criterion, you’ll need to run the following commands paired with a bootstrap script to complete the installation.

./bootstrap

make

make install

Furthermore, if you are using a compiler other than the GNU C++ compiler, you’ll have to inform it to the bootstrap script by setting the CC and CXX environment variables before running it. Preceding the bootstrap script execution with env CC=cc CXX=CC will tell which compiler you want to use. In such a situation, the script execution will look like env CC=cc CXX=CC ./bootstrap. Here are a few more points that you should always keep in mind:

  • Running the make install command is optional.
  • CMake will execute from the build directory.
  • Boostrap will build CMake without any optimization or debug flags by default.
  • You can enable the optimizations by tweaking the ./bootstrap script like ./bootstrap — -DCMAKE_BUILD_TYPE:STRING=Release.

Besides this, you can run sudo apt-get update && sudo apt-get upgrade, and sudo apt-get install cmake to fix the CMake command not found CentOS 7 and CMake command not found Raspberry Pi errors instantly.

– Say Yes To CMAKE on macOS

To resolve the CMake command not found mac error, you’ll have to welcome CMake on your macOS system. The CMake official website’s download page offers precompiled binaries and source distributions for the mac platform as well. So, you can download the file and install it to get things working.

Know that the binary files for macOS are available as tarballs and disk images. You can freely choose your preferred format. Moreover, after downloading and installing the precompiled binary, you’ll need to copy the CMake.app to your desired location, such as /Applications, and execute it. Next, if you talk about setting the PATH environment variable, you’ll either need to follow the instructions provided in the How to Install For Command Line Use menu item or go for manual variable setting process.

Please note that downloading and building CMake from the source release will require you to follow the same steps specified in the CMake installation on the Linux section.

– Let the build-essential or Homebrew Package Do the Work

The build-essential is commonly known as a meta-package, and Homebrew is a popular package manager. Thus, you can use any one of them to install CMake and, eventually, make the CMake command not found Ubuntu error go away without taking much of your time.

The command using the build-essential package has been attached here: sudo apt-get install build-essential cmake. However, to take help from the Homebrew package, you’ll need to run the brew install cmake command. Once you execute any one of the given commands, you won’t face the same error again while running the CMake commands.

FAQs

1. How To Confirm If CMake Is Installed Successfully on Your PC?

You can confirm if CMake is installed successfully on your PC by running the cmake command followed by the –version or -version option like cmake –version. If CMake is installed, you’ll get its version number in the output. If it’s not, you’ll see the above error again.

2. What Is the Purpose of the cmake install Command?

The purpose of the CMake install command is to specify the way a project should be installed. A project executes the said command in the CMakeLists file to inform CMake about the way the installation scripts can be generated. Next, the same scripts will be executed at the installation time.

3. What Are Some Great Alternatives to CMake?

Some great alternatives to CMake are GNU Make, GNU Automake, Leiningen, SCons, FinalBuilder, A-A-P, Apache Buildr, and Distcc. Furthermore, you can check out the features and functionalities offered by each software to see which one among these fits the best to your requirements.

Conclusion

After reading this post, it’s clear that the CMake command not found Linux error is nothing but a signal that will light up when you execute the CMake commands without ensuring that your machine has the CMake tool and the PATH is set to the CMake directory path. So, having the tool is the key and the one and only fixing technique for the same error. Here you go with some noteworthy points for a quick recap of the above guide.

  • You can download the CMake precompiled binary based on your operating system from the CMake official website.
  • You can download and build CMake from the source releases available on the CMake official website.
  • It would be safe to use a package manager, such as Homebrew or build-essential, to install CMake.
  • The advanced package tool (APT) can make it easier for you to install CMake on Linux systems.

It won’t be wrong to say that there are a bunch of ways to let CMake enter your PC and make it possible for the CMake commands to run flawlessly.

  • Author
  • Recent Posts

Position is Everything

Your Go-To Resource for Learn & Build: CSS,JavaScript,HTML,PHP,C++ and MYSQL. Meet The Team

Position is Everything

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement. We’ll occasionally send you account related emails.

Already on GitHub?
Sign in
to your account

Closed

Sola1991 opened this issue

Jan 2, 2019

· 11 comments

Comments

@Sola1991

This my 1st time trying to compile a project.
I’m following building instructions of MSYS2 Method Building-on-Windows
but I’m facing this error.
Cmake command is not found

$ cmake .. -G 'Unix Makefiles' -DUSE_SDL2_LIBS=1
bash: cmake: command not found

make should have been downloaded & installed as part of:pacman --noconfirm --needed -Sy pkg-config make mingw-w64-i686-toolchain mingw-w64-i686-cmake mingw-w64-i686-zlib mingw-w64-i686-SDL2 mingw-w64-i686-SDL2_image mingw-w64-i686-SDL2_mixer

I’m using Windows 10×64-bit.

@mmatyas

Hm CMake should have been installed by mingw-w64-i686-cmake, did you see any related errors when you run pacman? It’s also possible that it comes from a different package now; try installing mingw-w64-cmake or just cmake to see if it works.

@Sola1991

MSYS2 still report the same error once I run the cmake argument.

This what I get after running thees code

$ pacman -Sy mingw-w64-cmake make
:: Synchronizing package databases...
 mingw32 is up to date
 mingw64 is up to date
 msys is up to date
error: target not found: mingw-w64-cmake
warning: make-4.2.1-1 is up to date -- reinstalling
$ pacman --noconfirm --needed -Sy pkg-config make mingw-w64-i686-toolchain mingw-w64-i686-cmake mingw-w64-i686-zlib mingw-w64-i686-SDL2 mingw-w64-i686-SDL2_image mingw-w64-i686-SDL2_mixer
:: Synchronizing package databases...
 mingw32 is up to date
 mingw64 is up to date
 msys is up to date
warning: pkg-config-0.29.2-1 is up to date -- skipping
warning: make-4.2.1-1 is up to date -- skipping
:: There are 17 members in group mingw-w64-i686-toolchain:
:: Repository mingw32
   1) mingw-w64-i686-binutils  2) mingw-w64-i686-crt-git  3) mingw-w64-i686-gcc  4) mingw-w64-i686-gcc-ada  5) mingw-w64-i686-gcc-fortran  6) mingw-w64-i686-gcc-libgfortran
   7) mingw-w64-i686-gcc-libs  8) mingw-w64-i686-gcc-objc  9) mingw-w64-i686-gdb  10) mingw-w64-i686-headers-git  11) mingw-w64-i686-libmangle-git  12) mingw-w64-i686-libwinpthread-git
   13) mingw-w64-i686-make  14) mingw-w64-i686-pkg-config  15) mingw-w64-i686-tools-git  16) mingw-w64-i686-winpthreads-git  17) mingw-w64-i686-winstorecompat-git

Enter a selection (default=all):
warning: mingw-w64-i686-binutils-2.30-5 is up to date -- skipping
warning: mingw-w64-i686-crt-git-7.0.0.5285.7b2baaf8-1 is up to date -- skipping
warning: mingw-w64-i686-gcc-7.4.0-1 is up to date -- skipping
warning: mingw-w64-i686-gcc-ada-7.4.0-1 is up to date -- skipping
warning: mingw-w64-i686-gcc-fortran-7.4.0-1 is up to date -- skipping
warning: mingw-w64-i686-gcc-libgfortran-7.4.0-1 is up to date -- skipping
warning: mingw-w64-i686-gcc-libs-7.4.0-1 is up to date -- skipping
warning: mingw-w64-i686-gcc-objc-7.4.0-1 is up to date -- skipping
warning: mingw-w64-i686-gdb-8.2.1-1 is up to date -- skipping
warning: mingw-w64-i686-headers-git-7.0.0.5285.7b2baaf8-1 is up to date -- skipping
warning: mingw-w64-i686-libmangle-git-7.0.0.5230.69c8fad6-1 is up to date -- skipping
warning: mingw-w64-i686-libwinpthread-git-7.0.0.5273.3e5acf5d-1 is up to date -- skipping
warning: mingw-w64-i686-make-4.2.1-2 is up to date -- skipping
warning: mingw-w64-i686-pkg-config-0.29.2-1 is up to date -- skipping
warning: mingw-w64-i686-tools-git-7.0.0.5272.d66350ea-1 is up to date -- skipping
warning: mingw-w64-i686-winpthreads-git-7.0.0.5273.3e5acf5d-1 is up to date -- skipping
warning: mingw-w64-i686-winstorecompat-git-7.0.0.5230.69c8fad6-1 is up to date -- skipping
warning: mingw-w64-i686-cmake-3.12.4-1 is up to date -- skipping
warning: mingw-w64-i686-zlib-1.2.11-5 is up to date -- skipping
warning: mingw-w64-i686-SDL2-2.0.9-1 is up to date -- skipping
warning: mingw-w64-i686-SDL2_image-2.0.4-1 is up to date -- skipping
warning: mingw-w64-i686-SDL2_mixer-2.0.4-1 is up to date -- skipping

@mmatyas

Checked the mingw-w64-i686-cmake package, it does provide CMake, but seems it’s not on your PATH for some reason (and probably the other 32-bit binaries aren’t either). Try installing mingw-w64-x86_64-cmake, it should add CMake and then we’ll see if it founds the other parts.

@Sola1991

Same issue; I see the pkg has been installed tough.
here is the log

$ pacman -Sy mingw-w64-x86_64-cmake
:: Synchronizing package databases...
mingw32 is up to date
mingw64 is up to date
msys is up to date
resolving dependencies...
looking for conflicting packages...
Packages (38) mingw-w64-x86_64-brotli-1.0.7-1  mingw-w64-x86_64-bzip2-1.0.6-6  mingw-w64-x86_64-c-ares-1.15.0-1  mingw-w64-x86_64-ca-certificates-20180409-1  mingw-w64-x86_64-curl-7.63.0-1
mingw-w64-x86_64-expat-2.2.6-1  mingw-w64-x86_64-gcc-libs-8.2.1+20181214-1  mingw-w64-x86_64-gettext-0.19.8.1-7  mingw-w64-x86_64-gmp-6.1.2-1  mingw-w64-x86_64-jansson-2.12-1
mingw-w64-x86_64-jemalloc-5.1.0-3  mingw-w64-x86_64-jsoncpp-1.8.4-3  mingw-w64-x86_64-libarchive-3.3.3-2  mingw-w64-x86_64-libffi-3.2.1-4  mingw-w64-x86_64-libiconv-1.15-3
mingw-w64-x86_64-libidn2-2.0.5-1  mingw-w64-x86_64-libmetalink-0.1.3-3  mingw-w64-x86_64-libpsl-0.20.2-1  mingw-w64-x86_64-libssh2-1.8.0-3  mingw-w64-x86_64-libsystre-1.0.1-4
mingw-w64-x86_64-libtasn1-4.13-1  mingw-w64-x86_64-libtre-git-r128.6fb7206-2  mingw-w64-x86_64-libunistring-0.9.10-1  mingw-w64-x86_64-libuv-1.24.1-1
mingw-w64-x86_64-libwinpthread-git-7.0.0.5273.3e5acf5d-1  mingw-w64-x86_64-lz4-1.8.3-1  mingw-w64-x86_64-lzo2-2.10-1  mingw-w64-x86_64-mpc-1.1.0-1  mingw-w64-x86_64-mpfr-4.0.1-2
mingw-w64-x86_64-nettle-3.4.1-1  mingw-w64-x86_64-nghttp2-1.35.1-1  mingw-w64-x86_64-openssl-1.1.1.a-1  mingw-w64-x86_64-p11-kit-0.23.14-1  mingw-w64-x86_64-rhash-1.3.6-2
mingw-w64-x86_64-xz-5.2.4-1  mingw-w64-x86_64-zlib-1.2.11-5  mingw-w64-x86_64-zstd-1.3.8-1  mingw-w64-x86_64-cmake-3.12.4-1
Total Download Size:    21.79 MiB
Total Installed Size:  156.76 MiB
:: Proceed with installation? [Y/n] y
:: Retrieving packages...
mingw-w64-x86_64-gmp-6.1.2-1-any                                                           486.0 KiB   266K/s 00:02 [#####################################################################] 100%
mingw-w64-x86_64-mpfr-4.0.1-2-any                                                          338.3 KiB   512K/s 00:01 [#####################################################################] 100%
mingw-w64-x86_64-mpc-1.1.0-1-any                                                            78.9 KiB  1924K/s 00:00 [#####################################################################] 100%
mingw-w64-x86_64-libwinpthread-git-7.0.0.5273.3e5acf5d-1-any                                43.3 KiB  1445K/s 00:00 [#####################################################################] 100%
mingw-w64-x86_64-gcc-libs-8.2.1+20181214-1-any                                             578.6 KiB   559K/s 00:01 [#####################################################################] 100%
mingw-w64-x86_64-c-ares-1.15.0-1-any                                                        98.1 KiB  68.0K/s 00:01 [#####################################################################] 100%
mingw-w64-x86_64-brotli-1.0.7-1-any                                                        329.2 KiB   254K/s 00:01 [#####################################################################] 100%
mingw-w64-x86_64-expat-2.2.6-1-any                                                         158.7 KiB   630K/s 00:00 [#####################################################################] 100%
mingw-w64-x86_64-libiconv-1.15-3-any                                                       616.3 KiB   561K/s 00:01 [#####################################################################] 100%
mingw-w64-x86_64-gettext-0.19.8.1-7-any                                                      3.1 MiB   597K/s 00:05 [#####################################################################] 100%
mingw-w64-x86_64-libunistring-0.9.10-1-any                                                 625.6 KiB   565K/s 00:01 [#####################################################################] 100%
mingw-w64-x86_64-libidn2-2.0.5-1-any                                                       114.0 KiB  1932K/s 00:00 [#####################################################################] 100%
mingw-w64-x86_64-libmetalink-0.1.3-3-any                                                    61.1 KiB  1970K/s 00:00 [#####################################################################] 100%
mingw-w64-x86_64-libpsl-0.20.2-1-any                                                       101.9 KiB  1756K/s 00:00 [#####################################################################] 100%
mingw-w64-x86_64-libtasn1-4.13-1-any                                                       186.3 KiB   773K/s 00:00 [#####################################################################] 100%
mingw-w64-x86_64-libffi-3.2.1-4-any                                                         44.9 KiB  1953K/s 00:00 [#####################################################################] 100%
mingw-w64-x86_64-p11-kit-0.23.14-1-any                                                     296.0 KiB   664K/s 00:00 [#####################################################################] 100%
mingw-w64-x86_64-ca-certificates-20180409-1-any                                            356.3 KiB   769K/s 00:00 [#####################################################################] 100%
mingw-w64-x86_64-bzip2-1.0.6-6-any                                                          81.3 KiB  1891K/s 00:00 [#####################################################################] 100%
mingw-w64-x86_64-zlib-1.2.11-5-any                                                         177.8 KiB   330K/s 00:01 [#####################################################################] 100%
mingw-w64-x86_64-openssl-1.1.1.a-1-any                                                       4.7 MiB   598K/s 00:08 [#####################################################################] 100%
mingw-w64-x86_64-libssh2-1.8.0-3-any                                                       232.3 KiB   526K/s 00:00 [#####################################################################] 100%
mingw-w64-x86_64-jansson-2.12-1-any                                                         65.8 KiB  1530K/s 00:00 [#####################################################################] 100%
mingw-w64-x86_64-jemalloc-5.1.0-3-any                                                      306.3 KiB   633K/s 00:00 [#####################################################################] 100%
mingw-w64-x86_64-nghttp2-1.35.1-1-any                                                      201.0 KiB   280K/s 00:01 [#####################################################################] 100%
mingw-w64-x86_64-curl-7.63.0-1-any                                                        1144.9 KiB   486K/s 00:02 [#####################################################################] 100%
mingw-w64-x86_64-jsoncpp-1.8.4-3-any                                                       284.3 KiB   618K/s 00:00 [#####################################################################] 100%
mingw-w64-x86_64-lz4-1.8.3-1-any                                                           133.7 KiB   541K/s 00:00 [#####################################################################] 100%
mingw-w64-x86_64-lzo2-2.10-1-any                                                           101.1 KiB  3.40M/s 00:00 [#####################################################################] 100%
mingw-w64-x86_64-libtre-git-r128.6fb7206-2-any                                              84.2 KiB  75.4K/s 00:01 [#####################################################################] 100%
mingw-w64-x86_64-libsystre-1.0.1-4-any                                                      24.0 KiB  0.00B/s 00:00 [#####################################################################] 100%
mingw-w64-x86_64-nettle-3.4.1-1-any                                                        419.4 KiB   466K/s 00:01 [#####################################################################] 100%
mingw-w64-x86_64-xz-5.2.4-1-any                                                            297.7 KiB   595K/s 00:01 [#####################################################################] 100%
mingw-w64-x86_64-zstd-1.3.8-1-any                                                          369.4 KiB   557K/s 00:01 [#####################################################################] 100%
mingw-w64-x86_64-libarchive-3.3.3-2-any                                                    647.4 KiB   492K/s 00:01 [#####################################################################] 100%
mingw-w64-x86_64-libuv-1.24.1-1-any                                                        187.6 KiB   439K/s 00:00 [#####################################################################] 100%
mingw-w64-x86_64-rhash-1.3.6-2-any                                                         163.9 KiB   656K/s 00:00 [#####################################################################] 100%
mingw-w64-x86_64-cmake-3.12.4-1-any                                                          4.7 MiB   439K/s 00:11 [#####################################################################] 100%
(38/38) checking keys in keyring                                                                                     [#####################################################################] 100%
(38/38) checking package integrity                                                                                   [#####################################################################] 100%
(38/38) loading package files                                                                                        [#####################################################################] 100%
(38/38) checking for file conflicts                                                                                  [#####################################################################] 100%
(38/38) checking available disk space                                                                                [#####################################################################] 100%
:: Processing package changes...
( 1/38) installing mingw-w64-x86_64-gmp                                                                              [#####################################################################] 100%
( 2/38) installing mingw-w64-x86_64-mpfr                                                                             [#####################################################################] 100%
( 3/38) installing mingw-w64-x86_64-mpc                                                                              [#####################################################################] 100%
( 4/38) installing mingw-w64-x86_64-libwinpthread-git                                                                [#####################################################################] 100%
( 5/38) installing mingw-w64-x86_64-gcc-libs                                                                         [#####################################################################] 100%
( 6/38) installing mingw-w64-x86_64-c-ares                                                                           [#####################################################################] 100%
( 7/38) installing mingw-w64-x86_64-brotli                                                                           [#####################################################################] 100%
( 8/38) installing mingw-w64-x86_64-expat                                                                            [#####################################################################] 100%
( 9/38) installing mingw-w64-x86_64-libiconv                                                                         [#####################################################################] 100%
(10/38) installing mingw-w64-x86_64-gettext                                                                          [#####################################################################] 100%
(11/38) installing mingw-w64-x86_64-libunistring                                                                     [#####################################################################] 100%
(12/38) installing mingw-w64-x86_64-libidn2                                                                          [#####################################################################] 100%
(13/38) installing mingw-w64-x86_64-libmetalink                                                                      [#####################################################################] 100%
(14/38) installing mingw-w64-x86_64-libpsl                                                                           [#####################################################################] 100%
(15/38) installing mingw-w64-x86_64-libtasn1                                                                         [#####################################################################] 100%
(16/38) installing mingw-w64-x86_64-libffi                                                                           [#####################################################################] 100%
(17/38) installing mingw-w64-x86_64-p11-kit                                                                          [#####################################################################] 100%
(18/38) installing mingw-w64-x86_64-ca-certificates                                                                  [#####################################################################] 100%
(19/38) installing mingw-w64-x86_64-bzip2                                                                            [#####################################################################] 100%
(20/38) installing mingw-w64-x86_64-zlib                                                                             [#####################################################################] 100%
(21/38) installing mingw-w64-x86_64-openssl                                                                          [#####################################################################] 100%
(22/38) installing mingw-w64-x86_64-libssh2                                                                          [#####################################################################] 100%
(23/38) installing mingw-w64-x86_64-jansson                                                                          [#####################################################################] 100%
(24/38) installing mingw-w64-x86_64-jemalloc                                                                         [#####################################################################] 100%
(25/38) installing mingw-w64-x86_64-nghttp2                                                                          [#####################################################################] 100%
(26/38) installing mingw-w64-x86_64-curl                                                                             [#####################################################################] 100%
(27/38) installing mingw-w64-x86_64-jsoncpp                                                                          [#####################################################################] 100%
(28/38) installing mingw-w64-x86_64-lz4                                                                              [#####################################################################] 100%
(29/38) installing mingw-w64-x86_64-lzo2                                                                             [#####################################################################] 100%
(30/38) installing mingw-w64-x86_64-libtre-git                                                                       [#####################################################################] 100%
(31/38) installing mingw-w64-x86_64-libsystre                                                                        [#####################################################################] 100%
(32/38) installing mingw-w64-x86_64-nettle                                                                           [#####################################################################] 100%
(33/38) installing mingw-w64-x86_64-xz                                                                               [#####################################################################] 100%
(34/38) installing mingw-w64-x86_64-zstd                                                                             [#####################################################################] 100%
(35/38) installing mingw-w64-x86_64-libarchive                                                                       [#####################################################################] 100%
(36/38) installing mingw-w64-x86_64-libuv                                                                            [#####################################################################] 100%
(37/38) installing mingw-w64-x86_64-rhash                                                                            [#####################################################################] 100%
(38/38) installing mingw-w64-x86_64-cmake                                                                            [#####################################################################] 100%
Optional dependencies for mingw-w64-x86_64-cmake
mingw-w64-x86_64-qt5: CMake Qt GUI
Sola@Sola MSYS /c/supermariowar/build
$ cmake .. -G 'Unix Makefiles' -DUSE_SDL2_LIBS=1
bash: cmake: command not found

@mmatyas

Ah there’s the issue:

Sola@Sola MSYS /c/supermariowar/build

You should launch the «MSYS2 MinGW 32-bit» command prompt, which adds /mingw32/bin to your PATH.

@Sola1991

Thanks @mmatyas,
You are totally correct. Now I’m able to run cmake & make arguments.

@Je55ie

Hi. My situation is similar with Sola1991, but after I finish the steps above I had another error.
je55i@LAPTOP-JFI2G606 MINGW32 /d/Master/zacros/zacros_2.0/build
$ cmake .. -G»MSYS Makefiles»
CMake Error: CMake was unable to find a build program corresponding to «MSYS Makefiles». CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
CMake Error: CMake was unable to find a build program corresponding to «MSYS Makefiles». CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
CMake Error: CMAKE_Fortran_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_AR was not found, please set to archive program.
— Configuring incomplete, errors occurred!

@mmatyas

Hi, have you tried running CMake with -G 'Unix Makefiles'? I’m not sure «MSYS Makefiles» works.

@Xagarsan

Hi! Im new at this also and when I put what you said (MSYS2 MinGW 32-bit), it says this

$ MSYS2 MinGW 32-bit
-bash: MSYS2: command not found

@mmatyas

Hi! MSYS2 MinGW 32-bit is a program installed by the MSYS installer (or, at least it did 3 years ago). You can access it from the Start menu, and you should see a slightly different command prompt when you launch it.

@mmatyas

Just checked, it’s called MSYS2 MINGW32 now. You should see MINGW32 in the prompt.


Linux

  • 20.12.2016
  • 10 051
  • 4
  • 07.03.2019
  • 10
  • 9
  • 1

cmake: command not found

  • Содержание статьи
    • Описание
    • Комментарии к статье ( 4 шт )
    • Добавить комментарий

В данной статье будут даны рекомендации о том, что делать в случаях, когда при попытке собрать что-либо из исходников, вы получаете ошибку, говорящую о том, что cmake не найден в вашей системе.

Описание

Эту ошибку очень часто можно встретить при начале компиляции чего-либо из исходного кода в дистрибутивах, которые имеют в своем названии minimal. Например, Ubuntu-1610-yakkety-64-minimal ;)

cmake: command not found

Она означает, что в вашей системе не найдена кроссплатформенная система автоматизации сборки программного обеспечения из исходного кода (она же и есть cmake). Для установки cmake в большинстве современных дистрибутивов достаточно сделать следующее:

sudo apt-get update
sudo apt-get install cmake

После этого можно пробовать запустить cmake еще раз.

Я пытаюсь построить https://github.com/AlbertWerner/cryptonotecoinwallet и сталкивается с проблемой.

Согласно README репо, я могу запустить cmake Команда и она завершается без каких-либо ошибок. Но потом, когда я бегу make, это дает мне ошибку ниже.

$ make
make: /usr/bin/cmake: Command not found
make: *** [Makefile:5138: cmake_check_build_system] Error 127

Я использую MSYS на Windows, и вот соответствующие подробности.

$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/opt/bin:/c/Windows/System32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0/:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/mingw32/bin
$ which cmake
/mingw32/bin/cmake

Похоже, он ищет cmake на неправильном пути.

Makefile

cmake_check_build_system:
$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0
.PHONY : cmake_check_build_system # <== Line 5139

Я не уверен, что не так. Пожалуйста, помогите мне.

Благодарю.

0

Решение

Убедитесь, что вы запускаете MSYS2, используя mingw32.exe исполняемый на верхнем уровне вашей установки MSYS2, и что вы используете эту среду при первом запуске cmake, Если вы запускали CMake в другой среде, удалите все созданные файлы. Команды для бега cmake и создание проекта должно быть примерно таким, если разработчики настроили его разумным образом:

mkdir build
cd build
cmake .. -G"MSYS Makefiles"make

Я не пробовал это сам, потому что я опасаюсь запуска случайного кода из Интернета, но я нашел это примечание в CMakefile, указывающее, что разработчики не поддерживают MSYS2:

if (WIN32)
if (NOT MSVC)
message(FATAL_ERROR "Only MSVC is supported on this platform")
endif ()
...

Поэтому вам придется потратить некоторые усилия на перенос кода Windows для этой программы в GCC, если вы действительно хотите это сделать.

0

Другие решения

Других решений пока нет …

According to CMake developers,
Windows’s find cannot be called directly by cmake from within execute_process, because of a limitation of the CreateProcess API and of the non-standard way find parses arguments.

It can be called indirectly though, by creating a temporary batch script.

My problem of counting occurrences of a string from the output of a program in Windows is solved in the following way:

file(WRITE ${CMAKE_BINARY_DIR}/countLines.bat [[@find /v /c "" %1]])
execute_process(COMMAND <firstCommandPipingSomethingToFind> COMMAND findstr <regular expression> COMMAND countLines.bat WORKING_DIRECTORY ${CMAKE_BINARY_DIR} OUTPUT_VARIABLE N_MATCHES OUTPUT_STRIP_TRAILING_WHITESPACE)
message(STATUS "N_MATCHES=${N_MATCHES}")
file(REMOVE ${CMAKE_BINARY_DIR}/countLines.bat)

The advantage of findstr in between is that it supports regular expressions. find is only used to count matching lines.

The @ in front of find is to prevent the command invocation within the script from ending up in the output variable.

  • Bamboo dock скачать для windows 10
  • Bad system config info windows 10 как исправить через командную строку windows
  • Baseus ba04 driver windows 10
  • Basecamp garmin скачать бесплатно на русском для windows 7
  • Bamboo ctl 460 драйвер windows 10