Browse Source

ENH: add a test for find framework stuff in find_library, and fix the framework search stuff

Bill Hoffman 19 years ago
parent
commit
4fd3292d04
2 changed files with 59 additions and 0 deletions
  1. 28 0
      Source/cmFindBase.cxx
  2. 31 0
      Tests/BundleTest/CMakeLists.txt

+ 28 - 0
Source/cmFindBase.cxx

@@ -116,6 +116,31 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn)
     this->SetError("called with incorrect number of arguments");
     return false;
     }
+  std::string ff = this->Makefile->GetSafeDefinition("CMAKE_FIND_FRAMEWORK");
+  if(ff == "NEVER")
+    {
+    this->SearchFrameworkLast = false;
+    this->SearchFrameworkFirst = false;
+    this->SearchFrameworkOnly = false;
+    }
+  else if (ff == "ONLY")
+    {
+    this->SearchFrameworkLast = false;
+    this->SearchFrameworkFirst = false;
+    this->SearchFrameworkOnly = true;
+    }
+  else if (ff == "FIRST")
+    {
+    this->SearchFrameworkLast = false;
+    this->SearchFrameworkFirst = true;
+    this->SearchFrameworkOnly = false;
+    }
+  else if (ff == "LAST")
+    {
+    this->SearchFrameworkLast = true;
+    this->SearchFrameworkFirst = false;
+    this->SearchFrameworkOnly = false;
+    }
 
   // CMake versions below 2.3 did not search all these extra
   // locations.  Preserve compatibility unless a modern argument is
@@ -479,6 +504,9 @@ void cmFindBase::ExpandRegistryAndCleanPath()
 
 void cmFindBase::PrintFindStuff()
 {
+  std::cerr << "SearchFrameworkLast: " << this->SearchFrameworkLast << "\n";
+  std::cerr << "SearchFrameworkOnly: " << this->SearchFrameworkOnly << "\n";
+  std::cerr << "SearchFrameworkFirst: " << this->SearchFrameworkFirst << "\n";
   std::cerr << "VariableName " << this->VariableName << "\n";
   std::cerr << "VariableDocumentation " << this->VariableDocumentation << "\n";
   std::cerr << "NoDefaultPath " << this->NoDefaultPath << "\n";

+ 31 - 0
Tests/BundleTest/CMakeLists.txt

@@ -54,3 +54,34 @@ SET_TARGET_PROPERTIES(BundleTestLib PROPERTIES
 
 INCLUDE(CPack)
 
+# test the framework find stuff
+IF(EXISTS /usr/lib/libtcl.dylib
+    AND EXISTS /System/Library/Frameworks/tcl.framework)
+  SET(TCL NOTFOUND)
+  FIND_LIBRARY(TCL tcl)
+  MESSAGE("frame: ${TCL}")
+  IF(NOT "${TCL}" MATCHES .framework)
+    MESSAGE(FATAL_ERROR "Could not find tcl framework, found ${TCL}")
+  ENDIF(NOT "${TCL}" MATCHES .framework)
+  SET(TCL NOTFOUND)
+  SET(CMAKE_FIND_FRAMEWORK LAST)
+  FIND_LIBRARY(TCL tcl)
+  IF("${TCL}" MATCHES .framework)
+    MESSAGE(FATAL_ERROR "Found framework and should have found dylib ${TCL}")
+  ENDIF("${TCL}" MATCHES .framework)
+  SET(TCL NOTFOUND)
+  SET(CMAKE_FIND_FRAMEWORK NEVER)
+  FIND_LIBRARY(TCL tcl)
+  IF("${TCL}" MATCHES .framework)
+    MESSAGE(FATAL_ERROR "Found framework and should have found dylib ${TCL}")
+  ENDIF("${TCL}" MATCHES .framework)
+  MESSAGE("not frame: ${TCL}")
+  SET(TCL NOTFOUND)
+  SET(CMAKE_FIND_FRAMEWORK FIRST)
+  FIND_LIBRARY(TCL tcl)
+  IF(NOT "${TCL}" MATCHES .framework)
+    MESSAGE(FATAL_ERROR "Could not find tcl framework, found ${TCL}")
+  ENDIF(NOT "${TCL}" MATCHES .framework)
+  MESSAGE("frame: ${TCL}")
+ENDIF(EXISTS /usr/lib/libtcl.dylib
+  AND EXISTS /System/Library/Frameworks/tcl.framework)