forked from john30/ebusd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
executable file
·127 lines (114 loc) · 4.09 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
cmake_minimum_required(VERSION 2.8.4 FATAL_ERROR)
file(STRINGS "VERSION" VERSION)
project(ebusd)
set(PACKAGE ${CMAKE_PROJECT_NAME})
set(PACKAGE_NAME ${CMAKE_PROJECT_NAME})
set(PACKAGE_TARNAME ${CMAKE_PROJECT_NAME})
set(PACKAGE_VERSION ${VERSION})
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
set(PACKAGE_BUGREPORT "[email protected]")
set(PACKAGE_URL "https://github.com/john30/ebusd")
set(PACKAGE_PIDFILE "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/run/${PACKAGE}.pid")
set(PACKAGE_LOGFILE "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/log/${PACKAGE}.log")
execute_process(COMMAND echo -n ${VERSION}
COMMAND sed "-e" "s/^\\([0-9]*\\.[0-9]*\\).*/\\1/" "-e" "s/\\.\\([0-9]\\)\$/0\\1/" "-e" "s/\\.//"
OUTPUT_VARIABLE SCAN_VERSION)
execute_process(COMMAND git describe --always
OUTPUT_VARIABLE REVISION
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT REVISION)
execute_process(COMMAND date +p%Y%m%d
OUTPUT_VARIABLE REVISION
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif(NOT REVISION)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_FLAGS_DEBUG_INIT "-g -O0 -ggdb")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_INSTALL_PREFIX "")
include(GNUInstallDirs)
include(CheckFunctionExists)
include(CheckCXXSourceRuns)
include(CheckIncludeFile)
add_definitions(-fpic -Wall -Wno-unused-function -Wextra)
check_include_file(arpa/inet.h HAVE_ARPA_INET_H)
check_include_file(dirent.h HAVE_DIRENT_H)
check_include_file(fcntl.h HAVE_FCNTL_H)
check_include_file(netdb.h HAVE_NETDB_H)
check_include_file(poll.h HAVE_POLL_H)
check_include_file(pthread.h HAVE_PTHREAD_H)
check_include_file(sys/ioctl.h HAVE_SYS_IOCTL_H)
check_include_file(sys/select.h HAVE_SYS_SELECT_H)
check_include_file(sys/time.h HAVE_SYS_TIME_H)
check_include_file(time.h HAVE_TIME_H)
check_include_file(termios.h HAVE_TERMIOS_H)
set(CMAKE_REQUIRED_LIBRARIES pthread rt)
check_function_exists(pthread_setname_np HAVE_PTHREAD_SETNAME_NP)
check_function_exists(pselect HAVE_PSELECT)
check_function_exists(ppoll HAVE_PPOLL)
check_include_file(linux/serial.h HAVE_LINUX_SERIAL -DHAVE_LINUX_SERIAL=1)
check_include_file(dev/usb/uftdiio.h HAVE_FREEBSD_UFTDI -DHAVE_FREEBSD_UFTDI=1)
check_function_exists(argp_parse HAVE_ARGP)
if(NOT HAVE_ARGP)
find_library(LIB_ARGP argp)
if (NOT LIB_ARGP)
message(FATAL_ERROR "argp library not available")
endif(NOT LIB_ARGP)
set(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES} ${LIB_ARGP}")
endif(NOT HAVE_ARGP)
option(coverage "enable code coverage tracking." OFF)
if(NOT coverage STREQUAL OFF)
add_definitions(-coverage -O0)
message(STATUS "coverage enabled")
endif(NOT coverage STREQUAL OFF)
option(contrib "disable inclusion of contributed sources." ON)
if(contrib STREQUAL ON)
set(HAVE_CONTRIB ON)
message(STATUS "contrib enabled")
endif(contrib STREQUAL ON)
find_library(HAVE_MQTT mosquitto)
if(HAVE_MQTT)
option(mqtt "disable support for MQTT handling." ON)
if(mqtt STREQUAL ON)
message(STATUS "MQTT enabled")
else(mqtt STREQUAL ON)
unset(HAVE_MQTT)
endif(mqtt STREQUAL ON)
endif(HAVE_MQTT)
check_cxx_source_runs("
#include <stdint.h>
int main() {
union {
uint32_t i;
float f;
} test;
test.f = 0.15;
return test.i == 0x3e19999a ? 0 : 1;
}
" HAVE_DIRECT_FLOAT_FORMAT)
if(NOT HAVE_DIRECT_FLOAT_FORMAT)
check_cxx_source_runs("
#include <stdint.h>
int main() {
union {
uint32_t i;
float f;
} test;
test.f = 0.15;
return test.i == 0x9a99193e ? 0 : 1;
}
" HAVE_DIRECT_FLOAT_FORMAT_REV)
if(HAVE_DIRECT_FLOAT_FORMAT_REV)
set(HAVE_DIRECT_FLOAT_FORMAT 2)
endif(HAVE_DIRECT_FLOAT_FORMAT_REV)
endif(NOT HAVE_DIRECT_FLOAT_FORMAT)
add_definitions(-D_GNU_SOURCE -DHAVE_CONFIG_H -DSYSCONFDIR="${CMAKE_INSTALL_FULL_SYSCONFDIR}" -DLOCALSTATEDIR="${CMAKE_INSTALL_FULL_LOCALSTATEDIR}")
configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${ebusd_SOURCE_DIR}/src)
if(BUILD_TESTING)
enable_testing()
endif(BUILD_TESTING)
add_subdirectory(src/ebusd)
add_subdirectory(src/lib/utils)
add_subdirectory(src/lib/ebus)
add_subdirectory(src/tools)