cmake_minimum_required(VERSION 3.10)


if(NOT CMAKE_BUILD_TYPE)
  set(CMAKE_BUILD_TYPE Debug)
endif()

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)

project(tview)

set (SOURCES
lib/backends/imgui_impl_opengl3.cpp
lib/backends/imgui_impl_opengl3.h
lib/backends/imgui_impl_opengl3_loader.h
lib/backends/imgui_impl_sdl2.cpp
lib/backends/imgui_impl_sdl2.h
lib/backends/tex_inspect_opengl.h
lib/backends/tex_inspect_opengl.cpp
lib/context_wrapper.h
lib/image_model.h
lib/imconfig.h
lib/imfilebrowser.h
lib/imgui.cpp
lib/imgui.h
lib/imgui_bezier_math.h
lib/imgui_bezier_math.inl
lib/imgui_demo.cpp
lib/imgui_draw.cpp
lib/imgui_extra_math.h
lib/imgui_extra_math.inl
lib/imgui_internal.h
lib/imgui_tables.cpp
lib/imgui_widgets.cpp
lib/imstb_rectpack.h
lib/imstb_textedit.h
lib/imstb_truetype.h
lib/stb_image.h
lib/imgui_tex_inspect.h
lib/imgui_tex_inspect_internal.h
lib/imgui_tex_inspect.cpp
lib/argparse.hpp
lib/histogram.h
main.cpp
)

set(OpenGL_GL_PREFERENCE GLVND)
find_package(SDL2 REQUIRED)
find_package(OpenGL REQUIRED)
find_package(exiv2 REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBRAW REQUIRED libraw)
include_directories(${SDL2_INCLUDE_DIRS} ${OPENGL_INCLUDE_DIRS} ${LIBRAW_INCLUDE_DIRS})

set(CMAKE_CXX_FLAGS "-Wall -Wextra")
set(CMAKE_CXX_FLAGS_DEBUG "-g3 -rdynamic -O0")
set(CMAKE_CXX_FLAGS_RELEASE "-O2")

add_executable(tview ${SOURCES})
target_link_libraries(tview ${SDL2_LIBRARIES} ${OPENGL_LIBRARIES} exiv2lib ${LIBRAW_LIBRARIES})
