-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
114 lines (104 loc) · 5.97 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
#------------------------------GPLv3------------------------------------#
#
# This file is part of SumpMonitor.
#
# SumpMonitor is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# SumpMonitor is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with SumpMonitor. If not, see <http://www.gnu.org/licenses/>.
#
#------------------------------GPLv3------------------------------------#
MACRO(use_cxx11)
IF (CMAKE_VERSION VERSION_LESS "3.1")
IF (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
SET (CMAKE_CXX_FLAGS "--std=gnu++11 ${CMAKE_CXX_FLAGS}")
ENDIF ()
ELSE ()
SET (CMAKE_CXX_STANDARD 11)
ENDIF ()
ENDMACRO(use_cxx11)
PROJECT(SumpMonitor)
FIND_PACKAGE(Qt5Core)
IF(NOT Qt5Core_FOUND)
MESSAGE(ERROR "Qt5 libraries not found")
ENDIF(NOT Qt5Core_FOUND)
FIND_PACKAGE(Qt5 REQUIRED COMPONENTS Core Sql Network Widgets)
ENABLE_LANGUAGE(C)
ENABLE_LANGUAGE(CXX)
use_cxx11()
SET(CMAKE_INCLUDE_CURRENT_DIR ON)
SET(CMAKE_AUTOMOC ON)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)
# Get the current working branch
EXECUTE_PROCESS(
COMMAND git rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# Get the latest abbreviated commit hash of the working branch
EXECUTE_PROCESS(
COMMAND git describe --always --tags
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
ADD_LIBRARY( wiringPi STATIC ${CMAKE_SOURCE_DIR}/thirdparty/wiringPi/wiringPi/wiringPi.c
${CMAKE_SOURCE_DIR}/thirdparty/wiringPi/wiringPi/wiringSerial.c
${CMAKE_SOURCE_DIR}/thirdparty/wiringPi/wiringPi/wiringShift.c
${CMAKE_SOURCE_DIR}/thirdparty/wiringPi/wiringPi/piHiPri.c
${CMAKE_SOURCE_DIR}/thirdparty/wiringPi/wiringPi/piThread.c
${CMAKE_SOURCE_DIR}/thirdparty/wiringPi/wiringPi/wiringPiSPI.c
${CMAKE_SOURCE_DIR}/thirdparty/wiringPi/wiringPi/wiringPiI2C.c
${CMAKE_SOURCE_DIR}/thirdparty/wiringPi/wiringPi/softPwm.c
${CMAKE_SOURCE_DIR}/thirdparty/wiringPi/wiringPi/softTone.c
${CMAKE_SOURCE_DIR}/thirdparty/wiringPi/wiringPi/mcp23008.c
${CMAKE_SOURCE_DIR}/thirdparty/wiringPi/wiringPi/mcp23016.c
${CMAKE_SOURCE_DIR}/thirdparty/wiringPi/wiringPi/mcp23017.c
${CMAKE_SOURCE_DIR}/thirdparty/wiringPi/wiringPi/mcp23s08.c
${CMAKE_SOURCE_DIR}/thirdparty/wiringPi/wiringPi/mcp23s17.c
${CMAKE_SOURCE_DIR}/thirdparty/wiringPi/wiringPi/sr595.c
${CMAKE_SOURCE_DIR}/thirdparty/wiringPi/wiringPi/pcf8574.c
${CMAKE_SOURCE_DIR}/thirdparty/wiringPi/wiringPi/pcf8591.c
${CMAKE_SOURCE_DIR}/thirdparty/wiringPi/wiringPi/mcp3002.c
${CMAKE_SOURCE_DIR}/thirdparty/wiringPi/wiringPi/mcp3004.c
${CMAKE_SOURCE_DIR}/thirdparty/wiringPi/wiringPi/mcp4802.c
${CMAKE_SOURCE_DIR}/thirdparty/wiringPi/wiringPi/mcp3422.c
${CMAKE_SOURCE_DIR}/thirdparty/wiringPi/wiringPi/max31855.c
${CMAKE_SOURCE_DIR}/thirdparty/wiringPi/wiringPi/max5322.c
${CMAKE_SOURCE_DIR}/thirdparty/wiringPi/wiringPi/ads1115.c
${CMAKE_SOURCE_DIR}/thirdparty/wiringPi/wiringPi/sn3218.c
${CMAKE_SOURCE_DIR}/thirdparty/wiringPi/wiringPi/bmp180.c
${CMAKE_SOURCE_DIR}/thirdparty/wiringPi/wiringPi/htu21d.c
${CMAKE_SOURCE_DIR}/thirdparty/wiringPi/wiringPi/ds18b20.c
${CMAKE_SOURCE_DIR}/thirdparty/wiringPi/wiringPi/rht03.c
${CMAKE_SOURCE_DIR}/thirdparty/wiringPi/wiringPi/drcSerial.c
${CMAKE_SOURCE_DIR}/thirdparty/wiringPi/wiringPi/drcNet.c
${CMAKE_SOURCE_DIR}/thirdparty/wiringPi/wiringPi/pseudoPins.c
${CMAKE_SOURCE_DIR}/thirdparty/wiringPi/wiringPi/wpiExtensions.c )
TARGET_INCLUDE_DIRECTORIES(wiringPi PRIVATE ${CMAKE_SOURCE_DIR}/thirdparty/wiringPi/wiringPi)
TARGET_LINK_LIBRARIES(wiringPi m pthread rt crypt)
TARGET_COMPILE_DEFINITIONS(wiringPi PRIVATE _GNU_SOURCE)
ADD_EXECUTABLE( sumpmonitor ${CMAKE_SOURCE_DIR}/src/main.cpp
${CMAKE_SOURCE_DIR}/src/notifier.cpp
${CMAKE_SOURCE_DIR}/src/monitor.cpp
${CMAKE_SOURCE_DIR}/src/ultrasonicSensor.cpp
${CMAKE_SOURCE_DIR}/src/floatSensor.cpp
${CMAKE_SOURCE_DIR}/src/etapeSensor.cpp
${CMAKE_SOURCE_DIR}/src/postsqldata.cpp
${CMAKE_SOURCE_DIR}/src/sumpdata.cpp
${CMAKE_SOURCE_DIR}/src/network.cpp
${CMAKE_SOURCE_DIR}/src/netcdfdata.cpp
${CMAKE_SOURCE_DIR}/src/calibration.cpp )
ADD_DEPENDENCIES(sumpmonitor wiringPi)
TARGET_LINK_LIBRARIES(sumpmonitor netcdf netcdf_c++ wiringPi Qt5::Core Qt5::Network Qt5::Sql Qt5::Widgets )
TARGET_INCLUDE_DIRECTORIES(sumpmonitor PRIVATE ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/thirdparty/wiringPi/wiringPi)
TARGET_COMPILE_DEFINITIONS(sumpmonitor PRIVATE GIT_VERSION="${GIT_VERSION}")