# HG changeset patch
# User Alpar Juttner <alpar@cs.elte.hu>
# Date 1290790771 -3600
# Node ID 723af8fef5295490e64b5512e115961ef3a98d4b
# Parent  6de89926e5944a73b398561c344aa30585d09dee
Configurable LEMON source dir location (when used as a subproject)

diff -r 6de89926e594 -r 723af8fef529 CMakeLists.txt
--- a/CMakeLists.txt	Wed Jun 24 11:22:23 2009 +0100
+++ b/CMakeLists.txt	Fri Nov 26 17:59:31 2010 +0100
@@ -19,21 +19,31 @@
 
 ## The next part looks for LEMON. Typically, you don't want to modify it.
 ##
-## First, it checks if there exists a 'lemon' subdirectory which should contain
-## the LEMON source tree. If it is there, then it will compile it locally and
-## use it as a subproject. If it isn't, then CMAKE will try to find an
-## installed version of LEMON. If it is installed to some non-standard place,
-## then you must tell its location to 'cmake-gui' in the LEMON_ROOT_DIR
-## config variable. (Do not hard code it into your config! Others may keep
+## First, it tries to use LEMON as a CMAKE subproject by looking for
+## it in the 'lemon' or 'deps/lemon' subdirectories or in directory
+## given by the LEMON_SOURCE_ROOT_DIR variable.
+## If LEMON isn't there, then CMAKE will try to find an installed
+## version of LEMON. If it is installed at some non-standard place,
+## then you must tell its location in the LEMON_ROOT_DIR CMAKE config
+## variable. (Do not hard code it into your config! Others may keep
 ## LEMON at different places.)
 
-IF(EXISTS ${CMAKE_SOURCE_DIR}/lemon)
-  ADD_SUBDIRECTORY(lemon)
+FIND_PATH(LEMON_SOURCE_ROOT_DIR CMakeLists.txt
+  PATHS ${CMAKE_SOURCE_DIR}/lemon ${CMAKE_SOURCE_DIR}/deps/lemon
+  NO_DEFAULT_PATH
+  DOC "Location of LEMON source as a CMAKE subproject")
+
+IF(EXISTS ${LEMON_SOURCE_ROOT_DIR})
+  ADD_SUBDIRECTORY(${LEMON_SOURCE_ROOT_DIR} deps/lemon)
   SET(LEMON_INCLUDE_DIRS
-    ${CMAKE_SOURCE_DIR}/lemon
-    ${CMAKE_BINARY_DIR}/lemon
+    ${LEMON_SOURCE_ROOT_DIR}
+    ${CMAKE_BINARY_DIR}/deps/lemon
   )
   SET(LEMON_LIBRARIES lemon)
+  UNSET(LEMON_ROOT_DIR CACHE)
+  UNSET(LEMON_DIR CACHE)
+  UNSET(LEMON_INCLUDE_DIR CACHE)
+  UNSET(LEMON_LIBRARY CACHE)
 ELSE()
   FIND_PACKAGE(LEMON QUIET NO_MODULE)
   FIND_PACKAGE(LEMON REQUIRED)