Opened 9 years ago

Closed 7 years ago

Last modified 7 weeks ago

#317 closed task (fixed)

Add configuration for CMake build system

Reported by: mloskot Owned by: mloskot
Priority: major Milestone: 3.3.0
Component: Build/Install Version: master
Severity: Idea Keywords: cmake
Cc:

Description

The aim of this task is to add build configure for CMake - a modern cross-platform fast build system, a meta-builder.

One of many reasons is that maintenance of the Visual C++ solutions and projects is usually a big hassle. My aim is to replace it (msvc80, msvc90 and msvc10 in trunk/build) with CMake configuration. Then users will be able to generate Visual Studio projects or other build configurations of their wish which are supported by CMake.

Requirements:

  • CMake 2.6+
  • One of the build toolsets supported by GEOS and also by CMake generators (i.e. GCC 4.x, Visual Studio 2003+, XCode 2.8+)

Resources:

Change History (37)

comment:1 Changed 9 years ago by mloskot

Owner: changed from pramsey to mloskot
Status: newassigned

Added first straps of configuration for CMake build system (r2852)

  • compilation of C++ API library
  • compilation of C API library

comment:2 Changed 9 years ago by mloskot

Added platform.h.cmake file used by build configuration for CMake build system (r2856)

comment:3 Changed 9 years ago by mloskot

Added generation of build-specific platform.h file from platform.h.cmake (r2858)

comment:4 Changed 9 years ago by mloskot

Added checks of C/C++ headers and library features like 64-bit integer type (r2859)

comment:5 Changed 9 years ago by mloskot

Refined detection of isnan and isfinite features (r2860)

comment:6 Changed 9 years ago by mloskot

  • Now CMake can generates geos_c.h (r2861).
  • Removed include/geos/version.h.cmake as no longer needed - CMake can subsitute variables of Autoconf-style @VAR@ very well.

comment:7 Changed 9 years ago by mloskot

Updated CMake configuration (r2862):

  • CMake generates config headers in build tree.
  • Added generation of geos-config script.
  • Refined include directories settings.
  • Added unit tests package to the configuration.
  • Status: GEOS core + GEOS C library + unit tests build and run successfully.

comment:8 Changed 9 years ago by mloskot

Added simplewkttester and xmltester tests to CMake configuration (r2863)

comment:9 Changed 9 years ago by mloskot

Configured make install target for GEOS C++ static library archive and headers (r2865)

comment:10 Changed 9 years ago by mloskot

Configured make install target for GEOS C shared library and headers (r2866)

comment:11 Changed 9 years ago by mloskot

Configured make install for tools to install geos-config program on Unix platforms (r2867)

comment:12 Changed 9 years ago by mloskot

Cleaned redundant include for <cmath> and <math.h> from platform.h.cmake (r2871)

comment:13 Changed 9 years ago by mloskot

Example of how to build GEOS with CMake on Linux:

  • Check if you have cmake program installed (I installed CMake from sources):
mloskot@dog:~/dev/geos/_svn/build$ which cmake
/usr/local/bin/cmake
mloskot@dog:~/dev/geos/_svn/build$ cmake --version
cmake version 2.8.0
  • Prepare build directory
mloskot@dog:~/dev/geos/_svn/trunk$ mkdir ../build
mloskot@dog:~/dev/geos/_svn/trunk$ cd ../build/
  • Configure build, optionally, with custom installation prefix
mloskot@dog:~/dev/geos/_svn/build$ cmake ../trunk -DCMAKE_INSTALL_PREFIX=$HOME/usr
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Setting GEOS version 3.3.0 as port of JTS 1.10.0
-- Setting GEOS C API version 1.6.1
-- Looking for include files HAVE_STDINT_H
-- Looking for include files HAVE_STDINT_H - found
-- Looking for include files HAVE_INTTYPES_H
-- Looking for include files HAVE_INTTYPES_H - found
-- Looking for include files HAVE_IEEEFP_H
-- Looking for include files HAVE_IEEEFP_H - not found.
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of int64_t
-- Check size of int64_t - done
-- Looking for std::isnan
-- Looking for std::isnan - not found.
-- Looking for isnan
-- Looking for isnan - found
-- Looking for std::isfinite
-- Looking for std::isfinite - not found.
-- Looking for isfinite
-- Looking for isfinite - found
-- Configuring done
-- Generating done
-- Build files have been written to: /home/mloskot/dev/geos/_svn/build
mloskot@dog:~/dev/geos/_svn/build$ 
  • Build
