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

# sourcetree: Z;no-all-load,no-import,no-inplace,no-public,no-rootheader;z
if( NOT Z_LIBRARY)
   find_library( Z_LIBRARY NAMES ${CMAKE_STATIC_LIBRARY_PREFIX}z${CMAKE_STATIC_LIBRARY_SUFFIX} z NO_CMAKE_SYSTEM_PATH)
   message( STATUS "Z_LIBRARY is ${Z_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( Z_LIBRARY)
      #
      # Add to Z_LIBRARY list.
      # Disable with: `mark no-cmakeadd`
      #
      set( DEPENDENCY_LIBRARIES
         ${DEPENDENCY_LIBRARIES}
         ${Z_LIBRARY}
         CACHE INTERNAL "need to cache this"
      )
      #
      # Inherit ObjC loader and link dependency info.
      # Disable with: `mark no-cmakeinherit`
      #
      # // temporarily expand CMAKE_MODULE_PATH
      get_filename_component( _TMP_Z_ROOT "${Z_LIBRARY}" DIRECTORY)
      get_filename_component( _TMP_Z_ROOT "${_TMP_Z_ROOT}" DIRECTORY)
      #
      #
      # Search for "DependenciesAndLibraries.cmake" to include.
      # Disable with: `mark no-cmakedependency`
      #
      foreach( _TMP_Z_NAME "z")
         set( _TMP_Z_DIR "${_TMP_Z_ROOT}/include/${_TMP_Z_NAME}/cmake")
         # use explicit path to avoid "surprises"
         if( EXISTS "${_TMP_Z_DIR}/DependenciesAndLibraries.cmake")
            unset( Z_DEFINITIONS)
            list( INSERT CMAKE_MODULE_PATH 0 "${_TMP_Z_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_Z_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_Z_DIR}")
            set( INHERITED_DEFINITIONS
               ${INHERITED_DEFINITIONS}
               ${Z_DEFINITIONS}
               CACHE INTERNAL "need to cache this"
            )
            break()
         else()
            message( STATUS "${_TMP_Z_DIR}/DependenciesAndLibraries.cmake not found")
         endif()
      endforeach()
   else()
      message( FATAL_ERROR "Z_LIBRARY was not found")
   endif()
endif()


# sourcetree: FOUNDATION;no-fetch-darwin,no-os-darwin;
if( NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
   if( NOT FOUNDATION_LIBRARY)
      find_library( FOUNDATION_LIBRARY NAMES ${CMAKE_STATIC_LIBRARY_PREFIX}Foundation${CMAKE_STATIC_LIBRARY_SUFFIX} Foundation NO_CMAKE_SYSTEM_PATH)
      message( STATUS "FOUNDATION_LIBRARY is ${FOUNDATION_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( FOUNDATION_LIBRARY)
         #
         # Add to FOUNDATION_LIBRARY list.
         # Disable with: `mark no-cmakeadd`
         #
         set( ALL_LOAD_DEPENDENCY_LIBRARIES
            ${ALL_LOAD_DEPENDENCY_LIBRARIES}
            ${FOUNDATION_LIBRARY}
            CACHE INTERNAL "need to cache this"
         )
         #
         # Inherit ObjC loader and link dependency info.
         # Disable with: `mark no-cmakeinherit`
         #
         # // temporarily expand CMAKE_MODULE_PATH
         get_filename_component( _TMP_FOUNDATION_ROOT "${FOUNDATION_LIBRARY}" DIRECTORY)
         get_filename_component( _TMP_FOUNDATION_ROOT "${_TMP_FOUNDATION_ROOT}" DIRECTORY)
         #
         #
         # Search for "DependenciesAndLibraries.cmake" to include.
         # Disable with: `mark no-cmakedependency`
         #
         foreach( _TMP_FOUNDATION_NAME "Foundation")
            set( _TMP_FOUNDATION_DIR "${_TMP_FOUNDATION_ROOT}/include/${_TMP_FOUNDATION_NAME}/cmake")
            # use explicit path to avoid "surprises"
            if( EXISTS "${_TMP_FOUNDATION_DIR}/DependenciesAndLibraries.cmake")
               unset( FOUNDATION_DEFINITIONS)
               list( INSERT CMAKE_MODULE_PATH 0 "${_TMP_FOUNDATION_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_FOUNDATION_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_FOUNDATION_DIR}")
               set( INHERITED_DEFINITIONS
                  ${INHERITED_DEFINITIONS}
                  ${FOUNDATION_DEFINITIONS}
                  CACHE INTERNAL "need to cache this"
               )
               break()
            else()
               message( STATUS "${_TMP_FOUNDATION_DIR}/DependenciesAndLibraries.cmake not found")
            endif()
         endforeach()
         #
         # Search for "objc-loader.inc" in include directory.
         # Disable with: `mark no-cmakeloader`
         #
         if( NOT NO_INHERIT_OBJC_LOADERS)
            foreach( _TMP_FOUNDATION_NAME "Foundation")
               set( _TMP_FOUNDATION_FILE "${_TMP_FOUNDATION_ROOT}/include/${_TMP_FOUNDATION_NAME}/MulleObjCLoader+${_TMP_FOUNDATION_NAME}.h")
               if( EXISTS "${_TMP_FOUNDATION_FILE}")
                  set( INHERITED_OBJC_LOADERS
                     ${INHERITED_OBJC_LOADERS}
                     ${_TMP_FOUNDATION_FILE}
                     CACHE INTERNAL "need to cache this"
                  )
                  break()
               endif()
            endforeach()
         endif()
      else()
         message( FATAL_ERROR "FOUNDATION_LIBRARY was not found")
      endif()
   endif()
endif()