#
# cmake/_Libraries.cmake is generated by `mulle-sde`. Edits will be lost.
#
if( MULLE_TRACE_INCLUDE)
   message( STATUS "# Include \"${CMAKE_CURRENT_LIST_FILE}\"" )
endif()

if( NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows")
   if( NOT DLFCN_LIBRARY)
      find_library( DLFCN_LIBRARY NAMES dl dlfcn dlfcn)
      message( STATUS "DLFCN_LIBRARY is ${DLFCN_LIBRARY}")
      #
      # the order looks ascending, but due to the way this file is read
      # it ends up being descending, which is what we need
      if( DLFCN_LIBRARY)
         set( OS_SPECIFIC_LIBRARIES
            ${OS_SPECIFIC_LIBRARIES}
            ${DLFCN_LIBRARY}
            CACHE INTERNAL "need to cache this"
         )
         # temporarily expand CMAKE_MODULE_PATH
         get_filename_component( _TMP_DLFCN_ROOT "${DLFCN_LIBRARY}" DIRECTORY)
         get_filename_component( _TMP_DLFCN_ROOT "${_TMP_DLFCN_ROOT}" DIRECTORY)
         #
         # search for DependenciesAndLibraries.cmake to include
         foreach( _TMP_DLFCN_NAME "dl" "dlfcn" "dlfcn")
            set( _TMP_DLFCN_DIR "${_TMP_DLFCN_ROOT}/include/${_TMP_DLFCN_NAME}/cmake")
            # use explicit path to avoid "surprises"
            if( EXISTS "${_TMP_DLFCN_DIR}/DependenciesAndLibraries.cmake")
               unset( DLFCN_DEFINITIONS)
               list( INSERT CMAKE_MODULE_PATH 0 "${_TMP_DLFCN_DIR}")
               # we only want top level INHERIT_OBJC_LOADERS, so disable them
               if( NOT NO_INHERIT_OBJC_LOADERS)
                  set( NO_INHERIT_OBJC_LOADERS OFF)
               endif()
               list( APPEND _TMP_INHERIT_OBJC_LOADERS ${NO_INHERIT_OBJC_LOADERS})
               set( NO_INHERIT_OBJC_LOADERS ON)
               #
               include( "${_TMP_DLFCN_DIR}/DependenciesAndLibraries.cmake")
               #
               list( GET _TMP_INHERIT_OBJC_LOADERS -1 NO_INHERIT_OBJC_LOADERS)
               list( REMOVE_AT _TMP_INHERIT_OBJC_LOADERS -1)
               #
               list( REMOVE_ITEM CMAKE_MODULE_PATH "${_TMP_DLFCN_DIR}")
               set( INHERITED_DEFINITIONS
                  ${INHERITED_DEFINITIONS}
                  ${DLFCN_DEFINITIONS}
                  CACHE INTERNAL "need to cache this"
               )
               break()
            else()
               message( STATUS "${_TMP_DLFCN_DIR}/DependenciesAndLibraries.cmake not found")
            endif()
         endforeach()
      else()
         message( FATAL_ERROR "DLFCN_LIBRARY was not found")
      endif()
   endif()
endif()
