cmake_minimum_required(VERSION 3.2)
project(glTest)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Og -g -Wall")
set(CMAKE_BUILD_TYPE DEBUG)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")

if(APPLE)
	find_library(OPENGL_FRAMEWORK OpenGL)
	set(OPENGL_LIBRARIES ${OPENGL_FRAMEWORK})
else()
	find_package(OpenGL REQUIRED)
	set(OPENGL_LIBRARIES ${OPENGL_LIBRARIES})
endif()

find_package(PkgConfig REQUIRED)
pkg_search_module(GLFW REQUIRED glfw3)
include_directories(${GLFW_INCLUDE_DIRS})
link_directories(${GLFW_LIBRARY_DIRS})

find_package(GLEW REQUIRED)
include_directories(${GLEW_INCLUDE_DIRS})

find_package(GLM REQUIRED)
include_directories(${GLM_INCLUDE_DIRS})

find_package(Portaudio REQUIRED)
include_directories(${PORTAUDIO_INCLUDE_DIRS})

pkg_search_module(SNDFILE REQUIRED sndfile)
include_directories(${SNDFILE_INCLUDE_DIRS})
link_directories(${SNDFILE_LIBRARY_DIRS})

pkg_search_module(FFTW3F REQUIRED fftw3f)
include_directories(${FFTW3F_INCLUDE_DIRS})
link_directories(${FFTW3F_LIBRARY_DIRS})

aux_source_directory(src MAIN_SOURCE_FILES)
aux_source_directory(src/Audio AUDIO_SOURCE_FILES)
aux_source_directory(src/GLObjects GLOBJECTS_SOURCE_FILES)
aux_source_directory(src/Shaders SHADERS_SOURCE_FILES)

add_executable(glTest ${MAIN_SOURCE_FILES} ${AUDIO_SOURCE_FILES} ${GLOBJECTS_SOURCE_FILES} ${SHADERS_SOURCE_FILES})
target_link_libraries(glTest ${OPENGL_LIBRARIES} ${GLFW_LIBRARIES} ${GLEW_LIBRARIES} ${PORTAUDIO_LIBRARIES} ${SNDFILE_LIBRARIES} ${FFTW3F_LIBRARIES})
