-
Notifications
You must be signed in to change notification settings - Fork 57
/
CMakeLists.txt
62 lines (52 loc) · 1.89 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
cmake_minimum_required(VERSION 3.10)
project(foundation CXX)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CXX_FLAGS
-O2
-std=c++11
-rdynamic
-lpthread
-fPIC
-lstdc++
-pipe
)
if (WIN32)
add_definitions(-D__win__)
add_definitions(-D__use_iocp__)
endif ()
if(CMAKE_BUILD_BITS EQUAL 32)
list(APPEND CXX_FLAGS "-m32")
else()
list(APPEND CXX_FLAGS "-m64")
endif()
include_directories(${PROJECT_SOURCE_DIR})
aux_source_directory(${PROJECT_SOURCE_DIR}/foundation/alloter src_files)
aux_source_directory(${PROJECT_SOURCE_DIR}/foundation/buffer src_files)
aux_source_directory(${PROJECT_SOURCE_DIR}/foundation/log src_files)
aux_source_directory(${PROJECT_SOURCE_DIR}/foundation/os src_files)
aux_source_directory(${PROJECT_SOURCE_DIR}/foundation/network src_files)
aux_source_directory(${PROJECT_SOURCE_DIR}/foundation/structure src_files)
aux_source_directory(${PROJECT_SOURCE_DIR}/foundation/thread src_files)
aux_source_directory(${PROJECT_SOURCE_DIR}/foundation/timer src_files)
aux_source_directory(${PROJECT_SOURCE_DIR}/foundation/util src_files)
IF (WIN32)
aux_source_directory(${PROJECT_SOURCE_DIR}/foundation/network/win src_files)
aux_source_directory(${PROJECT_SOURCE_DIR}/foundation/os/win src_files)
ELSEIF (APPLE)
aux_source_directory(${PROJECT_SOURCE_DIR}/foundation/network/posix src_files)
aux_source_directory(${PROJECT_SOURCE_DIR}/foundation/os/posix src_files)
ELSEIF (UNIX)
aux_source_directory(${PROJECT_SOURCE_DIR}/foundation/network/posix src_files)
aux_source_directory(${PROJECT_SOURCE_DIR}/foundation/os/posix src_files)
ENDIF ()
# output
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
add_library(${PROJECT_NAME} STATIC ${src_files})
# use whit cmake -DWITH_TEST=ON
option(WITH_TEST "build unit test executable file." OFF)
if(WITH_TEST)
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
add_subdirectory(third/gtest)
add_subdirectory(utest)
endif(WITH_TEST)