FindDlopen.cmake: Don't run the FindDlopen module more than once.
authorPierre d'Herbemont <pdherbemont@videolan.org>
Mon, 4 Feb 2008 20:07:27 +0000 (20:07 +0000)
committerPierre d'Herbemont <pdherbemont@videolan.org>
Mon, 4 Feb 2008 20:07:27 +0000 (20:07 +0000)
extras/buildsystem/cmake/include/FindDlopen.cmake

index 1f2ac9e..1b99b2b 100644 (file)
@@ -8,31 +8,35 @@
 # Copyright (c) 2007 Erik Johansson <erik@ejohansson.se>
 # Redistribution and use is allowed according to the terms of the BSD license.
 
-include(CheckLibraryExists)
 
 # Assume dlopen is not found.
-set(Dlopen_FOUND FALSE)
-
-foreach (library c c_r dl)
-  if (NOT Dlopen_FOUND)
-    check_library_exists(${library} dlopen "" Dlopen_IN_${library})
-
-    if (Dlopen_IN_${library})
-      set(Dlopen_LIBRARIES ${library} CACHE STRING "Library containing dlopen")
-      set(Dlopen_FOUND TRUE)
-    endif (Dlopen_IN_${library})
-
-  endif (NOT Dlopen_FOUND)
-endforeach (library)
-
-if (Dlopen_FOUND)
-  if (NOT Dlopen_FIND_QUIETLY)
-    message(STATUS "Found dlopen in: ${Dlopen_LIBRARIES}")
-  endif (NOT Dlopen_FIND_QUIETLY)
-else (Dlopen_FOUND)
-  if (Dlopen_FIND_REQUIRED)
-    message(FATAL_ERROR "Could not find the library containing dlopen")
-  endif (Dlopen_FIND_REQUIRED)
-endif (Dlopen_FOUND)
-
-mark_as_advanced(Dlopen_LIBRARIES)
+if (Dlopen_SEARCHED)
+    include(CheckLibraryExists)
+
+    set(Dlopen_SEARCHED TRUE)
+    set(Dlopen_FOUND FALSE)
+
+    foreach (library c c_r dl)
+      if (NOT Dlopen_FOUND)
+        check_library_exists(${library} dlopen "" Dlopen_IN_${library})
+
+        if (Dlopen_IN_${library})
+          set(Dlopen_LIBRARIES ${library} CACHE STRING "Library containing dlopen")
+          set(Dlopen_FOUND TRUE)
+        endif (Dlopen_IN_${library})
+
+      endif (NOT Dlopen_FOUND)
+    endforeach (library)
+
+    if (Dlopen_FOUND)
+      if (NOT Dlopen_FIND_QUIETLY)
+        message(STATUS "Found dlopen in: ${Dlopen_LIBRARIES}")
+      endif (NOT Dlopen_FIND_QUIETLY)
+    else (Dlopen_FOUND)
+      if (Dlopen_FIND_REQUIRED)
+        message(FATAL_ERROR "Could not find the library containing dlopen")
+      endif (Dlopen_FIND_REQUIRED)
+    endif (Dlopen_FOUND)
+
+    mark_as_advanced(Dlopen_LIBRARIES)
+endif(Dlopen_SEARCHED)
\ No newline at end of file