84 lines
2.5 KiB
CMake
84 lines
2.5 KiB
CMake
cmake_minimum_required(VERSION 3.20)
|
|
project(tizi LANGUAGES CXX)
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
set(third_party "${CMAKE_CURRENT_LIST_DIR}/third_party")
|
|
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
|
set(CMAKE_FOLDER "yaml-cpp-master")
|
|
add_subdirectory("${third_party}/yaml-cpp-master")
|
|
set(CMAKE_FOLDER "lexbor-3.0.0")
|
|
add_subdirectory("${third_party}/lexbor-3.0.0")
|
|
set(CMAKE_FOLDER "json-3.12.0")
|
|
add_subdirectory("${third_party}/json-3.12.0")
|
|
set(CMAKE_FOLDER "asio")
|
|
include("${third_party}/asio/main.cmake")
|
|
|
|
|
|
unset(CMAKE_FOLDER)
|
|
|
|
|
|
find_package(OpenSSL REQUIRED)
|
|
if (WIN32 AND TARGET asio_object)
|
|
target_compile_definitions(asio_object PUBLIC
|
|
_WIN32_WINNT=0x0A00
|
|
WINVER=0x0A00
|
|
NOMINMAX
|
|
WIN32_LEAN_AND_MEAN
|
|
)
|
|
endif ()
|
|
set(src "${CMAKE_CURRENT_LIST_DIR}/src")
|
|
set(base_src "${src}/base")
|
|
file(GLOB_RECURSE base_srcs CONFIGURE_DEPENDS
|
|
"${base_src}/*.hpp" "${base_src}/*.h" "${base_src}/*.cpp"
|
|
"${src}/*.hpp" "${src}/*.h" "${src}/*.cpp"
|
|
)
|
|
add_library(Base ${base_srcs})
|
|
target_include_directories(Base PUBLIC "${websocketpp_dir}")
|
|
target_include_directories(Base PUBLIC "${src}")
|
|
target_compile_definitions(Base PUBLIC
|
|
CPPHTTPLIB_OPENSSL_SUPPORT
|
|
ASIO_STANDALONE
|
|
ASIO_SEPARATE_COMPILATION
|
|
ASIO_NO_TS_EXECUTORS
|
|
ASIO_NO_DYNAMIC_BUFFER_V1
|
|
)
|
|
if (WIN32)
|
|
target_compile_definitions(Base PUBLIC
|
|
_WIN32_WINNT=0x0A00
|
|
WINVER=0x0A00
|
|
NOMINMAX
|
|
WIN32_LEAN_AND_MEAN
|
|
)
|
|
endif ()
|
|
target_link_libraries(Base PUBLIC
|
|
OpenSSL::SSL
|
|
OpenSSL::Crypto
|
|
yaml-cpp::yaml-cpp
|
|
lexbor_static
|
|
nlohmann_json::nlohmann_json
|
|
asio_object
|
|
)
|
|
if (MSVC)
|
|
target_compile_options(Base PUBLIC /utf-8)
|
|
endif ()
|
|
file(GLOB list CONFIGURE_DEPENDS LIST_DIRECTORIES true "${src}/*" )
|
|
list(REMOVE_ITEM list "${src}/base")
|
|
foreach (cur_dir ${list})
|
|
if(NOT IS_DIRECTORY "${cur_dir}")
|
|
continue()
|
|
endif()
|
|
get_filename_component(target "${cur_dir}" NAME)
|
|
file(GLOB_RECURSE cur_srcs CONFIGURE_DEPENDS "${cur_dir}/*.h" "${cur_dir}/*.cpp")
|
|
add_executable(${target} ${cur_srcs})
|
|
target_link_libraries(${target} PRIVATE Base)
|
|
# if (target STREQUAL "node_service")
|
|
# add_custom_command(TARGET ${target} POST_BUILD
|
|
# COMMAND "${CMAKE_COMMAND}" -E copy_directory
|
|
# "${cur_dir}/web"
|
|
# "$<TARGET_FILE_DIR:${target}>/../node_service_web"
|
|
# VERBATIM
|
|
# )
|
|
# endif ()
|
|
endforeach ()
|