-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
CMakeLists.txt
124 lines (105 loc) · 4.07 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
set_property(GLOBAL PROPERTY USE_FOLDERS On)
option(BUILD_TOOLS_ONLY "help string describing option" OFF)
option(BUILD_MID_WARE_SDK "help string describing option" OFF)
cmake_minimum_required(VERSION 2.8)
macro(link_NFSDK projName)
add_dependencies(${projName} NFNetPlugin NFCore NFMessageDefine)
target_link_libraries(${projName} NFCore NFMessageDefine NFNetPlugin)
endmacro(link_NFSDK)
project(NoahFrame)
#OSX上强制生成so后缀的动态库而不是dylib后缀动态库
if (APPLE)
SET(CMAKE_SHARED_LIBRARY_SUFFIX ".so")
endif(APPLE)
set(SolutionDir ${PROJECT_SOURCE_DIR})
if( CMAKE_BUILD_TYPE STREQUAL "Debug" )
set(NFOutPutDir ${PROJECT_SOURCE_DIR}/_Out/Debug)
else()
set(NFOutPutDir ${PROJECT_SOURCE_DIR}/_Out/Release)
endif()
message("NFOutPutDir:${NFOutPutDir}")
# message(STATUS "SolutionDir=" ${SolutionDir})
if (APPLE)
include_directories(
${SolutionDir}
${SolutionDir}/Dependencies/
${SolutionDir}/Dependencies/NFMessageDefine/
${SolutionDir}/NFComm/NFPluginModule/
${SolutionDir}/Dependencies/hiredis/hiredis_linux
${SolutionDir}/Dependencies/vcpkg/installed/x64-osx/include/
${SolutionDir}/Dependencies/vcpkg/installed/x64-osx/include/SDL2
${SolutionDir}/Dependencies/vcpkg/installed/x64-osx/include/google/protobuf/
${SolutionDir}/Dependencies/vcpkg/installed/x64-osx/include/google/protobuf/src/
)
elseif(UNIX)
include_directories(
${SolutionDir}
${SolutionDir}/Dependencies/
${SolutionDir}/Dependencies/NFMessageDefine/
${SolutionDir}/NFComm/NFPluginModule/
${SolutionDir}/Dependencies/hiredis/hiredis_linux
${SolutionDir}/Dependencies/vcpkg/installed/x64-linux/include/
${SolutionDir}/Dependencies/vcpkg/installed/x64-linux/include/SDL2
${SolutionDir}/Dependencies/vcpkg/installed/x64-linux/include/google/protobuf/
${SolutionDir}/Dependencies/vcpkg/installed/x64-linux/include/google/protobuf/src/
)
else()
include_directories(
${SolutionDir}
${SolutionDir}/Dependencies/
${SolutionDir}/Dependencies/NFMessageDefine/
${SolutionDir}/NFComm/NFPluginModule/
${SolutionDir}/Dependencies/hiredis/hiredis_win
${SolutionDir}/Dependencies/vcpkg/installed/x64-windows-static/include/
${SolutionDir}/Dependencies/vcpkg/installed/x64-windows-static/include/SDL2
${SolutionDir}/Dependencies/vcpkg/installed/x64-windows-static/include/google/protobuf/
${SolutionDir}/Dependencies/vcpkg/installed/x64-windows-static/include/google/protobuf/src/
)
endif()
#message("Build Type:"${CMAKE_BUILD_TYPE} ${CMAKE_CXX_FLAGS})
if(UNIX)
if( CMAKE_BUILD_TYPE STREQUAL "Debug" )
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -O0 -Wall -g -ggdb -DDEBUG -fPIC")
else()
set(CMAKE_BUILD_TYPE "Release")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -std=c++17 -O3 -Wall")
endif()
set(LDFLAGS "$ENV{LDFLAGS} -stdlib=libc++")
#MAC不需要这一行
if (NOT APPLE)
add_definitions(-std=c++17)
endif()
else()
SET ( CMAKE_CXX_FLAGS "-D_X64 -D_WINDOWS /EHsc" )
include_directories(${SolutionDir}/Dependencies/libevent/WIN32-Code/)
endif()
if( CMAKE_BUILD_TYPE STREQUAL "Debug" )
set(DependenciesLibPath ${SolutionDir}/Dependencies/lib ${SolutionDir}/_Out/Debug/ ${SolutionDir}/Dependencies/lib/Debug)
else()
set(DependenciesLibPath ${SolutionDir}/Dependencies/lib ${SolutionDir}/_Out/Release/ ${SolutionDir}/Dependencies/lib/Release)
endif()
link_directories(${DependenciesLibPath})
if(${BUILD_TOOLS_ONLY} STREQUAL "ON")
message("Build Tools Only")
add_subdirectory(NFTools)
elseif(${BUILD_MID_WARE_SDK} STREQUAL "ON")
add_subdirectory(NFTools)
message("Build SDK & MIDWARE")
add_subdirectory(Dependencies)
add_subdirectory(NFComm)
add_subdirectory(NFServer)
add_subdirectory(Tutorial)
add_subdirectory(NFExamples)
add_subdirectory(../NFMidWare NFMidWare)
add_subdirectory(../NFComm/NFMessageDefineEx NFComm/NFMessageDefineEx)
add_subdirectory(../NFComm/NFServerEx NFComm/NFServerEx)
else()
message("Build SDK")
add_subdirectory(Dependencies)
add_subdirectory(NFComm)
add_subdirectory(NFServer)
add_subdirectory(Tutorial)
add_subdirectory(NFExamples)
endif()