forked from crayzeewulf/libserial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
147 lines (120 loc) · 3.73 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
CMAKE_MINIMUM_REQUIRED(VERSION 3.0)
PROJECT(LibSerial)
SET(LibSerial_VERSION_MAJOR 1)
SET(LibSerial_VERSION_MINOR 0)
INCLUDE(ExternalProject)
ENABLE_TESTING()
SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
FIND_PACKAGE(Doxygen REQUIRED)
FIND_PACKAGE(Boost COMPONENTS unit_test_framework REQUIRED)
FIND_PACKAGE(PythonLibs REQUIRED)
#FIND_PACKAGE(SIP REQUIRED)
FIND_PACKAGE(Threads REQUIRED)
ADD_DEFINITIONS(
-O3
-DNDEBUG
-Wall
-Wcast-align
-Wchar-subscripts
-Wchkp
#-Wconversion
-Wdouble-promotion
-Wextra
-Wfatal-errors
-Wformat
#-Wformat-overflow
-Wformat-security
#-Winline
-Wlogical-op
-Wno-format-extra-args
-Wno-long-long
-Wpacked
-Wno-parentheses
-Wno-psabi
-Wno-variadic-macros
-Woverlength-strings
-Wpointer-arith
-Wunused-local-typedefs
-Wwrite-strings
-fstrict-aliasing
-fno-check-new
-fno-common
#-fvisibility=hidden
-fvisibility=default
-fPIC
-c
-g
-s
-pedantic
-pthread
)
# Note: Add "-m32" to the compiler flags to compile for 32 bit architectures
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11 -fms-extensions")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11 -fms-extensions")
SET(GTEST_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/gtest")
EXTERNALPROJECT_ADD(GTestExternal
PREFIX "${GTEST_PREFIX}"
URL https://github.com/google/googletest/archive/release-1.8.0.tar.gz
URL_HASH SHA1=e7e646a6204638fe8e87e165292b8dd9cd4c36ed
INSTALL_COMMAND ""
#@TODO - Pull from Github rather than prebuilt zip file.
#GIT_REPOSITORY https://github.com/google/googletest.git
#GIT_TAG master
#SOURCE_DIR "${GTEST_PREFIX}/src"
#BINARY_DIR "${GTEST_PREFIX}/build"
#CONFIGURE_COMMAND ""
#BUILD_COMMAND ""
#INSTALL_COMMAND ""
#TEST_COMMAND ""
)
SET(LIBPREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}")
SET(LIBSUFFIX "${CMAKE_STATIC_LIBRARY_SUFFIX}")
SET(GTEST_LOCATION "${GTEST_PREFIX}/src/GTestExternal-build/googlemock/gtest/")
SET(GTEST_LIBRARY "${GTEST_LOCATION}/${LIBPREFIX}gtest${LIBSUFFIX}")
SET(GTEST_MAINLIB "${GTEST_LOCATION}/${LIBPREFIX}gtest_main${LIBSUFFIX}")
ADD_LIBRARY(GTest IMPORTED STATIC GLOBAL)
SET_TARGET_PROPERTIES(GTest
PROPERTIES
IMPORTED_LOCATION "${GTEST_LIBRARY}"
IMPORTED_LINK_INTERFACE_LIBRARIES "${CMAKE_THREAD_LIBS_INIT}"
)
ADD_LIBRARY(GTestMain IMPORTED STATIC GLOBAL)
SET_TARGET_PROPERTIES(GTestMain
PROPERTIES
IMPORTED_LOCATION "${GTEST_MAINLIB}"
IMPORTED_LINK_INTERFACE_LIBRARIES "${GTEST_LIBRARY};${CMAKE_THREAD_LIBS_INIT}"
)
ADD_DEPENDENCIES(GTest GTestExternal)
ADD_DEPENDENCIES(GTestMain GTestExternal)
EXTERNALPROJECT_GET_PROPERTY(GTestExternal source_dir)
INCLUDE_DIRECTORIES(
BEFORE ${GTEST_PREFIX}/src/GTestExternal/googletest/include
${Boost_INCLUDE_DIRS}
)
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
SET(CMAKE_INSTALL_PREFIX /usr/local)
SET(CMAKE_INSTALL_MESSAGE ALWAYS)
#ADD_SUBDIRECTORY(docs)
ADD_SUBDIRECTORY(examples)
ADD_SUBDIRECTORY(sip)
ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(test)
CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/doxygen.conf.in
${CMAKE_CURRENT_BINARY_DIR}/doxygen.conf.in @ONLY
)
ADD_CUSTOM_TARGET(docs ALL
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/doxygen.conf.in
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Generating API documentation with Doxygen" VERBATIM
)
#INSTALL(
# FILES src/SerialPort.h src/SerialPortConstants.h src/SerialStream.h src/SerialStreamBuf.h
# DESTINATION "${CMAKE_INSTALL_PREFIX}/include"
# )
#INSTALL(
# TARGETS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libserial.so ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libserial_static.la
# DESTINATION "${CMAKE_INSTALL_PREFIX}/lib"
# )