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

Gavin Heavyside gavin.heavyside at gmail.com
Sun Feb 21 10:55:36 EST 2010


2010/2/21 Mateusz Loskot <mateusz at loskot.net>

> Gavin Heavyside wrote:
> > 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.
>
> Gavin, interesting idea.
>
> It works well for me, as I build projects on multiple machines with
different architectures, and building dependencies as part of the project
means I can upgrade dependencies or change their configuration in a single
place.  The strategy is the one described in the boost CMake docs:

http://sodium.resophonic.com/boost-cmake/current-docs/exported_targets.html#with-boost-source-in-a-subdirectory-of-your-source


> Applied to trunk, thanks!
>

As I've investigated further, there are a couple more places that need
changing:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 21a6c50..020dc3b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -206,13 +206,13 @@ endif()
 #################################################################################

 # for including GEOS C++ API headers
-include_directories(${CMAKE_SOURCE_DIR}/include)
+include_directories(${geos_SOURCE_DIR}/include)

 # for including build-specific GEOS C API headers
-include_directories(${CMAKE_BINARY_DIR}/capi)
+include_directories(${geos_BINARY_DIR}/capi)

 # for including build-specific version.h, platform.h and geos_c.h
-include_directories(${CMAKE_BINARY_DIR}/include)
+include_directories(${geos_BINARY_DIR}/include)

 #################################################################################
 # Setup checks and generate config headers



With the above patch, and after adding relevant include dirs to my main
CMakeFiles.txt, I can successfully build and link against GEOS from my main
project, with GEOS being built correctly as a dependency.

Thanks,

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


More information about the geos-devel mailing list