cmake_minimum_required(VERSION 3.23)
project(VWeb)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUGSOFT")
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
set(SOURCE_FILES
        Source/EPollManager.cpp
        Source/RequestHandler.cpp
        Source/Server.cpp
        Source/SocketManager.cpp
        Source/ThreadPool.cpp
        Source/Router.cpp
        Source/MiddleWare.cpp
        Source/Route.cpp
        Source/StringUtils.cpp
        Source/Cookie.cpp
        Source/Session.cpp
        Source/Response.cpp)
include_directories(${CMAKE_SOURCE_DIR}/)
add_library(VWeb ${SOURCE_FILES})

set(mode release)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
    set(mode debug)
endif ()
set(target_file ${CMAKE_SOURCE_DIR}/dist/libVWeb.${mode}.a)
add_custom_command(TARGET VWeb POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:VWeb> ${target_file})