cmake_minimum_required(VERSION 3.9.6)
cmake_policy(VERSION 3.9.6)

# Sources
file(GLOB_RECURSE SOURCES "src/*.cpp" "src/*.cxx" "src/*.c" "../common/*.cpp" "../tinyply/source/tinyply.cpp")
file(GLOB_RECURSE HEADERS "src/*.hpp" "src/*.hxx" "src/*.h")

# Output
project(demo VERSION 0.1.0)
add_executable(demo src/main.cpp ${SOURCES} ${HEADERS})

# Compilation options
set(CMAKE_CXX_STANDARD_REQUIRED "ON")

set_property(TARGET demo PROPERTY INTERPROCEDURAL_OPTIMIZATION True)
set_property(TARGET demo PROPERTY CXX_STANDARD 20)

option (FORCE_COLORED_OUTPUT "Always produce ANSI-colored output (GNU/Clang only)." FALSE)
if (${FORCE_COLORED_OUTPUT})
    if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
       add_compile_options (-fdiagnostics-color=always)
    elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
       add_compile_options (-fcolor-diagnostics)
    endif ()
endif ()


if (WIN32)
	add_definitions(-D_WIN32 -DVK_USE_PLATFORM_WIN32_KHR)

	find_library(AssimpLib assimp-vc140-mt HINTS external/ bin/)
	find_library(FreeimageLib freeimage HINTS external/ bin/)
	target_link_libraries(demo PUBLIC ${AssimpLib} ${FreeimageLib})
endif (WIN32)
if (UNIX)
	target_compile_options(demo PRIVATE 
		-march=native -pipe 
		-mavx2
	)

	add_definitions(-D_linux -DVK_USE_PLATFORM_XCB_KHR -D__AVX2__)

	target_link_libraries(demo PUBLIC
		stdc++fs
		pthread atomic
		tbb
		assimp png
		xcb xcb-icccm X11 X11-xcb
		IlmImf Half
		fftw3
		opencv_videoio opencv_core opencv_imgproc
	)
endif (UNIX)

# Include paths
target_include_directories(demo PRIVATE 
	../common
	../external
	../external/gli
	../external/glm
	../external/stb 
	../external/vulkan
	../external/color-util/include
	../external/eigen
	../external/assimp
	../external/fftw3cxx
    ../uraster
	../tinyply/source
	/usr/include/eigen3
	/usr/include/opencv4
)


set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)

