cmake_minimum_required(VERSION 3.12)
project({project_name} LANGUAGES C CXX)

set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)

include(${CMAKE_CURRENT_LIST_DIR}/cmake/symlink.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/cmake/conan.cmake)
conan_cmake_run(
    BASIC_SETUP
    CONANFILE conanfile.py
    BUILD missing)

option(BUILD_TEST "Build test" ON)
option(BUILD_SHARED "Build shared lib" ON)

set(sources src/main.cpp)

if (BUILD_SHARED)
    add_library({project_name} SHARED ${sources})
else()
    add_library({project_name} STATIC ${sources})
endif()

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
    ${CONAN_LIBS}
    $<$<PLATFORM_ID:Linux>:dl>)

if (BUILD_TEST)
    file(GLOB test-sources CONFIGURE_DEPENDS "test/*.cpp")
    foreach (file ${test-sources})
      get_filename_component(comp ${file} NAME_WE)
      add_executable(${comp} ${file})
      target_link_libraries(${comp} PRIVATE {project_name})
    endforeach ()
endif ()
