cmake (was Re: [geos-devel] 3.0?)

Mateusz Loskot mateusz at loskot.net
Mon Sep 4 02:56:14 EDT 2006


Mateusz Loskot wrote:
> 孙高勇 wrote:
>> #   CMakeLists.txt for geos 3.0 by sungaoyong
>> #   2006-09-04 sungaoyong at gmail.com <mailto:sungaoyong at gmail.com>
>> #     Building on Cmake 2.4
>> #     ------------------------------------
>> #   test on windows mingw32 g++ 3.4.2、msvc 2003,linux g++ 4.1
>> #   hope it's usefull
> 
> First, I'd like to thank you on behalf of GEOS team for
> this contribution!
> 
> I also run it with success!
> I use Linux (Ubuntu 6.06) + gcc 4.0.3 + cmake 2.4.3 (compiled
> from sources)
> 
> Here are binaries generated by cmake:
> libgeos_i.a
> libgeos.so
> TestSweepLineSpeed
> 
> Is it possible to put CMakeLists.txt file outside the 'source' tree?
> For example, to <GEOS ROOT>/build/cmake
> 
> cmake generates Makefile on the same level as automake, so
> I'd suggest to put cmake outside the tree to avoid potential
> conflicts with autotools (some problems may be unknown at the moment).
> 
> Is this possible to use cmake thisway?

Hi,

I played for a few minutes with cmake and CMakeLists.txtfile
and I managed to do complete build from outside the sources tree.

I atteched my version of CMakeLists.txt file. Please note, I'm not sure
it's correct, as I'm not a cmake user yet, though it works for me :-)

I copied this file to following location:
<GEOS>/build/cmake/CMakeLists.txt
where <GEOS> is root sources dir of GEOS.
In my environment it's $HOME/dev/geos/_svn/geos/

Now, to build outside the sources tree I run:

$ cd $HOME/dev/geos/_svn/geos/build/cmake
$ cmake .
$ make
-- Configuring done
-- Generating done
-- Build files have been written to:
/home/mloskot/dev/geos/_svn/geos/build/cmake
[  0%] Building CXX object
CMakeFiles/geos.dir/home/mloskot/dev/geos/_svn/geos/source/inlines.o
...
[ 99%] Building CXX object
CMakeFiles/geos_i.dir/home/mloskot/dev/geos/_svn/geos-cmake/source/util/math.o
[100%] Building CXX object
CMakeFiles/geos_i.dir/home/mloskot/dev/geos/_svn/geos-cmake/source/util/Profiler.o
Linking CXX static library libgeos_i.a
[100%] Built target geos_i

$ pwd
/home/mloskot/dev/geos/_svn/geos/build/cmake
$ ls
libgeos_i.a
libgeos.so
TestSweepLineSpeed
...

So, it seems to work.
It may need some more work to tune it but I'd stick to this
approach of "building outside the sources tree".

Cheers
-- 
Mateusz Loskot
http://mateusz.loskot.net
-------------- next part --------------
#   CMakeLists.txt for geos 3.0 by sungaoyong
#
#   2006-09-04 mateusz at loskot.net
#   Modified to build from outside the source tree (<GEOS>/build/cmake)
#
#   2006-09-04 sungaoyong at gmail.com
# 	Building on Cmake 2.4 
# 	------------------------------------
#   test on windows mingw32 g++ 3.4.2¡¢msvc 2003,linux g++ 4.1 
#   hope it's usefull

PROJECT(GEOS)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/../../source/headers)

set (JTS_PORT 1.7.1)
set (VERSION_MAJOR 3)
set (VERSION_MINOR 0)
set (VERSION_PATCH 0rc1)
set (VERSION 3.0.0rc1)

INCLUDE(CheckSymbolExists)
#CHECK_SYMBOL_EXISTS(int64_t types.h HAVE_INT64_T_64)
IF(MINGW)
	set (HAVE_INT64_T_64 1)
ENDIF(MINGW)
IF(UNIX)
	set (HAVE_INT64_T_64 1)
ENDIF(UNIX)

CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/../../source/headers/geos/version.h.in ${CMAKE_SOURCE_DIR}/../../source/headers/geos/version.h)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/../../source/headers/geos/platform.h.in.cmake ${CMAKE_SOURCE_DIR}/../../source/headers/geos/platform.h ESCAPE_QUOTES)


#ADD_LIBRARY(geos STATIC inlines.cpp)
#ADD_LIBRARY(geos inlines.cpp)
SET(GEOS_SRCS Hello.c File2.c File3.c)
#ADD_LIBRARY(geos SHARED  inlines.cpp
SET(GEOS_SRCS ${CMAKE_SOURCE_DIR}/../../source/inlines.cpp
    ${CMAKE_SOURCE_DIR}/../../source/algorithm/CentroidArea.cpp
	${CMAKE_SOURCE_DIR}/../../source/algorithm/CentroidLine
	${CMAKE_SOURCE_DIR}/../../source/algorithm/CentroidPoint
	${CMAKE_SOURCE_DIR}/../../source/algorithm/CGAlgorithms
	${CMAKE_SOURCE_DIR}/../../source/algorithm/ConvexHull
	${CMAKE_SOURCE_DIR}/../../source/algorithm/HCoordinate
	${CMAKE_SOURCE_DIR}/../../source/algorithm/InteriorPointArea
	${CMAKE_SOURCE_DIR}/../../source/algorithm/InteriorPointLine
	${CMAKE_SOURCE_DIR}/../../source/algorithm/InteriorPointPoint
	${CMAKE_SOURCE_DIR}/../../source/algorithm/LineIntersector
	${CMAKE_SOURCE_DIR}/../../source/algorithm/MCPointInRing
	${CMAKE_SOURCE_DIR}/../../source/algorithm/MinimumDiameter
	${CMAKE_SOURCE_DIR}/../../source/algorithm/NotRepresentableException
	${CMAKE_SOURCE_DIR}/../../source/algorithm/PointLocator
	${CMAKE_SOURCE_DIR}/../../source/algorithm/RobustDeterminant
	${CMAKE_SOURCE_DIR}/../../source/algorithm/SimplePointInAreaLocator
	${CMAKE_SOURCE_DIR}/../../source/algorithm/SimplePointInRing
	${CMAKE_SOURCE_DIR}/../../source/algorithm/SIRtreePointInRing
	${CMAKE_SOURCE_DIR}/../../source/geom/Coordinate
	${CMAKE_SOURCE_DIR}/../../source/geom/CoordinateArraySequence
	${CMAKE_SOURCE_DIR}/../../source/geom/CoordinateArraySequenceFactory
	${CMAKE_SOURCE_DIR}/../../source/geom/CoordinateSequence
#	${CMAKE_SOURCE_DIR}/../../source/geom/CoordinateSequenceFactory
	${CMAKE_SOURCE_DIR}/../../source/geom/Dimension
	${CMAKE_SOURCE_DIR}/../../source/geom/Envelope
	${CMAKE_SOURCE_DIR}/../../source/geom/Geometry
	${CMAKE_SOURCE_DIR}/../../source/geom/GeometryCollection
	${CMAKE_SOURCE_DIR}/../../source/geom/GeometryComponentFilter
	${CMAKE_SOURCE_DIR}/../../source/geom/GeometryFactory
	${CMAKE_SOURCE_DIR}/../../source/geom/IntersectionMatrix
	${CMAKE_SOURCE_DIR}/../../source/geom/LinearRing
	${CMAKE_SOURCE_DIR}/../../source/geom/LineSegment
	${CMAKE_SOURCE_DIR}/../../source/geom/LineString
	${CMAKE_SOURCE_DIR}/../../source/geom/Location
	${CMAKE_SOURCE_DIR}/../../source/geom/MultiLineString
	${CMAKE_SOURCE_DIR}/../../source/geom/MultiPoint
	${CMAKE_SOURCE_DIR}/../../source/geom/MultiPolygon
	${CMAKE_SOURCE_DIR}/../../source/geom/Point
	${CMAKE_SOURCE_DIR}/../../source/geom/Polygon
	${CMAKE_SOURCE_DIR}/../../source/geom/PrecisionModel
	${CMAKE_SOURCE_DIR}/../../source/geom/Triangle
	${CMAKE_SOURCE_DIR}/../../source/geom/util/CoordinateOperation
	${CMAKE_SOURCE_DIR}/../../source/geom/util/GeometryEditor
	${CMAKE_SOURCE_DIR}/../../source/geom/util/GeometryTransformer
#	${CMAKE_SOURCE_DIR}/../../source/geom/util/LinearComponentExtracter
#	${CMAKE_SOURCE_DIR}/../../source/geom/util/PointExtracter
#	${CMAKE_SOURCE_DIR}/../../source/geom/util/PolygonExtracter
	${CMAKE_SOURCE_DIR}/../../source/geom/util/ShortCircuitedGeometryVisitor
	${CMAKE_SOURCE_DIR}/../../source/geomgraph/Depth
	${CMAKE_SOURCE_DIR}/../../source/geomgraph/DirectedEdge
	${CMAKE_SOURCE_DIR}/../../source/geomgraph/DirectedEdgeStar
	${CMAKE_SOURCE_DIR}/../../source/geomgraph/Edge
	${CMAKE_SOURCE_DIR}/../../source/geomgraph/EdgeEnd
	${CMAKE_SOURCE_DIR}/../../source/geomgraph/EdgeEndStar
	${CMAKE_SOURCE_DIR}/../../source/geomgraph/EdgeIntersection
	${CMAKE_SOURCE_DIR}/../../source/geomgraph/EdgeIntersectionList
	${CMAKE_SOURCE_DIR}/../../source/geomgraph/EdgeList
	${CMAKE_SOURCE_DIR}/../../source/geomgraph/EdgeNodingValidator
	${CMAKE_SOURCE_DIR}/../../source/geomgraph/EdgeRing
	${CMAKE_SOURCE_DIR}/../../source/geomgraph/GeometryGraph
	${CMAKE_SOURCE_DIR}/../../source/geomgraph/GraphComponent
	${CMAKE_SOURCE_DIR}/../../source/geomgraph/Label
	${CMAKE_SOURCE_DIR}/../../source/geomgraph/Node
	${CMAKE_SOURCE_DIR}/../../source/geomgraph/NodeFactory
	${CMAKE_SOURCE_DIR}/../../source/geomgraph/NodeMap
	${CMAKE_SOURCE_DIR}/../../source/geomgraph/PlanarGraph
	${CMAKE_SOURCE_DIR}/../../source/geomgraph/Position
	${CMAKE_SOURCE_DIR}/../../source/geomgraph/Quadrant
	${CMAKE_SOURCE_DIR}/../../source/geomgraph/TopologyLocation
	${CMAKE_SOURCE_DIR}/../../source/geomgraph/index/MonotoneChainEdge
	${CMAKE_SOURCE_DIR}/../../source/geomgraph/index/MonotoneChainIndexer
	${CMAKE_SOURCE_DIR}/../../source/geomgraph/index/SegmentIntersector
	${CMAKE_SOURCE_DIR}/../../source/geomgraph/index/SimpleEdgeSetIntersector
	${CMAKE_SOURCE_DIR}/../../source/geomgraph/index/SimpleMCSweepLineIntersector
	${CMAKE_SOURCE_DIR}/../../source/geomgraph/index/SimpleSweepLineIntersector
	${CMAKE_SOURCE_DIR}/../../source/geomgraph/index/SweepLineEvent
	${CMAKE_SOURCE_DIR}/../../source/geomgraph/index/SweepLineSegment
	${CMAKE_SOURCE_DIR}/../../source/index/bintree/Bintree
	${CMAKE_SOURCE_DIR}/../../source/index/bintree/Interval
	${CMAKE_SOURCE_DIR}/../../source/index/bintree/Key
	${CMAKE_SOURCE_DIR}/../../source/index/bintree/Node
	${CMAKE_SOURCE_DIR}/../../source/index/bintree/NodeBase
	${CMAKE_SOURCE_DIR}/../../source/index/bintree/Root
	${CMAKE_SOURCE_DIR}/../../source/index/chain/MonotoneChain
	${CMAKE_SOURCE_DIR}/../../source/index/chain/MonotoneChainBuilder
	${CMAKE_SOURCE_DIR}/../../source/index/chain/MonotoneChainOverlapAction
	${CMAKE_SOURCE_DIR}/../../source/index/chain/MonotoneChainSelectAction
	${CMAKE_SOURCE_DIR}/../../source/index/quadtree/DoubleBits
	${CMAKE_SOURCE_DIR}/../../source/index/quadtree/IntervalSize
	${CMAKE_SOURCE_DIR}/../../source/index/quadtree/Key
	${CMAKE_SOURCE_DIR}/../../source/index/quadtree/Node
	${CMAKE_SOURCE_DIR}/../../source/index/quadtree/NodeBase
	${CMAKE_SOURCE_DIR}/../../source/index/quadtree/Root
	${CMAKE_SOURCE_DIR}/../../source/index/quadtree/Quadtree
	${CMAKE_SOURCE_DIR}/../../source/index/strtree/AbstractNode
	${CMAKE_SOURCE_DIR}/../../source/index/strtree/AbstractSTRtree
	${CMAKE_SOURCE_DIR}/../../source/index/strtree/Interval
	${CMAKE_SOURCE_DIR}/../../source/index/strtree/ItemBoundable
	${CMAKE_SOURCE_DIR}/../../source/index/strtree/SIRtree
	${CMAKE_SOURCE_DIR}/../../source/index/strtree/STRtree
	${CMAKE_SOURCE_DIR}/../../source/index/sweepline/SweepLineEvent
	${CMAKE_SOURCE_DIR}/../../source/index/sweepline/SweepLineIndex
	${CMAKE_SOURCE_DIR}/../../source/index/sweepline/SweepLineInterval
	${CMAKE_SOURCE_DIR}/../../source/io/ByteOrderDataInStream
	${CMAKE_SOURCE_DIR}/../../source/io/ByteOrderValues
	${CMAKE_SOURCE_DIR}/../../source/io/ParseException
	${CMAKE_SOURCE_DIR}/../../source/io/StringTokenizer
	${CMAKE_SOURCE_DIR}/../../source/io/Unload
	${CMAKE_SOURCE_DIR}/../../source/io/WKBReader
	${CMAKE_SOURCE_DIR}/../../source/io/WKBWriter
	${CMAKE_SOURCE_DIR}/../../source/io/WKTReader
	${CMAKE_SOURCE_DIR}/../../source/io/WKTWriter
	${CMAKE_SOURCE_DIR}/../../source/io/Writer
	${CMAKE_SOURCE_DIR}/../../source/noding/IntersectionAdder
	${CMAKE_SOURCE_DIR}/../../source/noding/IntersectionFinderAdder
	${CMAKE_SOURCE_DIR}/../../source/noding/IteratedNoder
	${CMAKE_SOURCE_DIR}/../../source/noding/MCIndexNoder
	${CMAKE_SOURCE_DIR}/../../source/noding/NodingValidator
	${CMAKE_SOURCE_DIR}/../../source/noding/Octant
	${CMAKE_SOURCE_DIR}/../../source/noding/ScaledNoder
	${CMAKE_SOURCE_DIR}/../../source/noding/SegmentNode
	${CMAKE_SOURCE_DIR}/../../source/noding/SegmentNodeList
	${CMAKE_SOURCE_DIR}/../../source/noding/SegmentString
	${CMAKE_SOURCE_DIR}/../../source/noding/SimpleNoder
	${CMAKE_SOURCE_DIR}/../../source/noding/snapround/HotPixel
	${CMAKE_SOURCE_DIR}/../../source/noding/snapround/MCIndexPointSnapper
	${CMAKE_SOURCE_DIR}/../../source/noding/snapround/MCIndexSnapRounder
	${CMAKE_SOURCE_DIR}/../../source/noding/snapround/SimpleSnapRounder
	${CMAKE_SOURCE_DIR}/../../source/operation/buffer/BufferBuilder
	${CMAKE_SOURCE_DIR}/../../source/operation/buffer/BufferOp
	${CMAKE_SOURCE_DIR}/../../source/operation/buffer/BufferSubgraph
	${CMAKE_SOURCE_DIR}/../../source/operation/buffer/OffsetCurveBuilder
	${CMAKE_SOURCE_DIR}/../../source/operation/buffer/OffsetCurveSetBuilder
	${CMAKE_SOURCE_DIR}/../../source/operation/buffer/RightmostEdgeFinder
	${CMAKE_SOURCE_DIR}/../../source/operation/buffer/SubgraphDepthLocater
	${CMAKE_SOURCE_DIR}/../../source/operation/distance/ConnectedElementLocationFilter
	${CMAKE_SOURCE_DIR}/../../source/operation/distance/ConnectedElementPointFilter
	${CMAKE_SOURCE_DIR}/../../source/operation/distance/DistanceOp
	${CMAKE_SOURCE_DIR}/../../source/operation/distance/GeometryLocation
	${CMAKE_SOURCE_DIR}/../../source/operation/GeometryGraphOperation
	${CMAKE_SOURCE_DIR}/../../source/operation/IsSimpleOp
	${CMAKE_SOURCE_DIR}/../../source/operation/linemerge/EdgeString
	${CMAKE_SOURCE_DIR}/../../source/operation/linemerge/LineMergeDirectedEdge
	${CMAKE_SOURCE_DIR}/../../source/operation/linemerge/LineMergeEdge
	${CMAKE_SOURCE_DIR}/../../source/operation/linemerge/LineMergeGraph
	${CMAKE_SOURCE_DIR}/../../source/operation/linemerge/LineMerger
	${CMAKE_SOURCE_DIR}/../../source/operation/linemerge/LineSequencer
	${CMAKE_SOURCE_DIR}/../../source/operation/overlay/EdgeSetNoder
	${CMAKE_SOURCE_DIR}/../../source/operation/overlay/ElevationMatrix
	${CMAKE_SOURCE_DIR}/../../source/operation/overlay/ElevationMatrixCell
	${CMAKE_SOURCE_DIR}/../../source/operation/overlay/LineBuilder
	${CMAKE_SOURCE_DIR}/../../source/operation/overlay/MaximalEdgeRing
	${CMAKE_SOURCE_DIR}/../../source/operation/overlay/MinimalEdgeRing
	${CMAKE_SOURCE_DIR}/../../source/operation/overlay/OverlayNodeFactory
	${CMAKE_SOURCE_DIR}/../../source/operation/overlay/OverlayOp
	${CMAKE_SOURCE_DIR}/../../source/operation/overlay/PointBuilder
	${CMAKE_SOURCE_DIR}/../../source/operation/overlay/PolygonBuilder
	${CMAKE_SOURCE_DIR}/../../source/operation/polygonize/PolygonizeDirectedEdge
	${CMAKE_SOURCE_DIR}/../../source/operation/polygonize/PolygonizeEdge
	${CMAKE_SOURCE_DIR}/../../source/operation/polygonize/EdgeRing
	${CMAKE_SOURCE_DIR}/../../source/operation/polygonize/PolygonizeGraph
	${CMAKE_SOURCE_DIR}/../../source/operation/polygonize/Polygonizer
	${CMAKE_SOURCE_DIR}/../../source/operation/predicate/RectangleContains
	${CMAKE_SOURCE_DIR}/../../source/operation/predicate/RectangleIntersects
	${CMAKE_SOURCE_DIR}/../../source/operation/predicate/SegmentIntersectionTester
	${CMAKE_SOURCE_DIR}/../../source/operation/relate/EdgeEndBuilder
	${CMAKE_SOURCE_DIR}/../../source/operation/relate/EdgeEndBundle
	${CMAKE_SOURCE_DIR}/../../source/operation/relate/EdgeEndBundleStar
	${CMAKE_SOURCE_DIR}/../../source/operation/relate/RelateComputer
	${CMAKE_SOURCE_DIR}/../../source/operation/relate/RelateNode
	${CMAKE_SOURCE_DIR}/../../source/operation/relate/RelateNodeFactory
	${CMAKE_SOURCE_DIR}/../../source/operation/relate/RelateNodeGraph
	${CMAKE_SOURCE_DIR}/../../source/operation/relate/RelateOp
	${CMAKE_SOURCE_DIR}/../../source/operation/valid/ConnectedInteriorTester
	${CMAKE_SOURCE_DIR}/../../source/operation/valid/ConsistentAreaTester
	${CMAKE_SOURCE_DIR}/../../source/operation/valid/IsValidOp
	${CMAKE_SOURCE_DIR}/../../source/operation/valid/QuadtreeNestedRingTester
	${CMAKE_SOURCE_DIR}/../../source/operation/valid/RepeatedPointTester
	${CMAKE_SOURCE_DIR}/../../source/operation/valid/SimpleNestedRingTester
	${CMAKE_SOURCE_DIR}/../../source/operation/valid/SweeplineNestedRingTester
	${CMAKE_SOURCE_DIR}/../../source/operation/valid/TopologyValidationError
	${CMAKE_SOURCE_DIR}/../../source/planargraph/DirectedEdge
	${CMAKE_SOURCE_DIR}/../../source/planargraph/DirectedEdgeStar
	${CMAKE_SOURCE_DIR}/../../source/planargraph/Edge
	${CMAKE_SOURCE_DIR}/../../source/planargraph/Node
	${CMAKE_SOURCE_DIR}/../../source/planargraph/NodeMap
	${CMAKE_SOURCE_DIR}/../../source/planargraph/PlanarGraph
	${CMAKE_SOURCE_DIR}/../../source/planargraph/Subgraph
	${CMAKE_SOURCE_DIR}/../../source/planargraph/algorithm/ConnectedSubgraphFinder
	${CMAKE_SOURCE_DIR}/../../source/precision/CommonBits
	${CMAKE_SOURCE_DIR}/../../source/precision/CommonBitsOp
	${CMAKE_SOURCE_DIR}/../../source/precision/CommonBitsRemover
	${CMAKE_SOURCE_DIR}/../../source/precision/EnhancedPrecisionOp
	${CMAKE_SOURCE_DIR}/../../source/precision/GeometrySnapper
	${CMAKE_SOURCE_DIR}/../../source/precision/LineStringSnapper
	${CMAKE_SOURCE_DIR}/../../source/precision/SimpleGeometryPrecisionReducer
	${CMAKE_SOURCE_DIR}/../../source/simplify/DouglasPeuckerLineSimplifier
	${CMAKE_SOURCE_DIR}/../../source/simplify/DouglasPeuckerSimplifier
	${CMAKE_SOURCE_DIR}/../../source/simplify/LineSegmentIndex
	${CMAKE_SOURCE_DIR}/../../source/simplify/TaggedLineSegment
	${CMAKE_SOURCE_DIR}/../../source/simplify/TaggedLinesSimplifier
	${CMAKE_SOURCE_DIR}/../../source/simplify/TaggedLineString
	${CMAKE_SOURCE_DIR}/../../source/simplify/TaggedLineStringSimplifier
	${CMAKE_SOURCE_DIR}/../../source/simplify/TopologyPreservingSimplifier
	${CMAKE_SOURCE_DIR}/../../source/util/Assert
#	${CMAKE_SOURCE_DIR}/../../source/util/AssertionFailedException
	${CMAKE_SOURCE_DIR}/../../source/util/GeometricShapeFactory
#	${CMAKE_SOURCE_DIR}/../../source/util/IllegalArgumentException
	${CMAKE_SOURCE_DIR}/../../source/util/math
	${CMAKE_SOURCE_DIR}/../../source/util/Profiler
#	${CMAKE_SOURCE_DIR}/../../source/util/UnsupportedOperationException
)

ADD_LIBRARY(geos SHARED ${GEOS_SRCS})
ADD_LIBRARY(geos_i STATIC ${GEOS_SRCS})

ADD_EXECUTABLE(TestSweepLineSpeed
${CMAKE_SOURCE_DIR}/../../tests/bigtest/GeometryTestFactory
${CMAKE_SOURCE_DIR}/../../tests/bigtest/TestSweepLineSpeed)
TARGET_LINK_LIBRARIES(TestSweepLineSpeed geos)


More information about the geos-devel mailing list