cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
project({project_name} LANGUAGES C CXX)

set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

file(MAKE_DIRECTORY "${PROJECT_SOURCE_DIR}/assets/public/SimGraphicsNative"
  "${CMAKE_CURRENT_BINARY_DIR}/bin")
file(CREATE_LINK "${PROJECT_SOURCE_DIR}/assets"
  "${CMAKE_CURRENT_BINARY_DIR}/bin/assets" SYMBOLIC)
include(${CMAKE_CURRENT_LIST_DIR}/cmake/conan.cmake)
conan_cmake_run(
    BASIC_SETUP
    CONANFILE conanfile.py
    BUILD missing)

option(BUILD_TEST "Build test" ON)

add_executable({project_name} src/main.cpp)

target_include_directories({project_name} PUBLIC
    ${CMAKE_CURRENT_LIST_DIR}/src)
target_compile_definitions({project_name}
    PRIVATE
    $<$<CONFIG:DEBUG>:DEBUG>)
target_link_libraries({project_name}
    PUBLIC
    $<$<PLATFORM_ID:Linux>:dl>
    ${CONAN_LIBS}
    $<$<CXX_COMPILER_ID:GNU>:-static-libgcc>
    $<$<CXX_COMPILER_ID:GNU>:-static-libstdc++>)

if (BUILD_TEST)
    file(GLOB_RECURSE test-sources CONFIGURE_DEPENDS "test/*.cpp")
    foreach (file ${test-sources})
      get_filename_component(comp ${file} NAME_WE)
      add_executable(${comp} ${file})
      target_include_directories(${comp} PUBLIC
        ${CMAKE_CURRENT_LIST_DIR}/test)
      target_link_libraries(${comp} PRIVATE ${CONAN_LIBS})
    endforeach ()
endif ()