mloskot@dog:~/dev/geos/_svn/build$ make
Scanning dependencies of target geos
[  0%] Building CXX object src/CMakeFiles/geos.dir/operation/valid/RepeatedPointTester.cpp.o
...
[ 95%] Building CXX object tests/unit/CMakeFiles/geos_unit.dir/linearref/LengthIndexedLineTest.cpp.o
Linking CXX executable geos_unit
[ 97%] Built target geos_unit
Scanning dependencies of target simplewkttester
[ 97%] Building CXX object tests/xmltester/CMakeFiles/simplewkttester.dir/SimpleWKTTester.cpp.o
Linking CXX executable simplewkttester
[ 97%] Built target simplewkttester
Scanning dependencies of target xmltester
[ 98%] Building CXX object tests/xmltester/CMakeFiles/xmltester.dir/XMLTester.cpp.o
[ 98%] Building CXX object tests/xmltester/CMakeFiles/xmltester.dir/tinyxml/tinyxml.cpp.o
[ 98%] Building CXX object tests/xmltester/CMakeFiles/xmltester.dir/tinyxml/tinystr.cpp.o
[ 99%] Building CXX object tests/xmltester/CMakeFiles/xmltester.dir/tinyxml/tinyxmlerror.cpp.o
[ 99%] Building CXX object tests/xmltester/CMakeFiles/xmltester.dir/tinyxml/tinyxmlparser.cpp.o
[ 99%] Building CXX object tests/xmltester/CMakeFiles/xmltester.dir/BufferResultMatcher.cpp.o
[100%] Building CXX object tests/xmltester/CMakeFiles/xmltester.dir/SingleSidedBufferResultMatcher.cpp.o
Linking CXX executable xmltester
[100%] Built target xmltester
mloskot@dog:~/dev/geos/_svn/build$
  • Install GEOS binaries, headers and geos-config script
mloskot@dog:~/dev/geos/_svn/build$ make install
[ 78%] Built target geos
[ 78%] Built target geos_c
[ 97%] Built target geos_unit
[ 97%] Built target simplewkttester
[100%] Built target xmltester
Install the project...
-- Install configuration: ""
-- Installing: /home/mloskot/usr/include/geos/geos.h
-- Installing: /home/mloskot/usr/include/geos/platform.h
-- Installing: /home/mloskot/usr/include/geos/version.h
-- Installing: /home/mloskot/usr/include/geos
-- Installing: /home/mloskot/usr/include/geos/profiler.h
-- Installing: /home/mloskot/usr/include/geos/inline.h
...
-- Installing: /home/mloskot/usr/include/geos/planargraph.h
-- Installing: /home/mloskot/usr/lib/libgeos.a
-- Installing: /home/mloskot/usr/include/geos/geos_c.h
-- Installing: /home/mloskot/usr/lib/libgeos_c.so
-- Installing: /home/mloskot/usr/bin/geos-config
mloskot@dog:~/dev/geos/_svn/build$ 

Feedback welcome!

comment:14 Changed 9 years ago by mloskot

Updated MSVC specifics (r2875):

  • Added CXX flags specific to Visual C++ compiler
  • Added ENABLE_MSVC_MP option to allow setting Visual C++ /MP flag that enables multi-process compilation:
    cmake ..\trunk -DENABLE_MSVC_MP=ON
    

comment:15 Changed 9 years ago by mloskot

Compiler flags can not be handled using CMake list type (r2876)

comment:16 Changed 9 years ago by mloskot

Fixed related ticket #318

Addd extra test for STL classes in std namespace using TestForANSIForScope macro (r2879)

comment:17 Changed 9 years ago by mloskot

Fixed use of incorrect (r2879) macro name in trunk (rr2880)

