[Qgis-developer] Link issues on mac

Tom Elwertowski telwertowski at comcast.net
Thu Apr 3 15:39:47 EDT 2008


Hi Tim and William,

I found the source of the FindGEOS.cmake and FindProj.cmake Mac problem. The addition of the NO_DEFAULT_PATH flag to FIND_* made the files framework-unfriendly.

The geos.h header is also missing from the GEOS framework. The file is not used by qgis but FindGEOS.cmake references it to locate GEOS. I have changed the cmake search reference to geos_c.h which is present (and also not used by qgis).

NO_DEFAULT_PATH was added to force searching of specified paths before default paths. /usr/lib paths but not /Library/Frameworks were then explicitly added.

The Cmake documentation recommends calling FIND twice to achieve the same effect. First with only nonstandard paths and the NO_DEFAULT_PATH flag. Then again with no specified paths to search the default locations. When an earlier FIND succeeds, later FINDs for the same item do nothing.

The multiple FIND method avoids the need to list standard paths (and perhaps forget about frameworks). It is also compatible with the CMAKE_FIND_FRAMEWORK setting which might be LAST, ONLY or NEVER rather then the default FIRST. (Hardcoding the all path permutations would look awful.)

Since the default paths were inserted into the middle of the nonstandard paths, apparently for mingw and perhaps msvc too, I have attached the Mac fix as a patch to be verified and perhaps adjusted for those systems before being submitted to svn. Perhaps a third FIND is needed if the defaults really need to be in the middle of the list.

Tom


Tom Elwertowski wrote:
> When I run cmake, I get the following message:
> 
> CMake Error: This project requires some variables to be set,
> and cmake can not find them.
> Please set the following variables:
> GEOS_INCLUDE_DIR
> GEOS_LIBRARY
> PROJ_INCLUDE_DIR
> PROJ_LIBRARY
-------------- next part --------------
Index: cmake/FindExpat.cmake
===================================================================
--- cmake/FindExpat.cmake	(revision 8315)
+++ cmake/FindExpat.cmake	(working copy)
@@ -7,29 +7,26 @@
 #    EXPAT_INCLUDE_DIR
 #    EXPAT_LIBRARY
 
-# Normally there is no need to specify /usr/... paths because 
-# cmake will look there automatically. However the NO_DEFAULT_PATH
-# prevents this behaviour allowing you to use no standard file
-# locations in preference over standard ones. Note in this case
-# you then need to explicitly add /usr and /usr/local prefixes
-# to the search list. This applies both to FIND_PATH and FIND_LIBRARY
-FIND_PATH(EXPAT_INCLUDE_DIR expat.h 
+# FIND_PATH and FIND_LIBRARY normally search standard locations
+# before the specified paths. To search non-standard paths first,
+# FIND_* is invoked first with specified paths and NO_DEFAULT_PATH
+# and then again with no specified paths to search the default
+# locations. When an earlier FIND_* succeeds, subsequent FIND_*s
+# searching for the same item do nothing. 
+FIND_PATH(EXPAT_INCLUDE_DIR expat.h
   "$ENV{LIB_DIR}/include/"
   "$ENV{LIB_DIR}/include/expat"
-  /Users/tim/dev/universal_libs/include
-  /usr/local/include 
-  /usr/include 
   c:/msys/local/include
   NO_DEFAULT_PATH
   )
+FIND_PATH(EXPAT_INCLUDE_DIR expat.h)
 #libexpat needed for msvc version
 FIND_LIBRARY(EXPAT_LIBRARY NAMES expat libexpat PATHS 
   "$ENV{LIB_DIR}/lib"
-  /usr/local/lib 
-  /usr/lib 
   c:/msys/local/lib
   NO_DEFAULT_PATH
   )
+FIND_LIBRARY(EXPAT_LIBRARY NAMES expat libexpat)
 
 IF (EXPAT_INCLUDE_DIR AND EXPAT_LIBRARY)
    SET(EXPAT_FOUND TRUE)
Index: cmake/FindSqlite3.cmake
===================================================================
--- cmake/FindSqlite3.cmake	(revision 8315)
+++ cmake/FindSqlite3.cmake	(working copy)
@@ -7,29 +7,28 @@
 #    SQLITE3_LIBRARY
 
 
-# Normally there is no need to specify /usr/... paths because 
-# cmake will look there automatically. However the NO_DEFAULT_PATH
-# prevents this behaviour allowing you to use no standard file
-# locations in preference over standard ones. Note in this case
-# you then need to explicitly add /usr and /usr/local prefixes
-# to the search list. This applies both to FIND_PATH and FIND_LIBRARY
-FIND_PATH(SQLITE3_INCLUDE_DIR sqlite3.h 
+# FIND_PATH and FIND_LIBRARY normally search standard locations
+# before the specified paths. To search non-standard paths first,
+# FIND_* is invoked first with specified paths and NO_DEFAULT_PATH
+# and then again with no specified paths to search the default
+# locations. When an earlier FIND_* succeeds, subsequent FIND_*s
+# searching for the same item do nothing. 
+FIND_PATH(SQLITE3_INCLUDE_DIR sqlite3.h
   "$ENV{LIB_DIR}/include"
   "$ENV{LIB_DIR}/include/sqlite"
-  /usr/local/include 
-  /usr/include 
   #mingw
   c:/msys/local/include
   NO_DEFAULT_PATH
   )
+FIND_PATH(SQLITE3_INCLUDE_DIR sqlite3.h)
 
-FIND_LIBRARY(SQLITE3_LIBRARY NAMES sqlite3 PATHS 
+FIND_LIBRARY(SQLITE3_LIBRARY NAMES sqlite3 PATHS
   "$ENV{LIB_DIR}/lib"
-  /usr/local/lib 
-  /usr/lib 
+  #mingw
   c:/msys/local/lib
   NO_DEFAULT_PATH
   )
+FIND_LIBRARY(SQLITE3_LIBRARY NAMES sqlite3)
 
 IF (SQLITE3_INCLUDE_DIR AND SQLITE3_LIBRARY)
    SET(SQLITE3_FOUND TRUE)
Index: cmake/FindProj.cmake
===================================================================
--- cmake/FindProj.cmake	(revision 8315)
+++ cmake/FindProj.cmake	(working copy)
@@ -7,29 +7,28 @@
 #    PROJ_LIBRARY
 
 
-# Normally there is no need to specify /usr/... paths because 
-# cmake will look there automatically. However the NO_DEFAULT_PATH
-# prevents this behaviour allowing you to use no standard file
-# locations in preference over standard ones. Note in this case
-# you then need to explicitly add /usr and /usr/local prefixes
-# to the search list. This applies both to FIND_PATH and FIND_LIBRARY
-FIND_PATH(PROJ_INCLUDE_DIR proj_api.h 
+# FIND_PATH and FIND_LIBRARY normally search standard locations
+# before the specified paths. To search non-standard paths first,
+# FIND_* is invoked first with specified paths and NO_DEFAULT_PATH
+# and then again with no specified paths to search the default
+# locations. When an earlier FIND_* succeeds, subsequent FIND_*s
+# searching for the same item do nothing. 
+FIND_PATH(PROJ_INCLUDE_DIR proj_api.h
   "$ENV{LIB_DIR}/include/proj"
   "$ENV{LIB_DIR}/include"
-  /usr/local/include 
-  /usr/include 
   #mingw
   c:/msys/local/include
   NO_DEFAULT_PATH
   )
+FIND_PATH(PROJ_INCLUDE_DIR proj_api.h)
 
-FIND_LIBRARY(PROJ_LIBRARY NAMES proj PATHS 
+FIND_LIBRARY(PROJ_LIBRARY NAMES proj PATHS
   "$ENV{LIB_DIR}/lib"
-  /usr/local/lib 
-  /usr/lib 
+  #mingw
   c:/msys/local/lib
   NO_DEFAULT_PATH
   )
+FIND_LIBRARY(PROJ_LIBRARY NAMES proj)
 
 IF (PROJ_INCLUDE_DIR AND PROJ_LIBRARY)
    SET(PROJ_FOUND TRUE)
Index: cmake/FindGEOS.cmake
===================================================================
--- cmake/FindGEOS.cmake	(revision 8315)
+++ cmake/FindGEOS.cmake	(working copy)
@@ -7,29 +7,27 @@
 #    GEOS_LIBRARY
 
 
-# Normally there is no need to specify /usr/... paths because 
-# cmake will look there automatically. However the NO_DEFAULT_PATH
-# prevents this behaviour allowing you to use no standard file
-# locations in preference over standard ones. Note in this case
-# you then need to explicitly add /usr and /usr/local prefixes
-# to the search list. This applies both to FIND_PATH and FIND_LIBRARY
-FIND_PATH(GEOS_INCLUDE_DIR geos.h 
+# FIND_PATH and FIND_LIBRARY normally search standard locations
+# before the specified paths. To search non-standard paths first,
+# FIND_* is invoked first with specified paths and NO_DEFAULT_PATH
+# and then again with no specified paths to search the default
+# locations. When an earlier FIND_* succeeds, subsequent FIND_*s
+# searching for the same item do nothing. 
+FIND_PATH(GEOS_INCLUDE_DIR geos_c.h
   "$ENV{LIB_DIR}/include"
-  /usr/local/include 
-  /usr/include 
   #mingw
   c:/msys/local/include
   NO_DEFAULT_PATH
   )
+FIND_PATH(GEOS_INCLUDE_DIR geos_c.h)
 
 FIND_LIBRARY(GEOS_LIBRARY NAMES geos PATHS 
   "$ENV{LIB_DIR}/lib"
-  /usr/local/lib 
-  /usr/lib 
   #mingw
   c:/msys/local/lib
   NO_DEFAULT_PATH
   )
+FIND_LIBRARY(GEOS_LIBRARY NAMES geos)
 
 IF (GEOS_INCLUDE_DIR AND GEOS_LIBRARY)
    SET(GEOS_FOUND TRUE)


More information about the Qgis-developer mailing list