Dobedani
Dobedani

Reputation: 578

Getting cmake to work under Cygwin on Windows 7

I installed the latest Cygwin on my Windows 7 machine: version 2.893 (64-bits). I made sure I included cmake, i.e. I was able to add several packages by running the Cygwin net release setup program again, after doing the first installation. I then tried to use cmake and made sure I invoked it from the bin directory:

user008@L0147816 /bin
$ ./cmake
CMake Error: Could not find CMAKE_ROOT !!!
CMake has most likely not been installed correctly.
Modules directory not found in
//share/cmake-3.6.2
Usage

cmake [options] <path-to-source>
cmake [options] <path-to-existing-build>

Specify a source directory to (re-)generate a build system for it in the
current working directory.  Specify an existing build directory to
re-generate its build system.

Run 'cmake --help' for more information.

I don't know where the build directory could be. I'm relatively new to Cygwin. I hope somebody has found a solution for getting cmake installed and working properly under Cygwin.

Upvotes: 2

Views: 1957

Answers (2)

seedjyh
seedjyh

Reputation: 401

Here a solution I just found.

Let's name 3 directories:

  • {cygwin64-path}/bin/: cmake.exe is here.
  • {cygwin64-path}/usr/share/: cmake module directory (such as cmake-3.20.0) is here.
  • {cygwin64-path}/share/: cmake.exe trying to find cmake-module-directory here, but it doesn't exist.

It's wired because cygwin install cmake-module-directory in {cygwin64-path}/usr/share/, but cmake.exe looks for the directory in {cygwin64-path}/share/.

So solution is simple. Each one below works.

METHOD 1: Create the directory {cygwin64-path}/share/ and copy all relevant directories and files from {cygwin64-path}/usr/share/ to the new directory.

METHOD 2: Create a Symbolic links {cygwin64-path}/share/ to {cygwin64-path}/usr/share/.

  • In windows 10 Administrator cmd.exe: mklink /J share usr\share and all works.
  • Or use WSL or Cygwin64 Terminal: ln -s usr/share share

Upvotes: 1

matzeri
matzeri

Reputation: 8496

This looks cmake 101.

Assuming you want to just build a software download from somewhere eg gl2ps:

# choosing a test area
$ cd /tmp
# downloading source
$ wget http://geuz.org/gl2ps/src/gl2ps-1.4.0.tgz
# expanding source code
$ tar -xf gl2ps-1.4.0.tgz
$ ls gl2ps-1.4.0-source/
CMakeLists.txt  COPYING.LGPL  gl2ps.h    gl2ps.tex    gl2psTestSimple.c
COPYING.GL2PS   gl2ps.c       gl2ps.pdf  gl2psTest.c  README.txt
# preparing a build area
$ mkdir build
$ cd build
# invoking cmake and pointing to the source directory 
$ cmake ../gl2ps-1.4.0-source/
-- The C compiler identification is GNU 7.3.0
[cut ...]
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/build

# running the build 
$ make
Scanning dependencies of target shared
[ 11%] Building C object CMakeFiles/shared.dir/gl2ps.o
...
[ 88%] Building C object CMakeFiles/gl2psTestSimple.dir/gl2psTestSimple.o
[100%] Linking C executable gl2psTestSimple.exe
[100%] Built target gl2psTestSimple

Instead for learning how to build with cmake, go to https://cmake.org/cmake-tutorial/

Upvotes: 2

Related Questions