# CMake 3.14 fixes propagation of object library linking
# Cmake 3.24 dependency providers (helps with Conan find_package integration)
cmake_minimum_required(VERSION 3.24 FATAL_ERROR)

project(example VERSION 1.0.0 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_VERBOSE_MAKEFILE ON)

# Copy the resource data
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/res DESTINATION ${CMAKE_CURRENT_BINARY_DIR})

# Find OpenCV dependency
find_package(OpenCV CONFIG REQUIRED COMPONENTS core videoio)

# Import libdfx library from the parent folder
if(WIN32)
  set(LIB_EXT ".dll")
elseif(APPLE)
  set(LIB_EXT ".dylib")
else()
  set(LIB_EXT ".so")
endif()

add_library(libdfx SHARED IMPORTED)
set_target_properties(libdfx PROPERTIES
    IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/../lib/libdfx${LIB_EXT}
    INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/../include
)


add_executable(example 
    src/example.cpp
)

target_include_directories(example PUBLIC
    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>     # nlohmann
)

target_link_libraries(example PUBLIC
                      opencv::opencv
                      libdfx
)