comment:18 Changed 9 years ago by mloskot

comment:19 Changed 9 years ago by mloskot

Disabled GEOS_ENABLE_ASSERT option for Visual Studio builds - not supported, no sense and causes conflicts with /MD vs /MDd (r2885)

comment:20 Changed 9 years ago by mloskot

  • Configured shared library target for C++ API (r2887)
  • Added library version information and TODO comment about SOVERSION

comment:21 Changed 9 years ago by mloskot

comment:22 Changed 9 years ago by mloskot

  • Configured shared library target for C++ API (r2887)
  • Added library version information and TODO comment about SOVERSION (r2887)
  • GEOS C++ static library was missing from installation targets (r2888)
  • Configured make test target for CMake build currently executing only geos_test (r2892)
  • Solved problem with repeated definition of getMachineByteOrder function (r2893)

comment:23 Changed 9 years ago by mloskot

Related ticket #322 - CMake Build Instruction

comment:24 Changed 9 years ago by mloskot

Added two new builders to GEOS Buildbot for CMake configuration testing:

comment:25 Changed 9 years ago by mloskot

  • Based on Sandro's request, configured make check target for CMake as alias to make test to mimic GNU Autotools manner of running tests (r2895)

comment:26 Changed 9 years ago by mloskot

Fixed related ticket #327

comment:27 Changed 9 years ago by mloskot

Fixed missing substitution of @libdir@ in geos-config (r2902)

comment:28 Changed 9 years ago by mloskot

Regarding last fix, here is what I get now after rebuilding and installing geos-config with CMake:

mloskot@dog:~/dev/geos/_svn/build$ cmake ../trunk -DCMAKE_INSTALL_PREFIX=${HOME}/usr
...
mloskot@dog:~/dev/geos/_svn/build$ make
...
mloskot@dog:~/dev/geos/_svn/build$ make install
...
-- Installing: /home/mloskot/usr/bin/geos-config
mloskot@dog:~/dev/geos/_svn/build$ ~/usr/bin/geos-config --version --prefix --libs --cflags --ldflags --includes --jtsport
3.3.0
/home/mloskot/usr
-L/home/mloskot/usr/lib -lgeos
-I/home/mloskot/usr/include
-L/home/mloskot/usr/lib
/home/mloskot/usr/include
1.10.0

comment:29 Changed 9 years ago by mloskot

Fixed problem in CMake version comparison to disable platform.h (r2905)

There is a problem on Debian 5.0 which includes very early version of CMake 2.6, but I wanted to use more recent features.

comment:30 Changed 9 years ago by mloskot

Ported list of SAVE_XMLTESTS to CMake configuration of XMLTester (r2906)

mloskot@dog:~/dev/geos/_svn/build$ make check
Test project /home/mloskot/dev/geos/_svn/build
    Start 1: geos_unit
1/2 Test #1: geos_unit ........................   Passed    0.10 sec
    Start 2: xmltester
2/2 Test #2: xmltester ........................   Passed   19.45 sec

100% tests passed, 0 tests failed out of 2

Total Test time (real) =  19.56 sec
Built target check

comment:31 Changed 9 years ago by mloskot

Resolution: fixed
Status: assignedclosed

Fixed related ticket #330

comment:32 Changed 9 years ago by mloskot

Resolution: fixed
Status: closedreopened

comment:33 Changed 9 years ago by mloskot

Patch from Gavin Heavyside that enables CMake to build GEOS as a dependency of user-defined project (r2916)

comment:34 Changed 9 years ago by mloskot

Added cmake/cmake_uninstall.cmake.in script and configured make uninstall target for CMake configuration (r2934)

comment:35 Changed 9 years ago by mloskot

There is Wiki guide about Building on Unix with CMake

comment:36 Changed 7 years ago by mloskot

Resolution: fixed
Status: reopenedclosed

I think it's reasonable to consider this task completed. Closing.

comment:37 Changed 7 weeks ago by Regina Obe <lr@…>

In 7b40d44/git:

Clarify reason for sed change. References #317

Note: See TracTickets for help on using tickets.