cmake_minimum_required(VERSION 3.16)

project(tsc LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)

if (MSVC)
add_compile_options(/source-charset:utf-8)
endif()
if(DEFINED USE_BOOST)
message(STATUS "tsc use boost lib.")
include_directories(${MBOOST_INCLUDE_DIR})
link_directories(${MBOOST_LIB_DIR})
endif()

add_executable(tsc main.cpp client.h client.cpp config.h config.cpp)
target_link_libraries(tsc PRIVATE trans_net trans_util filecomplete)
if (UNIX)
target_link_libraries(tsc PRIVATE pthread)
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_SYSTEM_NAME MATCHES "Windows")
    target_link_libraries(tsc PRIVATE ws2_32 wsock32)
endif()
if(DEFINED USE_BOOST)
target_link_directories(tsc PRIVATE ${MBOOST_LIB_DIR})
target_link_libraries(tsc PRIVATE ${MBOOST_LIBS})
endif()
if(UNIX)
execute_process(
    COMMAND uname -a
    OUTPUT_VARIABLE UNAME_OUT
    OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(UNAME_OUT MATCHES "alpine" OR UNAME_OUT MATCHES "Alpine")
message(STATUS "tsc on musl static link")
target_link_libraries(tsc PRIVATE -static;-static-libstdc++)
endif()
endif()
