set(MODULE_NAME graphics)

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

set(platform_LIB_INCLUDES "")
set(platform_INCLUDE_DIRS "")
set(platform_HEADERS "")
set(platform_LIBS "")

list(APPEND graphics_LIB_INCLUDES 
    DrawingContext.cpp
    DrawingSurface.cpp
    RasterPainter.cpp
    PainterFactory.cpp
    ${platform_LIB_INCLUDES}
)
    
list(APPEND graphics_HEADERS 
    ${platform_HEADERS}
    RasterPainter.h
    PainterFactory.h
    )
if(UNIX)
set(OpenGL_GL_PREFERENCE "GLVND")
find_package(OpenGL QUIET)
if (OpenGL_FOUND)
    list(APPEND platform_LIBS OpenGL::GL OpenGL::GLU)
    list(APPEND graphics_LIB_INCLUDES 
            opengl/OpenGlPainter.cpp
            opengl/OpenGlTextPainter.cpp
            opengl/OpenGlMeshPainter.cpp
            opengl/OpenGlFontTexture.cpp
            opengl/OpenGlShaderProgram.cpp
            )
    list(APPEND ${MODULE_NAME} 
        opengl/OpenGlPainter.h
        opengl/OpenGlTextPainter.h
        opengl/OpenGlMeshPainter.h
        opengl/OpenGlFontTexture.h
        opengl/OpenGlShaderProgram.h)
    list(APPEND DEFINES "HAS_OPENGL") 
else()
    message(STATUS "OpenGL not found - skipping support")
endif()
endif()

add_library(${MODULE_NAME} SHARED 
    ${graphics_LIB_INCLUDES} 
    ${graphics_HEADERS})
    
target_include_directories(${MODULE_NAME} PUBLIC
                          ${platform_INCLUDE_DIRS}
                          ${CMAKE_CURRENT_SOURCE_DIR}
                          ${CMAKE_CURRENT_SOURCE_DIR}/opengl
                          )
                          
target_compile_definitions(${MODULE_NAME} PRIVATE ${DEFINES})
target_link_libraries(${MODULE_NAME} PUBLIC geometry mesh fonts image visual_elements ${platform_LIBS})

set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER src)
set_target_properties( ${MODULE_NAME} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON ) 