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:<div><br></div><div><div># GEOS</div><div>set(GEOS_ENABLE_TESTS off CACHE INTERNAL &quot;&quot;)</div>
<div>add_subdirectory(vendor/osgeo/geos EXCLUDE_FROM_ALL)</div><div><br></div><div><br></div><div>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.</div>
<div><br></div><div>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.</div>
<div><br></div><div><div>diff --git a/CMakeLists.txt b/CMakeLists.txt</div><div>index ec589e7..21a6c50 100644</div><div>--- a/CMakeLists.txt</div><div>+++ b/CMakeLists.txt</div><div>@@ -19,7 +19,7 @@ if(NOT CMAKE_VERSION)</div>
<div> endif()</div><div> </div><div> # Location of custom CMake modules with macros used by GEOS</div><div>-set(CMAKE_MODULE_PATH &quot;${CMAKE_SOURCE_DIR}/cmake/modules&quot;)</div><div>+set(CMAKE_MODULE_PATH &quot;${geos_SOURCE_DIR}/cmake/modules&quot;)</div>
<div> </div><div> #################################################################################</div><div> # Setup GEOS version</div><div><br></div><div><br></div><div>I tried to add this a ticket, but after creating an osgeo ID it isn&#39;t yet recognised by Trac.</div>
<div><br></div><div>Thanks very much,</div><div><br></div><div>Gavin</div></div></div><div><br></div>