[geos-devel] CMake, with GEOS as a dependency of a project

Gavin Heavyside gavin.heavyside at gmail.com
Sun Feb 21 08:52:31 EST 2010


I like to build dependencies of my projects as subprojects using CMake.  To
do this for GEOS I do the following from my main project CMakeLists.txt:

# GEOS
set(GEOS_ENABLE_TESTS off CACHE INTERNAL "")
add_subdirectory(vendor/osgeo/geos EXCLUDE_FROM_ALL)


This means that GEOS will be built whenever a binary from my main project
specifies GEOS as a dependency.  I use this technique successfully with
boost, googlemock and others.

For this to work properly, the subproject CMake configuration must not
assume that its directory is also the global project root.  The following
patch makes building as a subproject work correctly, and to the best of my
knowledge does not alter the behaviour when building GEOS in isolation.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index ec589e7..21a6c50 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -19,7 +19,7 @@ if(NOT CMAKE_VERSION)
 endif()

 # Location of custom CMake modules with macros used by GEOS
-set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")
+set(CMAKE_MODULE_PATH "${geos_SOURCE_DIR}/cmake/modules")

 #################################################################################
 # Setup GEOS version


I tried to add this a ticket, but after creating an osgeo ID it isn't yet
recognised by Trac.

Thanks very much,

Gavin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/geos-devel/attachments/20100221/a7232c4d/attachment.html


More information about the geos-devel mailing list