IF (DL_ROOT)
    # force re-find programs
    set(DL_INCLUDE_DIR NOTFOUND CACHE PATH "" FORCE)
    set(DL_LIBRARY NOTFOUND CACHE FILE "" FORCE)
ENDIF (DL_ROOT)

FIND_PATH(DL_INCLUDE_DIR dlfcn.h HINTS ${DL_ROOT} PATH_SUFFIXES "include")
FIND_LIBRARY(DL_LIBRARY dl HINTS ${DL_ROOT} PATH_SUFFIXES "lib") 

IF (DL_INCLUDE_DIR AND DL_LIBRARY)
   SET(DL_FOUND TRUE)
ENDIF (DL_INCLUDE_DIR AND DL_LIBRARY)

IF (DL_FOUND)
   IF (NOT DL_FIND_QUIETLY)
      MESSAGE(STATUS "Found dl: ${DL_LIBRARY}")
   ENDIF (NOT DL_FIND_QUIETLY)
ELSE (DL_FOUND)
   IF (DL_FIND_REQUIRED)
      MESSAGE(WARNING "Could not find dl")
   ENDIF (DL_FIND_REQUIRED)
ENDIF (DL_FOUND)
