-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
65 lines (55 loc) · 1.99 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
cmake_minimum_required(VERSION 2.8)
project(Messenger)
set(SOURCE_DIR "source")
set(CLIENT_SOURCE_DIR "${SOURCE_DIR}/client")
set(SERVER_SOURCE_DIR "${SOURCE_DIR}/server")
set(LIB_SOURCE_DIR "${SOURCE_DIR}/lib")
set(INCLUDE_DIR "include")
set(SERVER_INCLUDE_DIR "${INCLUDE_DIR}/server_headers")
set(CLIENT_INCLUDE_DIR "${INCLUDE_DIR}/client_headers")
set(LIB_INCLUDE_DIR "${INCLUDE_DIR}/lib_headers")
set(Boost_USE_STATIC_LIBS ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall -g")
find_package(Boost COMPONENTS system REQUIRED)
find_package(OpenSSL)
file(GLOB_RECURSE CLIENT_SOURCE_FILES
"${CLIENT_SOURCE_DIR}/*.cpp"
"${INCLUDE_DIR}/*.h"
"${INCLUDE_DIR}/*.hpp"
)
file(GLOB_RECURSE SERVER_SOURCE_FILES
"${SERVER_SOURCE_DIR}/*.cpp"
"${INCLUDE_DIR}/*.h"
"${INCLUDE_DIR}/*.hpp"
)
file(GLOB_RECURSE LIB_SOURCE_FILES
"${LIB_SOURCE_DIR}/*.cpp"
"${INCLUDE_DIR}/*.h"
"${INCLUDE_DIR}/*.hpp"
)
include_directories(${INCLUDE_DIR})
include_directories(${SERVER_INCLUDE_DIR})
include_directories(${CLIENT_INCLUDE_DIR})
include_directories(${LIB_INCLUDE_DIR})
include_directories(${Boost_INCLUDE_DIRS})
add_library(Lib STATIC ${LIB_SOURCE_FILES})
add_executable(Main ${SOURCE_DIR}/main.cpp)
add_executable(Client ${CLIENT_SOURCE_FILES})
add_executable(Server ${SERVER_SOURCE_FILES})
set_target_properties( Server Client Main
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin"
)
set_target_properties( Lib
PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin"
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin"
)
add_custom_target(_clean COMMAND rm -f CMakeCache.txt cmake_install.cmake
COMMAND rm -rf CMakeFiles/*
COMMAND rmdir CMakeFiles
COMMAND rm -f Makefile
CLION_EXE_DIR=${PROJECT_BINARY_DIR})
target_link_libraries(Client ${Boost_LIBRARIES} Lib pthread boost_thread ncurses)
target_link_libraries(Server ${Boost_LIBRARIES} Lib pthread boost_thread ssl crypto)
target_link_libraries(Main ${Boost_LIBRARIES} Lib pthread boost_thread)