-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
80 lines (66 loc) · 4.02 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
cmake_minimum_required (VERSION 3.1)
if(DEFINED ENV{VCPKG_DEFAULT_TRIPLET})
message(STATUS "Setting default vcpkg target triplet to $ENV{VCPKG_DEFAULT_TRIPLET}")
set(VCPKG_TARGET_TRIPLET $ENV{VCPKG_DEFAULT_TRIPLET})
endif()
if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "")
message(STATUS "VCPKG found: $ENV{VCPKG_ROOT}")
message(STATUS "Using VCPKG integration")
message(STATUS "VCPKG_MANIFEST_FEATURES: ${VCPKG_MANIFEST_FEATURES}")
elseif(DEFINED CMAKE_TOOLCHAIN_FILE)
message(STATUS "Using toolchain: ${CMAKE_TOOLCHAIN_FILE}")
if(CMAKE_TOOLCHAIN_FILE MATCHES "vcpkg.cmake")
message(STATUS "Toolchain uses VCPKG integration")
message(STATUS "VCPKG_MANIFEST_FEATURES: ${VCPKG_MANIFEST_FEATURES}")
endif()
else()
message(WARNING "vcpkg not found, toolchain not defined, build might fail")
endif()
project(boost_testing)
enable_language(CXX)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_LIST_DIR}" CACHE PATH "Install prefix" FORCE)
endif()
set(INSTALL_BIN_DIR "bin" CACHE PATH "Path where exe and dll will be installed")
set(INSTALL_LIB_DIR "lib" CACHE PATH "Path where lib will be installed")
set(INSTALL_INCLUDE_DIR "include" CACHE PATH "Path where headers will be installed")
set(INSTALL_CMAKE_DIR "share/${PROJECT_NAME}" CACHE PATH "Path where cmake configs will be installed")
if(MSVC)
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-D_WIN32_WINNT=0x0501)
endif()
if(UNIX AND NOT APPLE)
find_package(LibRt REQUIRED)
endif()
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
find_package(Boost COMPONENTS date_time filesystem regex serialization system REQUIRED)
include_directories(${Boost_INCLUDE_DIR})
add_executable(base64 "${CMAKE_SOURCE_DIR}/src/base64.cpp")
add_executable(parser_json "${CMAKE_SOURCE_DIR}/src/parser_json.cpp")
add_executable(parser_xml "${CMAKE_SOURCE_DIR}/src/parser_xml.cpp")
add_executable(serialization_binary "${CMAKE_SOURCE_DIR}/src/serialization_binary.cpp" "${CMAKE_SOURCE_DIR}/src/serialization_classes.hpp")
add_executable(serialization_text "${CMAKE_SOURCE_DIR}/src/serialization_text.cpp" "${CMAKE_SOURCE_DIR}/src/serialization_classes.hpp")
add_executable(udp_simple_cli "${CMAKE_SOURCE_DIR}/src/udp_simple_cli.cpp" "${CMAKE_SOURCE_DIR}/src/udp_lib.hpp" "${CMAKE_SOURCE_DIR}/src/md5.cpp" "${CMAKE_SOURCE_DIR}/src/md5.h")
add_executable(udp_simple_ser "${CMAKE_SOURCE_DIR}/src/udp_simple_ser.cpp" "${CMAKE_SOURCE_DIR}/src/udp_lib.hpp" "${CMAKE_SOURCE_DIR}/src/md5.cpp" "${CMAKE_SOURCE_DIR}/src/md5.h")
target_link_libraries(base64 ${Boost_LIBRARIES} Threads::Threads)
target_link_libraries(parser_json ${Boost_LIBRARIES} Threads::Threads)
target_link_libraries(parser_xml ${Boost_LIBRARIES} Threads::Threads)
target_link_libraries(serialization_binary ${Boost_LIBRARIES} Threads::Threads)
target_link_libraries(serialization_text ${Boost_LIBRARIES} Threads::Threads)
target_link_libraries(udp_simple_cli ${Boost_LIBRARIES} Threads::Threads)
target_link_libraries(udp_simple_ser ${Boost_LIBRARIES} Threads::Threads)
if(UNIX AND NOT APPLE)
target_link_libraries(base64 LIBRT::LIBRT )
target_link_libraries(parser_json LIBRT::LIBRT )
target_link_libraries(parser_xml LIBRT::LIBRT )
target_link_libraries(serialization_binary LIBRT::LIBRT )
target_link_libraries(serialization_text LIBRT::LIBRT )
target_link_libraries(udp_simple_cli LIBRT::LIBRT )
target_link_libraries(udp_simple_ser LIBRT::LIBRT )
endif()
install(TARGETS base64 parser_json parser_xml serialization_binary serialization_text udp_simple_cli udp_simple_ser DESTINATION "${INSTALL_BIN_DIR}")