# Automatically generated by cppiniter {{{date_time}}}

{{#is_exe}}
set(TARGET {{{project_name}}})
add_executable(${TARGET})
{{/is_exe}}
{{^is_exe}}
set(TARGET {{{project_name}}}_obj)
add_library(${TARGET} OBJECT)

if(BUILD_SHARED_LIBS)
    target_compile_definitions(${TARGET} PRIVATE {{{project_name_uppercase}}}_DLL {{{project_name_uppercase}}}_DLL_EXPORTS)
endif()
{{/is_exe}}

target_include_directories(${TARGET} PUBLIC ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_BINARY_DIR})

{{#is_exe}}
configure_file(${CMAKE_CURRENT_LIST_DIR}/version.h.in ${CMAKE_BINARY_DIR}/version.h)
{{/is_exe}}
{{^is_exe}}
configure_file(${CMAKE_CURRENT_LIST_DIR}/{{{project_name}}}/version.h.in ${CMAKE_BINARY_DIR}/version.h)
{{/is_exe}}

file(GLOB_RECURSE SRC "*.h" "*.hpp" "*.cpp")
target_sources(${TARGET} PRIVATE ${SRC})

find_package(fmt REQUIRED CONFIG)

target_link_libraries(${TARGET} fmt::fmt)

{{^is_exe}}
add_library({{{project_name}}} $<TARGET_OBJECTS:${TARGET}>)
target_link_libraries({{{project_name}}} $<TARGET_PROPERTY:${TARGET},LINK_LIBRARIES>)
target_include_directories({{{project_name}}} PUBLIC ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_BINARY_DIR})
{{/is_exe}}

{{#is_exe}}
if(LINUX)
    set_target_properties({{{project_name}}} PROPERTIES INSTALL_RPATH "$ORIGIN/../lib")
elseif(APPLE)
    set_target_properties({{{project_name}}} PROPERTIES INSTALL_RPATH "@executable_path/../lib")
endif()
{{/is_exe}}
{{^is_exe}}
if(LINUX)
    set_target_properties({{{project_name}}} PROPERTIES INSTALL_RPATH "$ORIGIN")
endif()
{{/is_exe}}
install(
    TARGETS {{{project_name}}}
    RUNTIME DESTINATION bin
    LIBRARY DESTINATION lib
    ARCHIVE DESTINATION lib
)

if(MSVC AND BUILD_SHARED_LIBS)
    install(FILES $<TARGET_PDB_FILE:{{{project_name}}}> DESTINATION bin)
endif()
