1 #################################################################################
3 # GEOS C++ library build configuration for CMake build system
5 # Copyright (C) 2009 Mateusz Loskot <mateusz@loskot.net>
7 # This is free software; you can redistribute and/or modify it under
8 # the terms of the GNU Lesser General Public Licence as published
9 # by the Free Software Foundation.
10 # See the COPYING file for more information.
12 #################################################################################
14 file(GLOB_RECURSE geos_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
15 file(GLOB_RECURSE geos_ALL_HEADERS ${CMAKE_SOURCE_DIR}/include/*.h) # fix source_group issue
17 if(GEOS_ENABLE_MACOSX_FRAMEWORK)
18 # OS X frameworks don't have static libs
19 # also 1 binary, so include CAPI here
20 # and, make name all caps
23 ${CMAKE_CURRENT_SOURCE_DIR}/../capi/geos_c.cpp
24 ${CMAKE_CURRENT_SOURCE_DIR}/../capi/geos_ts_c.cpp)
26 add_library(GEOS SHARED ${geos_SOURCES} ${geos_c_SOURCES})
28 math(EXPR CVERSION "${VERSION_MAJOR} + 1")
29 # VERSION = current version, SOVERSION = compatibility version
30 set_target_properties(GEOS
34 VERSION "${CVERSION}.${VERSION_MINOR}.${VERSION_PATCH}"
36 FRAMEWORK_VERSION ${VERSION_MAJOR}
37 BUILD_WITH_INSTALL_RPATH TRUE
38 INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}"
39 MACOSX_FRAMEWORK_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in"
40 MACOSX_FRAMEWORK_BUNDLE_VERSION "GEOS ${VERSION}"
41 MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${VERSION}
42 MACOSX_FRAMEWORK_IDENTIFIER org.osgeo.geos)
44 install(TARGETS GEOS FRAMEWORK DESTINATION .)
46 if(GEOS_ENABLE_MACOSX_FRAMEWORK_UNIXCOMPAT)
47 # Unix compatibility option, provides typical bin/lib/include folder
48 # structure for framework-challenged projects
50 set(GEOS_FWDIR "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/GEOS.framework")
51 set(GEOS_FWDIR_VER "${GEOS_FWDIR}/Versions/${VERSION_MAJOR}")
52 install(CODE "execute_process(COMMAND mkdir -p \"${GEOS_FWDIR_VER}/unix/bin\")")
53 install(CODE "execute_process(COMMAND mkdir -p \"${GEOS_FWDIR_VER}/unix/include\")")
54 install(CODE "execute_process(COMMAND mkdir -p \"${GEOS_FWDIR_VER}/unix/lib\")")
55 install(CODE "execute_process(COMMAND ln -sfh ../../Headers \"${GEOS_FWDIR_VER}/unix/include/geos\")")
56 install(CODE "execute_process(COMMAND ln -sf ../../Headers/geos_c.h \"${GEOS_FWDIR_VER}/unix/include/geos_c.h\")")
57 install(CODE "execute_process(COMMAND ln -sf ../../GEOS \"${GEOS_FWDIR_VER}/unix/lib/libgeos.dylib\")")
58 install(CODE "execute_process(COMMAND ln -sf ../../GEOS \"${GEOS_FWDIR_VER}/unix/lib/libgeos_c.dylib\")")
59 install(CODE "execute_process(COMMAND ln -sfh Versions/Current/unix \"${GEOS_FWDIR}/unix\")")
64 add_library(geos SHARED ${geos_SOURCES} ${geos_ALL_HEADERS})
65 add_library(geos-static STATIC ${geos_SOURCES} ${geos_ALL_HEADERS})
67 set_target_properties(geos
69 DEFINE_SYMBOL GEOS_DLL_EXPORT
71 CLEAN_DIRECT_OUTPUT 1)
73 set_target_properties(geos-static
77 CLEAN_DIRECT_OUTPUT 1)
82 # set_target_properties(geos
84 # BUILD_WITH_INSTALL_RPATH TRUE
85 # INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}")
88 #################################################################################
90 #################################################################################
92 if(NOT GEOS_ENABLE_MACOSX_FRAMEWORK)
93 install(TARGETS geos geos-static
94 RUNTIME DESTINATION bin
95 LIBRARY DESTINATION lib
96 ARCHIVE DESTINATION lib)
99 #################################################################################
100 # Group source files for IDE source explorers (e.g. Visual Studio)
101 #################################################################################
103 file(GLOB top_HEADERS ${CMAKE_SOURCE_DIR}/include/*.h)
104 source_group("Header Files" FILES ${top_HEADERS})
105 file(GLOB geos_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/*.h)
106 source_group("Header Files\\geos" FILES ${geos_HEADERS})
108 file(GLOB geos_algorithm_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/algorithm/*.h)
109 source_group("Header Files\\geos\\algorithm" FILES ${geos_algorithm_HEADERS})
110 file(GLOB geos_algorithm_distance_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/algorithm/distance/*.h)
111 source_group("Header Files\\geos\\algorithm\\distance" FILES ${geos_algorithm_distance_HEADERS})
112 file(GLOB geos_algorithm_locate_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/algorithm/locate/*.h)
113 source_group("Header Files\\geos\\algorithm\\locate" FILES ${geos_algorithm_locate_HEADERS})
115 file(GLOB geos_geom_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/geom/*.h)
116 source_group("Header Files\\geos\\geom" FILES ${geos_geom_HEADERS})
117 file(GLOB geos_geom_prep_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/geom/prep/*.h)
118 source_group("Header Files\\geos\\geom\\prep" FILES ${geos_geom_prep_HEADERS})
119 file(GLOB geos_geom_util_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/geom/util/*.h)
120 source_group("Header Files\\geos\\geom\\util" FILES ${geos_geom_util_HEADERS})
122 file(GLOB geos_geomgraph_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/geomgraph/*.h)
123 source_group("Header Files\\geos\\geomgraph" FILES ${geos_geomgraph_HEADERS})
124 file(GLOB geos_geomgraph_index_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/geomgraph/index/*.h)
125 source_group("Header Files\\geos\\geomgraph\\index" FILES ${geos_geomgraph_index_HEADERS})
127 file(GLOB geos_index_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/index/*.h)
128 source_group("Header Files\\geos\\index" FILES ${geos_index_HEADERS})
129 file(GLOB geos_index_bintree_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/index/bintree/*.h)
130 source_group("Header Files\\geos\\index\\bintree" FILES ${geos_index_bintree_HEADERS})
131 file(GLOB geos_index_chain_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/index/chain/*.h)
132 source_group("Header Files\\geos\\index\\chain" FILES ${geos_index_chain_HEADERS})
133 file(GLOB geos_index_intervalrtree_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/index/intervalrtree/*.h)
134 source_group("Header Files\\geos\\index\\intervalrtree" FILES ${geos_index_intervalrtree_HEADERS})
135 file(GLOB geos_index_quadtree_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/index/quadtree/*.h)
136 source_group("Header Files\\geos\\index\\quadtree" FILES ${geos_index_quadtree_HEADERS})
137 file(GLOB geos_index_strtree_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/index/strtree/*.h)
138 source_group("Header Files\\geos\\index\\strtree" FILES ${geos_index_strtree_HEADERS})
139 file(GLOB geos_index_sweepline_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/index/sweepline/*.h)
140 source_group("Header Files\\geos\\index\\sweepline" FILES ${geos_index_sweepline_HEADERS})
142 file(GLOB geos_io_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/io/*.h)
143 source_group("Header Files\\geos\\io" FILES ${geos_io_HEADERS})
145 file(GLOB geos_linearref_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/linearref/*.h)
146 source_group("Header Files\\geos\\linearref" FILES ${geos_linearref_HEADERS})
148 file(GLOB geos_noding_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/noding/*.h)
149 source_group("Header Files\\geos\\noding" FILES ${geos_noding_HEADERS})
150 file(GLOB geos_noding_snapround_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/noding/snapround/*.h)
151 source_group("Header Files\\geos\\noding\\snapround" FILES ${geos_noding_snapround_HEADERS})
153 file(GLOB geos_operation_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/operation/*.h)
154 source_group("Header Files\\geos\\operation" FILES ${geos_operation_HEADERS})
155 file(GLOB geos_operation_buffer_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/operation/buffer/*.h)
156 source_group("Header Files\\geos\\operation\\buffer" FILES ${geos_operation_buffer_HEADERS})
157 file(GLOB geos_operation_distance_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/operation/distance/*.h)
158 source_group("Header Files\\geos\\operation\\distance" FILES ${geos_operation_distance_HEADERS})
159 file(GLOB geos_operation_linemerge_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/operation/linemerge/*.h)
160 source_group("Header Files\\geos\\operation\\linemerge" FILES ${geos_operation_linemerge_HEADERS})
161 file(GLOB geos_operation_overlay_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/operation/overlay/*.h)
162 source_group("Header Files\\geos\\operation\\overlay" FILES ${geos_operation_overlay_HEADERS})
163 file(GLOB geos_operation_overlay_snap_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/operation/overlay/snap/*.h)
164 source_group("Header Files\\geos\\operation\\overlay\\snap" FILES ${geos_operation_overlay_snap_HEADERS})
165 file(GLOB geos_operation_overlay_validate_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/operation/overlay/validate/*.h)
166 source_group("Header Files\\geos\\operation\\overlay\\validate" FILES ${geos_operation_overlay_validate_HEADERS})
167 file(GLOB geos_operation_polygonize_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/operation/polygonize/*.h)
168 source_group("Header Files\\geos\\operation\\polygonize" FILES ${geos_operation_polygonize_HEADERS})
169 file(GLOB geos_operation_predicate_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/operation/predicate/*.h)
170 source_group("Header Files\\geos\\operation\\predicate" FILES ${geos_operation_predicate_HEADERS})
171 file(GLOB geos_operation_relate_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/operation/relate/*.h)
172 source_group("Header Files\\geos\\operation\\relate" FILES ${geos_operation_relate_HEADERS})
173 file(GLOB geos_operation_sharedpaths_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/operation/sharedpaths/*.h)
174 source_group("Header Files\\geos\\operation\\sharedpaths" FILES ${geos_operation_sharedpaths_HEADERS})
175 file(GLOB geos_operation_union_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/operation/union/*.h)
176 source_group("Header Files\\geos\\operation\\union" FILES ${geos_operation_union_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_valid_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/operation/valid/*.h)
180 source_group("Header Files\\geos\\operation\\valid" FILES ${geos_operation_valid_HEADERS})
182 file(GLOB geos_planargraph_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/planargraph/*.h)
183 source_group("Header Files\\geos\\planargraph" FILES ${geos_planargraph_HEADERS})
184 file(GLOB geos_planargraph_algorithm_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/planargraph/algorithm/*.h)
185 source_group("Header Files\\geos\\planargraph\\algorithm" FILES ${geos_planargraph_algorithm_HEADERS})
187 file(GLOB geos_precision_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/precision/*.h)
188 source_group("Header Files\\geos\\precision" FILES ${geos_precision_HEADERS})
190 file(GLOB geos_simplify_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/simplify/*.h)
191 source_group("Header Files\\geos\\simplify" FILES ${geos_simplify_HEADERS})
193 file(GLOB geos_util_HEADERS ${CMAKE_SOURCE_DIR}/include/geos/util/*.h)
194 source_group("Header Files\\geos\\util" FILES ${geos_util_HEADERS})