-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
126 lines (83 loc) · 2.79 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
# Minimum cmake verison 3.1 (required for C standard)
cmake_minimum_required (VERSION 3.1)
#########
# setup #
#########
cmake_policy( SET CMP0011 NEW )
cmake_policy( SET CMP0012 NEW ) # how if-statements work
cmake_policy( SET CMP0042 NEW ) # rpath on mac os xcmake_policy( SET CMP0048 NEW ) # version in project()
project( DL_Min_C VERSION 0.0.0 )
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set (CMAKE_INSTALL_PREFIX ${PROJECT_BINARY_DIR} CACHE PATH "Install prefix" FORCE )
endif()
# Get the dripline version
file( STRINGS "dripline_shield.json" JSON_STRINGS )
list( FILTER JSON_STRINGS INCLUDE REGEX "message" )
list( GET JSON_STRINGS 0 JSON_STRING )
string( REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" DRIPLINE_PROTOCOL_VERSION ${JSON_STRING})
message( STATUS "Dripline protocol version: ${DRIPLINE_PROTOCOL_VERSION}" )
# standard install directories
include( GNUInstallDirs )
# build shared libraries
set( BUILD_SHARED_LIBS ON )
# turn on RPATH for Mac OSX
set( CMAKE_MACOSX_RPATH ON )
# add the library install directory to the rpath
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_LIBDIR}" )
# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
set( CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE )
####################
# dripline options #
####################
set( DL_Min_C_Backend "rabbitmqc" )
option( DL_Min_C_BUILD_EXAMPLES "Flag to enable building the examples" TRUE )
option( DL_Min_C_ENABLE_TESTING "Enable build of tests" FALSE )
set( DL_Min_C_MAX_PAYLOAD_SIZE "10000" CACHE STRING "Maximum payload size (bytes)" )
# always use C11
set( CMAKE_C_STANDARD 11 )
# Process options
if( DL_Min_C_OFFLINE )
add_definitions( -DDL_OFFLINE )
else()
remove_definitions( -DDL_OFFLINE )
endif()
add_definitions( -DDL_MAX_PAYLOAD_SIZE=${DL_Min_C_MAX_PAYLOAD_SIZE} )
#########################
# External dependencies #
#########################
set( PUBLIC_EXT_LIBS )
set( PRIVATE_EXT_LIBS )
set( CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake )
##############
# rabbitmq-c #
##############
find_package( Rabbitmqc REQUIRED )
INCLUDE_DIRECTORIES(SYSTEM ${Rabbitmqc_INCLUDE_DIRS})
#####################
# Prepare for Build #
#####################
##################
# Build Dripline #
##################
add_subdirectory( library )
#if( DL_Min_C_ENABLE_EXECUTABLES )
# add_subdirectory( executables )
#endif()
############
# Examples #
############
if( DL_Min_C_BUILD_EXAMPLES )
add_subdirectory( examples )
endif()
#########
# Tests #
#########
if( DL_Min_C_ENABLE_TESTING )
add_subdirectory( testing )
endif()
##################
# Package Config #
##################
#configure_file( ${PROJECT_SOURCE_DIR}/DriplineConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/DriplineConfig.cmake @ONLY )
#pbuilder_do_package_config()