File: CMakeLists.txt

package info (click to toggle)
obdgpslogger 0.16-1.3
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 5,160 kB
  • ctags: 7,498
  • sloc: ansic: 73,206; cpp: 2,055; php: 407; sh: 51; makefile: 4
file content (215 lines) | stat: -rw-r--r-- 6,962 bytes parent folder | download | duplicates (2)
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)

IF(COMMAND CMAKE_POLICY)
# Use old policy on ADD_DEFINITIONS and escaping
	CMAKE_POLICY(SET CMP0005 OLD)
# Use old policy to make mixing libraries with and without full paths ok
	CMAKE_POLICY(SET CMP0003 OLD)
ENDIF(COMMAND CMAKE_POLICY)

IF("${CMAKE_SYSTEM}" MATCHES "Linux")
	SET(LINUX TRUE)
ENDIF("${CMAKE_SYSTEM}" MATCHES "Linux")

PROJECT(OBDGPSLogger)

SET(OBDGPSLOGGER_MAJOR_VERSION 0)
SET(OBDGPSLOGGER_MINOR_VERSION 16)

ADD_DEFINITIONS("-DOBDGPSLOGGER_MAJOR_VERSION=${OBDGPSLOGGER_MAJOR_VERSION}")
ADD_DEFINITIONS("-DOBDGPSLOGGER_MINOR_VERSION=${OBDGPSLOGGER_MINOR_VERSION}")

# For now, assume the choices are "windows" or "posix"
IF("${CMAKE_SYSTEM}" MATCHES "Windows")
	ADD_DEFINITIONS(-DOBDPLATFORM_WINDOWS)
ELSE("${CMAKE_SYSTEM}" MATCHES "Windows")
	ADD_DEFINITIONS(-DOBDPLATFORM_POSIX)
ENDIF("${CMAKE_SYSTEM}" MATCHES "Windows")

# You probably don't want to change this
SET(OBD_CONFIG_FILENAME ".obdgpslogger")

# Default obd column names to capture
SET(OBD_DEFAULT_COLUMNS "temp,rpm,vss,maf,throttlepos" CACHE STRING "Default columns to log")

# This is the default serial port on my mac for my OBD Key
SET(OBD_DEFAULT_SERIALPORT "/dev/cu.OBDKeyPro-DevB-1" CACHE STRING "Default serial port filename")

# Only used by the UI when it launches GPSD, to add devices
SET(OBD_GPSD_CONTROL_SOCKET "/tmp/obd_gpsd_controlsock" CACHE STRING "GPSD Control Socket (Used by UI)")

# Only used by the UI when it launches GPSD, this is the default gps device
SET(OBD_DEFAULT_GPSPORT "/dev/usbserial" CACHE STRING "GPSD default device filename (Used by UI)")

# Only used by the UI when it launches GPSD, to kill it afterwards
SET(OBD_GPSD_PIDFILE "/tmp/obd_gpsd_pid" CACHE STRING "GPSD PID File (Used by UI)")

# obdftdipty saves the device in this file
SET(OBD_FTDIPTY_DEVICE "/var/run/obdftdipty.device" CACHE STRING "File used by ftdipty to describe /dev/pts entry")

# Link with this library
SET(OBD_SQLITE_INCLUDED_LIB ON CACHE BOOL "Link with included sqlite3 library. Set to off to use systemwide copy")


# OBDSim Defaults
SET(OBDSIM_ELM_VERSION_STRING "ELM327 v1.3a OBDGPSLogger" CACHE STRING "OBDSim default Version String (ATI, ATZ)")
SET(OBDSIM_ELM_DEVICE_STRING "OBDGPSLogger" CACHE STRING "OBDSim default Device String (AT@1)")


SET(OBD_DISABLE_GUI false CACHE BOOL "Disable any UI modules")
IF(NOT OBD_DISABLE_GUI)
	SET(FLTK_SKIP_OPENGL true)
	SET(FLTK_SKIP_FORMS true)
	SET(FLTK_SKIP_IMAGES true)
	FIND_PACKAGE(FLTK)
