cmake_minimum_required(VERSION 2.8)

# libfreetype libm
find_library(FREETYPE_LIBRARY NAMES ${CONAN_LIBS_FREETYPE} PATHS ${CONAN_LIB_DIRS_FREETYPE} NO_CMAKE_FIND_ROOT_PATH)

if (DEFINED CONAN_LIBS_LIBPNG)
    find_library(LIBPNG_LIBRARY NAMES ${CONAN_LIBS_LIBPNG} PATHS ${CONAN_LIB_DIRS_LIBPNG} NO_CMAKE_FIND_ROOT_PATH)
    set(FREETYPE_LIBRARY ${FREETYPE_LIBRARY} ${LIBPNG_LIBRARY})
endif(DEFINED CONAN_LIBS_LIBPNG)

if (DEFINED CONAN_LIBS_BZIP2)
    find_library(BZIP2_LIBRARY NAMES ${CONAN_LIBS_BZIP2} PATHS ${CONAN_LIB_DIRS_BZIP2} NO_CMAKE_FIND_ROOT_PATH)
    set(FREETYPE_LIBRARY ${FREETYPE_LIBRARY} ${BZIP2_LIBRARY})
endif(DEFINED CONAN_LIBS_BZIP2)

if (DEFINED CONAN_LIBS_ZLIB)
    find_library(ZLIB_LIBRARY NAMES ${CONAN_LIBS_ZLIB} PATHS ${CONAN_LIB_DIRS_ZLIB} NO_CMAKE_FIND_ROOT_PATH)
    set(FREETYPE_LIBRARY ${FREETYPE_LIBRARY} ${ZLIB_LIBRARY})
endif(DEFINED CONAN_LIBS_ZLIB)

if(UNIX AND NOT APPLE)
    set(FREETYPE_LIBRARY ${FREETYPE_LIBRARY} m)
endif(UNIX AND NOT APPLE)

set(FREETYPE_INCLUDE_DIRS ${CONAN_INCLUDE_DIRS})
set(FREETYPE_INCLUDE_DIR ${CONAN_INCLUDE_DIRS_FREETYPE})
set(FREETYPE_LIBRARIES ${CONAN_LIBS})

MESSAGE("** FREETYPE ALREADY FOUND BY CONAN!")
SET(FREETYPE_FOUND TRUE)
MESSAGE("** FOUND FREETYPE:  ${FREETYPE_LIBRARY}")
MESSAGE("** FOUND FREETYPE INCLUDE:  ${FREETYPE_INCLUDE_DIR}")

mark_as_advanced(FREETYPE_LIBRARY FREETYPE_INCLUDE_DIR)

set(FREETYPE_MAJOR_VERSION "2")
set(FREETYPE_MINOR_VERSION "9")
set(FREETYPE_PATCH_VERSION "0")
