Add test for bug #448
[geos.git] / src / CMakeLists.txt
blob841fb92cedc8f4458a7798ffc07253e06516915d
1 #################################################################################
2 # $Id$
4 # GEOS C++ library build configuration for CMake build system
6 # Copyright (C) 2009 Mateusz Loskot <mateusz@loskot.net>
8 # This is free software; you can redistribute and/or modify it under
9 # the terms of the GNU Lesser General Public Licence as published
10 # by the Free Software Foundation. 
11 # See the COPYING file for more information.
13 #################################################################################
15 file(GLOB_RECURSE geos_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
16 file(GLOB_RECURSE geos_ALL_HEADERS ${CMAKE_SOURCE_DIR}/include/*.h) # fix source_group issue
18 if(APPLE AND GEOS_ENABLE_MACOSX_FRAMEWORK)
19   # OS X frameworks don't have static libs
20   # also 1 binary, so include CAPI here
21   # and, make name all caps
23   set(geos_c_SOURCES
24     ${CMAKE_CURRENT_SOURCE_DIR}/../capi/geos_c.cpp
25     ${CMAKE_CURRENT_SOURCE_DIR}/../capi/geos_ts_c.cpp)
27   add_library(GEOS SHARED ${geos_SOURCES} ${geos_c_SOURCES})
29   math(EXPR CVERSION "${VERSION_MAJOR} + 1") 
30         # VERSION = current version, SOVERSION = compatibility version 
31   set_target_properties(GEOS
32     PROPERTIES
33     CLEAN_DIRECT_OUTPUT 1
34     FRAMEWORK 1
35     VERSION "${CVERSION}.${VERSION_MINOR}.${VERSION_PATCH}" 
36           SOVERSION ${CVERSION} 
37     FRAMEWORK_VERSION ${VERSION_MAJOR}
38     BUILD_WITH_INSTALL_RPATH TRUE
39     INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}"
40     MACOSX_FRAMEWORK_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in"
41     MACOSX_FRAMEWORK_BUNDLE_VERSION "GEOS ${VERSION}"
42     MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${VERSION}
43     MACOSX_FRAMEWORK_IDENTIFIER org.osgeo.geos)
45   install(TARGETS GEOS FRAMEWORK DESTINATION .)
47   if(GEOS_ENABLE_MACOSX_FRAMEWORK_UNIXCOMPAT)
48     # Unix compatibility option, provides typical bin/lib/include folder
49     # structure for framework-challenged projects
51     set(GEOS_FWDIR "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/GEOS.framework")
52     set(GEOS_FWDIR_VER "${GEOS_FWDIR}/Versions/${VERSION_MAJOR}")
53     install(CODE "execute_process(COMMAND mkdir -p \"${GEOS_FWDIR_VER}/unix/bin\")")
54     install(CODE "execute_process(COMMAND mkdir -p \"${GEOS_FWDIR_VER}/unix/include\")")
55     install(CODE "execute_process(COMMAND mkdir -p \"${GEOS_FWDIR_VER}/unix/lib\")")
56     install(CODE "execute_process(COMMAND ln -sfh ../../Headers \"${GEOS_FWDIR_VER}/unix/include/geos\")")
57     install(CODE "execute_process(COMMAND ln -sf ../../Headers/geos_c.h \"${GEOS_FWDIR_VER}/unix/include/geos_c.h\")")
58     install(CODE "execute_process(COMMAND ln -sf ../../GEOS \"${GEOS_FWDIR_VER}/unix/lib/libgeos.dylib\")")
59     install(CODE "execute_process(COMMAND ln -sf ../../GEOS \"${GEOS_FWDIR_VER}/unix/lib/libgeos_c.dylib\")")
60     install(CODE "execute_process(COMMAND ln -sfh Versions/Current/unix \"${GEOS_FWDIR}/unix\")")
61   endif()
63 else()
65   add_library(geos SHARED ${geos_SOURCES} ${geos_ALL_HEADERS})
66   add_library(geos-static STATIC ${geos_SOURCES} ${geos_ALL_HEADERS})
68 # TODO: Enable SOVERSION property
69   set_target_properties(geos
70     PROPERTIES
71     DEFINE_SYMBOL GEOS_DLL_EXPORT
72     VERSION ${VERSION}
73     CLEAN_DIRECT_OUTPUT 1)
75   set_target_properties(geos-static
76     PROPERTIES
77     OUTPUT_NAME "geos"
78     PREFIX "lib"
79     CLEAN_DIRECT_OUTPUT 1)
81 endif()
83 if(APPLE)
84   set_target_properties(geos
85     PROPERTIES
86     BUILD_WITH_INSTALL_RPATH TRUE
87     INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}")
88 endif()
90 #################################################################################
91 # Installation
92 #################################################################################
94 if(NOT APPLE AND NOT GEOS_ENABLE_MACOSX_FRAMEWORK)
95   install(TARGETS geos geos-static
96     RUNTIME DESTINATION bin
97     LIBRARY DESTINATION lib
98     ARCHIVE DESTINATION lib)
99 endif()
101 #################################################################################
102 # Group source files for IDE source explorers (e.g. Visual Studio)
103 #################################################################################
105 file(GLOB top_HEADERS ${CMAKE_SOURCE_DIR}/include/*.h)
106 source_group("Header Files" FILES ${top_HEADERS})
107 file(GLOB geos_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/*.h)
108 source_group("Header Files\\geos" FILES ${geos_HEADERS})
109 ### geos/algorithm
110 file(GLOB geos_algorithm_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/algorithm/*.h)
111 source_group("Header Files\\geos\\algorithm" FILES ${geos_algorithm_HEADERS})
112 file(GLOB geos_algorithm_distance_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/algorithm/distance/*.h)
113 source_group("Header Files\\geos\\algorithm\\distance" FILES ${geos_algorithm_distance_HEADERS})
114 file(GLOB geos_algorithm_locate_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/algorithm/locate/*.h)
115 source_group("Header Files\\geos\\algorithm\\locate" FILES ${geos_algorithm_locate_HEADERS})
116 ### geos/geom
117 file(GLOB geos_geom_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/geom/*.h)
118 source_group("Header Files\\geos\\geom" FILES ${geos_geom_HEADERS})
119 file(GLOB geos_geom_prep_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/geom/prep/*.h)
120 source_group("Header Files\\geos\\geom\\prep" FILES ${geos_geom_prep_HEADERS})
121 file(GLOB geos_geom_util_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/geom/util/*.h)
122 source_group("Header Files\\geos\\geom\\util" FILES ${geos_geom_util_HEADERS})
123 ### geos/geomgraph
124 file(GLOB geos_geomgraph_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/geomgraph/*.h)
125 source_group("Header Files\\geos\\geomgraph" FILES ${geos_geomgraph_HEADERS})
126 file(GLOB geos_geomgraph_index_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/geomgraph/index/*.h)
127 source_group("Header Files\\geos\\geomgraph\\index" FILES ${geos_geomgraph_index_HEADERS})
128 ### geos/index
129 file(GLOB geos_index_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/index/*.h)
130 source_group("Header Files\\geos\\index" FILES ${geos_index_HEADERS})
131 file(GLOB geos_index_bintree_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/index/bintree/*.h)
132 source_group("Header Files\\geos\\index\\bintree" FILES ${geos_index_bintree_HEADERS})
133 file(GLOB geos_index_chain_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/index/chain/*.h)
134 source_group("Header Files\\geos\\index\\chain" FILES ${geos_index_chain_HEADERS})
135 file(GLOB geos_index_intervalrtree_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/index/intervalrtree/*.h)
136 source_group("Header Files\\geos\\index\\intervalrtree" FILES ${geos_index_intervalrtree_HEADERS})
137 file(GLOB geos_index_quadtree_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/index/quadtree/*.h)
138 source_group("Header Files\\geos\\index\\quadtree" FILES ${geos_index_quadtree_HEADERS})
139 file(GLOB geos_index_strtree_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/index/strtree/*.h)
140 source_group("Header Files\\geos\\index\\strtree" FILES ${geos_index_strtree_HEADERS})
141 file(GLOB geos_index_sweepline_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/index/sweepline/*.h)
142 source_group("Header Files\\geos\\index\\sweepline" FILES ${geos_index_sweepline_HEADERS})
143 ### geos/io
144 file(GLOB geos_io_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/io/*.h)
145 source_group("Header Files\\geos\\io" FILES ${geos_io_HEADERS})
146 ### geos/linearref
147 file(GLOB geos_linearref_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/linearref/*.h)
148 source_group("Header Files\\geos\\linearref" FILES ${geos_linearref_HEADERS})
149 ### geos/noding
150 file(GLOB geos_noding_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/noding/*.h)
151 source_group("Header Files\\geos\\noding" FILES ${geos_noding_HEADERS})
152 file(GLOB geos_noding_snapround_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/noding/snapround/*.h)
153 source_group("Header Files\\geos\\noding\\snapround" FILES ${geos_noding_snapround_HEADERS})
154 ### geos/operation 
155 file(GLOB geos_operation_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/operation/*.h)
156 source_group("Header Files\\geos\\operation" FILES ${geos_operation_HEADERS})
157 file(GLOB geos_operation_buffer_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/operation/buffer/*.h)
158 source_group("Header Files\\geos\\operation\\buffer" FILES ${geos_operation_buffer_HEADERS})
159 file(GLOB geos_operation_distance_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/operation/distance/*.h)
160 source_group("Header Files\\geos\\operation\\distance" FILES ${geos_operation_distance_HEADERS})
161 file(GLOB geos_operation_linemerge_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/operation/linemerge/*.h)
162 source_group("Header Files\\geos\\operation\\linemerge" FILES ${geos_operation_linemerge_HEADERS})
163 file(GLOB geos_operation_overlay_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/operation/overlay/*.h)
164 source_group("Header Files\\geos\\operation\\overlay" FILES ${geos_operation_overlay_HEADERS})
165 file(GLOB geos_operation_overlay_snap_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/operation/overlay/snap/*.h)
166 source_group("Header Files\\geos\\operation\\overlay\\snap" FILES ${geos_operation_overlay_snap_HEADERS})
167 file(GLOB geos_operation_overlay_validate_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/operation/overlay/validate/*.h)
168 source_group("Header Files\\geos\\operation\\overlay\\validate" FILES ${geos_operation_overlay_validate_HEADERS})
169 file(GLOB geos_operation_polygonize_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/operation/polygonize/*.h)
170 source_group("Header Files\\geos\\operation\\polygonize" FILES ${geos_operation_polygonize_HEADERS})
171 file(GLOB geos_operation_predicate_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/operation/predicate/*.h)
172 source_group("Header Files\\geos\\operation\\predicate" FILES ${geos_operation_predicate_HEADERS})
173 file(GLOB geos_operation_relate_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/operation/relate/*.h)
174 source_group("Header Files\\geos\\operation\\relate" FILES ${geos_operation_relate_HEADERS})
175 file(GLOB geos_operation_sharedpaths_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/operation/sharedpaths/*.h)
176 source_group("Header Files\\geos\\operation\\sharedpaths" FILES ${geos_operation_sharedpaths_HEADERS})
177 file(GLOB geos_operation_union_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/operation/union/*.h)
178 source_group("Header Files\\geos\\operation\\union" FILES ${geos_operation_union_HEADERS})
179 file(GLOB geos_operation_union_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/operation/union/*.h)
180 source_group("Header Files\\geos\\operation\\union" FILES ${geos_operation_union_HEADERS})
181 file(GLOB geos_operation_valid_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/operation/valid/*.h)
182 source_group("Header Files\\geos\\operation\\valid" FILES ${geos_operation_valid_HEADERS})
183 ### geos/planargraph
184 file(GLOB geos_planargraph_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/planargraph/*.h)
185 source_group("Header Files\\geos\\planargraph" FILES ${geos_planargraph_HEADERS})
186 file(GLOB geos_planargraph_algorithm_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/planargraph/algorithm/*.h)
187 source_group("Header Files\\geos\\planargraph\\algorithm" FILES ${geos_planargraph_algorithm_HEADERS})
188 ### geso/precision
189 file(GLOB geos_precision_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/precision/*.h)
190 source_group("Header Files\\geos\\precision" FILES ${geos_precision_HEADERS})
191 ### geso/simplify
192 file(GLOB geos_simplify_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/simplify/*.h)
193 source_group("Header Files\\geos\\simplify" FILES ${geos_simplify_HEADERS})
194 ### geso/util
195 file(GLOB geos_util_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/util/*.h)
196 source_group("Header Files\\geos\\util" FILES ${geos_util_HEADERS})