ENDIF(NOT OBD_DISABLE_GUI)

# Default database name
SET(OBD_DEFAULT_DATABASE "./obdgpslogger.db" CACHE STRING "Default database filename for all obdgpslogger modules")

SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${OBDGPSLogger_SOURCE_DIR}/cmakemodules")

SET(OBD_DISABLE_GPSD "Off" CACHE BOOL "Disable gpsd support")
IF(NOT OBD_DISABLE_GPSD)
	FIND_PACKAGE(GPSD)
	IF(GPSD_FOUND)
		INCLUDE_DIRECTORIES(${GPSD_INCLUDE_DIR})
		ADD_DEFINITIONS(-DHAVE_GPSD)
	ELSE(GPSD_FOUND)
		SET(OBD_ENABLE_GPSD "OFF" CACHE BOOL "Enable gps support using libgps" FORCE)
		MESSAGE(STATUS "Couldn't find libgps")
	ENDIF(GPSD_FOUND)
ENDIF(NOT OBD_DISABLE_GPSD)

SET(OBD_ENABLE_DBUS "OFF" CACHE BOOL "Enable dbus support")
FIND_PACKAGE(Dbus)
IF(OBD_ENABLE_DBUS)
	IF(DBUS_FOUND)
		INCLUDE_DIRECTORIES(${DBUS_INCLUDE_DIR})
		ADD_DEFINITIONS(-DHAVE_DBUS)
	ELSE(DBUS_FOUND)
		SET(OBD_ENABLE_DBUS "OFF" CACHE BOOL "Enable dbus support" FORCE)
		MESSAGE(STATUS "Couldn't find dbus")
	ENDIF(DBUS_FOUND)
ENDIF(OBD_ENABLE_DBUS)

INCLUDE(CheckSymbolExists)
INCLUDE(CheckFunctionExists)
CHECK_FUNCTION_EXISTS(ptsname_r HAVE_PTSNAME_R)
IF(HAVE_PTSNAME_R)
	ADD_DEFINITIONS(-DHAVE_PTSNAME_R)
ENDIF(HAVE_PTSNAME_R)


CONFIGURE_FILE("${OBDGPSLogger_SOURCE_DIR}/src/obdconfig.h.cmake" "${OBDGPSLogger_BINARY_DIR}/obdconfig.h")
INCLUDE_DIRECTORIES("${OBDGPSLogger_BINARY_DIR}")

SET(EXECUTABLE_OUTPUT_PATH "${OBDGPSLogger_SOURCE_DIR}/bin")

# Instead of just linking with cksqlite, link with ${CKSQLITE_LIBRARIES} to get deps
IF(OBD_SQLITE_INCLUDED_LIB)
	SET(CKSQLITE_LIBRARIES
		cksqlite
	)
ELSE(OBD_SQLITE_INCLUDED_LIB)
	SET(CKSQLITE_LIBRARIES
		sqlite3
	)
ENDIF(OBD_SQLITE_INCLUDED_LIB)

# TODO: Change this to look for necessary symbols, instead
IF("${CMAKE_SYSTEM}" MATCHES "Linux")
    SET(CKSQLITE_LIBRARIES ${CKSQLITE_LIBRARIES} pthread dl)
ENDIF("${CMAKE_SYSTEM}" MATCHES "Linux")


INCLUDE_DIRECTORIES(
	src/obdinfo/
	src/conf/
)

IF(OBD_SQLITE_INCLUDED_LIB)
	INCLUDE_DIRECTORIES(
		libs/sqlite3
	)
	ADD_SUBDIRECTORY(libs/sqlite3)
ENDIF(OBD_SQLITE_INCLUDED_LIB)

IF("${CMAKE_SYSTEM}" MATCHES "Windows")
	MESSAGE(STATUS "Logger and GUI modules not available on windows currently")
ELSE("${CMAKE_SYSTEM}" MATCHES "Windows")
	ADD_SUBDIRECTORY(src/obdcomm/)
	ADD_SUBDIRECTORY(src/logger/)
	ADD_SUBDIRECTORY(src/gui/)
