## Copyright (c) 2018-2020 Advanced Micro Devices, Inc. All rights reserved.
cmake_minimum_required(VERSION 3.5.1)

set(DEPTH "../../")

set(GPA_PROJECT_NAME GPUPerfAPICounterGenerator-GL)
set(ProjectName ${GPA_PROJECT_NAME})

set(CMAKE_INCLUDE_CURRENT_DIR ON)
include(${GPA_CMAKE_MODULES_DIR}/common.cmake)
include(${CMAKE_COMMON_LIB_GLOBAL_EXT_OPENGL})

set(COUNTER_GENERATOR_HEADERS_GL
    gpa_counter_generator_gl.h)

set(GL_SRC  gl_entry_points.h
            gl_func_types.h
            gl_functions.h
            gl_entry_points.cc)

set(COUNTER_GENERATOR_SRC_GL
    gpa_counter_generator_gl.cc)

set(COUNTER_SCHEDULER_HEADERS_GL
    gpa_counter_scheduler_gl.h)

set(COUNTER_SCHEDULER_SRC_GL
    gpa_counter_scheduler_gl.cc)

if(EXISTS ${GPA_AUTOGEN_SRC_COUNTER_GENERATOR})
    include(${GPA_AUTOGEN_SRC_COUNTER_GENERATOR}/gpa_hw_counter_gl.cmake)
    include(${GPA_AUTOGEN_SRC_COUNTER_GENERATOR}/public_counter_definitions_gl.cmake)

    set(API_HEADER_FILES ${HW_COUNTER_HEADERS_GL} ${PUBLIC_COUNTER_DEF_HEADERS_GL} ${ADDITIONAL_COUNTER_DEF_HEADERS_GL})
    set(API_SOURCE_FILES ${HW_COUNTER_SRC_GL} ${PUBLIC_COUNTER_DEF_SRC_GL} ${ADDITIONAL_COUNTER_DEF_SRC_GL})

    if(WIN32)
        source_group("Source Files\\${HARDWARE_COUNTER_VS_FILTER}\\AutoGenerated" FILES ${HW_COUNTER_HEADERS_GL} ${HW_COUNTER_SRC_GL})
        source_group("Source Files\\${DERIVED_COUNTER_VS_FILTER}\\AutoGenerated" FILES ${PUBLIC_COUNTER_DEF_HEADERS_GL}
                                                                                       ${ADDITIONAL_COUNTER_DEF_HEADERS_GL}
                                                                                       ${PUBLIC_COUNTER_DEF_SRC_GL}
                                                                                       ${ADDITIONAL_COUNTER_DEF_SRC_GL})
    endif()
endif()

set(SOURCES ${COUNTER_GENERATOR_HEADERS_GL}
            ${COUNTER_GENERATOR_SRC_GL}
            ${COUNTER_SCHEDULER_HEADERS_GL}
            ${COUNTER_SCHEDULER_SRC_GL}
            ${GL_SRC}
            ${API_HEADER_FILES}
            ${API_SOURCE_FILES}
            ${ADDITIONAL_COUNTERS_GL})

if(WIN32)
    add_compile_options(/bigobj)
else()
    add_compile_options(-Wno-write-strings)
endif()

ADD_STATIC_LIBRARY(${GPA_PROJECT_NAME})
ADD_LINKER_FLAGS()
target_link_libraries(${GPA_PROJECT_NAME} GPUPerfAPICounterGenerator-Common)
target_include_directories(${GPA_PROJECT_NAME} PUBLIC ${ADDITIONAL_INCLUDE_DIRECTORIES})

if(WIN32)
    source_group("Source Files\\" FILES ${GL_SRC})
    source_group("Source Files\\${COUNTER_GENERATOR_VS_FILTER}" FILES ${COUNTER_GENERATOR_HEADERS_GL} ${COUNTER_GENERATOR_SRC_GL})
    source_group("Source Files\\${COUNTER_SCHEDULER_VS_FILTER}" FILES ${COUNTER_SCHEDULER_HEADERS_GL} ${COUNTER_SCHEDULER_SRC_GL})
endif()

