project(pghp_opengl)

cmake_minimum_required(VERSION 2.8.0)

find_package(OpenGL REQUIRED)

add_subdirectory(ext/glfw)

include_directories(ext/glfw/include)
include_directories(ext/eigen3)
include_directories(ext/ObjFormat)
include_directories(ext/glfw/deps )

if(APPLE)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++")
else()
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()

set(ObjFormat_SRC_FILES
    ext/ObjFormat/ObjFormat.cpp
    ext/ObjFormat/ObjFormat.h
    ext/ObjFormat/ObjUtil.cpp
    ext/ObjFormat/ObjUtil.h
)

set(SRC_FILES 
    src/main.cpp
    src/viewer.cpp
    src/viewer.h
    src/shader.cpp
    src/shader.h
    src/trackball.cpp
    src/trackball.h
    src/camera.cpp
    src/camera.h
    src/meshloader.cpp
    src/meshloader.h
    src/mesh.cpp
    src/mesh.h
    src/opengl.h
    ext/glfw/deps/glad.c)

FILE(GLOB_RECURSE SHADER_FILES "data/shaders/*")
add_custom_target(SHADERS SOURCES ${SHADER_FILES})

add_definitions(-DDATA_DIR="${PROJECT_SOURCE_DIR}/data")

add_executable(pghp_td4 ${SRC_FILES} ${ObjFormat_SRC_FILES})

target_link_libraries(pghp_td4 glfw ${GLFW_LIBRARIES} ${OPENGL_LIBRARIES})