ENDIF("${CMAKE_SYSTEM}" MATCHES "Windows")

ADD_SUBDIRECTORY(src/obdinfo/)
ADD_SUBDIRECTORY(src/conf/)
ADD_SUBDIRECTORY(src/analysis/)
ADD_SUBDIRECTORY(src/kml/)
ADD_SUBDIRECTORY(src/csv/)
ADD_SUBDIRECTORY(src/gpx/)
ADD_SUBDIRECTORY(src/sim/)
ADD_SUBDIRECTORY(src/repair/)
ADD_SUBDIRECTORY(src/ftdipty/)


# FILE(GLOB manfiles1 ${OBDGPSLogger_SOURCE_DIR}/man/man1/*.1)
# INSTALL(FILES ${manfiles1} DESTINATION share/man/man1)
# FILE(GLOB manfiles5 ${OBDGPSLogger_SOURCE_DIR}/man/man5/*.5)
# INSTALL(FILES ${manfiles5} DESTINATION share/man/man5)


# And now, packaging...

# Common things to every type of package
SET(CPACK_PACKAGE_DESCRIPTION "Tools to log OBD and GPS data")
SET(CPACK_PACKAGE_NAME "OBDGPSLogger")
SET(CPACK_PACKAGE_EXECUTABLES "obdgui")
SET(CPACK_PACKAGE_VERSION_MAJOR ${OBDGPSLOGGER_MAJOR_VERSION})
SET(CPACK_PACKAGE_VERSION_MINOR ${OBDGPSLOGGER_MINOR_VERSION})
SET(CPACK_PACKAGE_VERSION "${OBDGPSLOGGER_MAJOR_VERSION}.${OBDGPSLOGGER_MINOR_VERSION}")
SET(CPACK_STRIP_FILES true)
SET(CPACK_PACKAGE_CONTACT "chunky@icculus.org")
SET(CPACK_RESOURCE_FILE_LICENSE "${OBDGPSLogger_SOURCE_DIR}/COPYING")


# Always build .tar.gz and .sh files
SET(CPACK_GENERATOR "STGZ;TGZ")


IF(APPLE)
	SET(CPACK_GENERATOR "${CPACK_GENERATOR};Bundle")
	SET(CPACK_BUNDLE_ICON "${OBDGPSLogger_SOURCE_DIR}/osx/BundleIcon.icns")
	SET(CPACK_BUNDLE_NAME "OBD GPS Logger")
	SET(CPACK_BUNDLE_PLIST "${OBDGPSLogger_SOURCE_DIR}/osx/Info.plist")
	SET(CPACK_BUNDLE_STARTUP_COMMAND "${OBDGPSLogger_SOURCE_DIR}/osx/StartupCommand")

	IF(GPSD_DAEMON)
		INSTALL(PROGRAMS ${GPSD_DAEMON}
				DESTINATION sbin/)
	ENDIF(GPSD_DAEMON)
ELSE(APPLE)

	# If we can find rpmbuild, then go for it
	FIND_PROGRAM(RPMBUILD_TEST rpmbuild INTERNAL)
	IF(RPMBUILD_TEST)
		SET(CPACK_GENERATOR "${CPACK_GENERATOR};RPM")
		SET(CPACK_RPM_PACKAGE_REQUIRES "gpsd >= 2.0")
		SET(CPACK_RPM_PACKAGE_LICENSE "GPLv2+")
	ENDIF(RPMBUILD_TEST)

	# If we can find dpkg, build a .deb
	#FIND_PROGRAM(DPKG_TEST dpkg INTERNAL)
	#IF(DPKG_TEST)
		SET(CPACK_GENERATOR "${CPACK_GENERATOR};DEB")
		SET(CPACK_DEBIAN_PACKAGE_DEPENDS "gpsd (>=2.0)")
		SET(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION})
	#ENDIF(DPKG_TEST)

ENDIF(APPLE)


INCLUDE(CPack)