include(FetchContent)

if(NOT DEFINED GLM_REPO)
    set(GLM_REPO https://github.com/g-truc/glm.git)
endif ()

FetchContent_Declare(
        glm
        EXCLUDE_FROM_ALL
        GIT_REPOSITORY ${GLM_REPO}
        GIT_TAG 1.0.1
        GIT_SHALLOW TRUE
)
set(GLM_TEST_ENABLE OFF CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(glm)

function(SetGlmDefines TARGET)
    target_compile_definitions(${TARGET} PUBLIC GLM_FORCE_SILENT_WARNINGS)
    target_compile_definitions(${TARGET} PUBLIC GLM_ENABLE_EXPERIMENTAL)
    target_compile_definitions(${TARGET} PUBLIC GLM_FORCE_ALIGNED_GENTYPES)

    if (NOT ANDROID AND NOT APPLE)
        # TODO check target architecture first
        target_compile_definitions(${TARGET} PUBLIC GLM_FORCE_AVX2)
    else ()
        target_compile_definitions(${TARGET} PUBLIC GLM_FORCE_INTRINSICS)
    endif ()
endfunction()
