
set (MESHMOON_SILVERLINING_SDK_DETECTED FALSE)

macro (configure_silverlining)
    if (NOT MESHMOON_SILVERLINING_SDK_DETECTED)
        if (MSVC)
            string (TOLOWER ${VC_VER}/${VS_PLATFORM} PLATFORM_PATH_LOWER)
            set (SILVERLINING_FOUND 0)
            if (NOT "$ENV{SILVERLINING_PATH}" STREQUAL "")
                file (TO_CMAKE_PATH "$ENV{SILVERLINING_PATH}" SILVERLINING_SDK)
                set (SILVERLINING_LIBS ${SILVERLINING_SDK}/lib/${PLATFORM_PATH_LOWER})
                set (SILVERLINING_FOUND 1)
            else ()
                message (FATAL_ERROR "Environment variable SILVERLINING_PATH is empty!")
            endif ()
        elseif (APPLE)
            if (NOT "$ENV{SILVERLINING_PATH}" STREQUAL "")
                file (TO_CMAKE_PATH "$ENV{SILVERLINING_PATH}" SILVERLINING_SDK)
                set (SILVERLINING_LIBS ${SILVERLINING_SDK}/lib/macos)
            else ()
                message (FATAL_ERROR "Environment variable SILVERLINING_PATH is empty!")
            endif ()
        elseif (UNIX)
            if (NOT "$ENV{SILVERLINING_PATH}" STREQUAL "")
                file (TO_CMAKE_PATH "$ENV{SILVERLINING_PATH}" SILVERLINING_SDK)
                set (SILVERLINING_LIBS ${SILVERLINING_SDK}/lib/linux)
            else ()
                message (FATAL_ERROR "Environment variable SILVERLINING_PATH is empty!")
            endif ()
        endif ()
        set (MESHMOON_SILVERLINING_SDK_DETECTED TRUE)
    endif ()
endmacro ()

macro (use_silverlining)
    configure_silverlining ()

    include_directories ("${SILVERLINING_SDK}/Public Headers")
endmacro ()

macro (link_silverlining)
    configure_silverlining ()

    if (MSVC)
        target_link_libraries (${TARGET_NAME} debug ${SILVERLINING_LIBS}/SilverLining-MTD-DLL.lib optimized ${SILVERLINING_LIBS}/SilverLining-MT-DLL.lib)
    elseif (APPLE)
        target_link_libraries (${TARGET_NAME} debug ${SILVERLINING_LIBS}/libSilverLiningOpenGL.a optimized ${SILVERLINING_LIBS}/libSilverLiningOpenGL.a)
    elseif (UNIX)
        target_link_libraries (${TARGET_NAME} ${SILVERLINING_LIBS}/libSilverLiningOpenGL.a GL)
    endif ()
endmacro ()
