[Cmake] FindLibrary problems

Gareth Jones gareth.jones at stud.man.ac.uk
Fri Feb 28 07:47:26 EST 2003


Suppose I have a CMakeLists.txt in a directory (/proj/dir) which
contains a sub-directory called `mex'.  FIND_LIBRARY(mex PATH
${MATLAB_LIB_DIR}) will return /proj/dir/mex which is not a library
(or even a regular file) even though there is a libmex.so in
${MATLAB_LIB_DIR}.  These sections

--- cmSystemTools.cxx	14 Feb 2003 15:56:21 -0000	1.218
+++ cmSystemTools.cxx	28 Feb 2003 12:26:25 -0000
@@ -1625,12 +1625,6 @@
 std::string cmSystemTools::FindLibrary(const char* name,
                                        const std::vector<std::string>& userPaths)
 {
-  // See if the executable exists as written.
-  if(cmSystemTools::FileExists(name))
-    {
-    return cmSystemTools::CollapseFullPath(name);
-    }
-    
   // Add the system search path to our path.
   std::vector<std::string> path = userPaths;
   cmSystemTools::GetPath(path);

--- cmMakefile.cxx.~1.192.~	Thu Feb 20 14:28:10 2003
+++ cmMakefile.cxx	Fri Feb 28 12:24:46 2003
@@ -1554,12 +1554,6 @@
 std::string cmMakefile::FindLibrary(const char* name,
                                     const std::vector<std::string>& userPaths)
 {
-  // See if the executable exists as written.
-  if(cmSystemTools::FileExists(name))
-    {
-    return cmSystemTools::CollapseFullPath(name);
-    }
-  
   // Add the system search path to our path.
   std::vector<std::string> path = userPaths;
   cmSystemTools::GetPath(path);


are responsible.  I think that the current behaviour is highly
confusing: it does not conform to FIND_LIBRARY's documentation and it
places restrictions on the directory structure within a project.  If
these sections were removed then I think you could still get the old
behaviour with

FIND_FILE (FOO_LIB foo /abs/path)
IF (NOT FOO_LIB)
  FIND_LIBRARY (FOO_LIB /abs/path/foo PATHS path1 path2)
ENDIF (NOT FOO_LIB)

Though doubt that

FIND_LIBRARY (FOO_LIB /abs/path/foo PATHS path1 path2)

is often useful since it looks for

path1/lib/abs/path/foo.a etc.
      ^^^
      Not on Windows.


Gareth Jones




More information about the CMake mailing list