-
-
Notifications
You must be signed in to change notification settings - Fork 341
/
Copy pathCMakeLists.txt
70 lines (59 loc) · 2.48 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
#***************************************************************************
# @file CMakeLists.txt
# @author itas109 ([email protected]) \n\n
# Blog : https://blog.csdn.net/itas109 \n
# Github : https://github.com/itas109 \n
# Gitee : https://gitee.com/itas109 \n
# QQ Group : 129518033
# @brief Lightweight cross-platform serial port library based on C++
# @copyright The CSerialPort is Copyright (C) 2014 itas109 <[email protected]>.
# You may use, copy, modify, and distribute the CSerialPort, under the terms
# of the LICENSE file.
############################################################################
cmake_minimum_required(VERSION 2.8.12)
project(CSerialPort LANGUAGES CXX)
# set output directory
if (CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
endif()
# set build tpye
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
option(CSERIALPORT_BUILD_EXAMPLES "Build CSerialPort examples" ON)
option(CSERIALPORT_BUILD_DOC "Build CSerialPort Doc" OFF)
option(CSERIALPORT_BUILD_TEST "Build CSerialPort Test" OFF)
# only build library if add CSeiralPort as subdirectory
if (NOT CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
set(CSERIALPORT_BUILD_EXAMPLES OFF)
set(CSERIALPORT_BUILD_DOC OFF)
set(CSERIALPORT_BUILD_TEST OFF)
endif()
message(STATUS "CSerialPort CMake Info")
message(STATUS "=======================================================")
message(STATUS " Operation System : ${CMAKE_SYSTEM}")
message(STATUS " CPU Architecture : ${CMAKE_SYSTEM_PROCESSOR}")
message(STATUS " Build Type : ${CMAKE_BUILD_TYPE}")
message(STATUS " Shared Library : ${BUILD_SHARED_LIBS}")
message(STATUS " Build Examples : ${CSERIALPORT_BUILD_EXAMPLES}")
message(STATUS " Build Doc : ${CSERIALPORT_BUILD_DOC}")
message(STATUS " Build Test : ${CSERIALPORT_BUILD_TEST}")
message(STATUS "=======================================================")
# libcserialport
add_subdirectory(lib)
# examples
if (CSERIALPORT_BUILD_EXAMPLES)
add_subdirectory(examples)
endif ()
# test
if (CSERIALPORT_BUILD_TEST)
add_subdirectory(test)
endif ()
# doc
if (CSERIALPORT_BUILD_DOC)
add_subdirectory(doc)
endif ()