wiki:BuildingOnUnixWithCMake

Version 14 (modified by mloskot, 9 years ago) (diff)

List tickets related to CMake

*** IMPORANT: Testers of CMake configuration wanted! Please, try to build GEOS with CMake and report any problems by submitting New Ticket. Patches welcome! ***

Building on Unix with CMake

The following instructions are dedicated to users of Unix-like systems (Linux, Mac OS X, Solaris, *BSD, etc.)

This article describes how to use CMake build system to build and install GEOS from sources.

GEOS has got equipped with build configuration for CMake shortly after GEOS 3.2.0 release (ticket #317), thus it is considered as work in progress, experimental. Hopefully, it will get into next release of GEOS 3.3.0 version.

Having CMake installed on Unix-like system, there are two ways of running CMake to configure and build a software with CMake:

  • cmake - CLI program accepting options or running in interactive mode
  • ccmake - program with curses-based GUI

Requirements

  • CMake 2.6 or later
  • Decent C++ compiler and C++ Standard Library, GNU GCC 4.x or later recommended
  • GEOS source code. Currently, only source code in SVN trunk is configured for CMake

Configure

Important, it is highly recommended to configure build out of source code tree.

$ svn checkout http://svn.osgeo.org/geos/trunk trunk
$ mkdir build
$ ls
build trunk
$ cd build
$ cmake ../trunk
$ make help

There is collection of CMake variables available to set by user to control various aspects of compilation and installation. For instance CMAKE_INSTALL_PREFIX variable which by default is set to /usr/local directory.

List of CMake options specific to GEOS:

  • GEOS_ENABLE_TESTS - Set to OFF|ON (default) to control build of GEOS tests package
  • GEOS_ENABLE_INLINE - Set to OFF|ON (default) to control GEOS compilation with small functions inlining
  • GEOS_ENABLE_ASSERT - Set to ON|OFF (default) to build GEOS with assert() macro enabled (not available for Visual C++ compiler)

Example:

$ cmake ../trunk -DGEOS_ENABLE_TESTS=ON -DGEOS_ENABLE_INLINE=OFF

Build

$ make

Test

In CMake build system, testing capabilities are provided by CTest which is distributed together with CMake package.

After the build is ready, tests can be run. Natively, CMake uses target named test:

$ make test

For convenience, Autotools-like alias is also available:

$ make check

It is also possible to run ctest program directly, but not through any of the make targets. This option gives access to number of ctest command line options (cmake --help), for example:

$ ctest
$ ctest --verbose

Install

$ make install

Open Tickets

#878
Static library does not contain C API
#901
cmake is not compiling doc/example
#903
cmake files get compiled twice