set(MODULE_NAME fonts)
message(STATUS "Checking dependencies for module: " ${MODULE_NAME})

set(LIB_DEPENDS "")

list(APPEND LIB_INCLUDES 
    FontReader.cpp
    TrueTypeFont.cpp
    FontsManager.cpp
    FontGlyph.cpp
    FontReader.h
    TrueTypeFont.h
    FontsManager.h
    FontGlyph.h
    IFont.h
    IFontEngine.h
	BasicFontEngine.h
	BasicFontEngine.cpp
	FontItem.h
	FontItem.cpp
    )
    
if(UNIX)
    find_package(Freetype QUIET)
    if(Freetype_FOUND)
        list(APPEND LIB_INCLUDES
        FreeTypeFontEngine.cpp
        )
        
        list(APPEND LIB_DEPENDS
        Freetype::Freetype
        )
        list(APPEND DEFINES "HAS_FREETYPE")   
    else()
        message(STATUS "Freetype not found - skipping support")
    endif()
else()
        list(APPEND LIB_INCLUDES
            directx/DirectWriteFontEngine.h
			directx/DirectWriteHelpers.h
            directx/DirectWriteFontEngine.cpp
			directx/DirectWriteHelpers.cpp
        )
        list(APPEND LIB_DEPENDS
            Dwrite.lib D2d1.lib uuid.lib
        )
endif()

add_library(${MODULE_NAME} SHARED ${LIB_INCLUDES})

target_include_directories(${MODULE_NAME} PUBLIC
                          ${CMAKE_CURRENT_SOURCE_DIR}
						  ${CMAKE_CURRENT_SOURCE_DIR}/directx
                          )
                          
target_link_libraries(${MODULE_NAME} PUBLIC core geometry image ${LIB_DEPENDS})

target_compile_definitions(${MODULE_NAME} PRIVATE ${DEFINES})
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER src/rendering)
set_target_properties( ${MODULE_NAME} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON )