-
Notifications
You must be signed in to change notification settings - Fork 256
/
CMakeLists.txt
66 lines (48 loc) · 1.91 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
cmake_minimum_required(VERSION 2.8)
project(mqtt-client)
set(TARGETS "mqtt-client")
set(SUBDIRS "common" "mqtt" "platform" "network" "mqttclient")
# 库文件前缀
set(LIBRARY_PREFIX "mc")
# 编译debug版本
set(CMAKE_BUILD_TYPE "Debug")
# 设置版本信息
set(PROJECT_MAJOR_VERSION 1) # 架版本信息
set(PROJECT_MINOR_VERSION 2) # 主版本信息
set(PROJECT_PATCH_VERSION 0) # 次版本信息
set(PROJECT_VERSION ${PROJECT_MAJOR_VERSION}.${PROJECT_MINOR_VERSION}.${PROJECT_PATCH_VERSION})
set(PROJECT_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_ROOT_DIR}/build/bin) #设置可执行文件的输出目录
set(LIBRARY_OUTPUT_PATH ${PROJECT_ROOT_DIR}/build/lib) #设置库文件的输出目录
link_directories(${LIBRARY_OUTPUT_PATH})
set(CMAKE_C_FLAGS "-Wall")
set(CMAKE_C_FLAGS "-lpthread")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -O0 -g -no-pie -ggdb")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -O3 -DNDEBUG")
if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "-std=c++11")
set(CMAKE_CXX_FLAGS "-lpthread")
set(CMAKE_CXX_FLAGS "-Wall")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -O0 -g -no-pie -ggdb")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O3")
endif(CMAKE_COMPILER_IS_GNUCXX)
#########################################
## load cmake config and load 3rdparty ##
#########################################
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/color.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/module.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/install.cmake)
# foreach(incdir ${INCDIRS})
# include_directories(${incdir})
# endforeach()
include_directories(${PROJECT_ROOT_DIR}/config)
foreach(subdir ${SUBDIRS})
add_subdirectory(${PROJECT_ROOT_DIR}/${subdir})
endforeach()
get_module_info()
show_module_info()
install_project()
option(BUILD_EXAMPLES "Build examples" ON)
if(BUILD_EXAMPLES)
add_subdirectory(example)
endif()