examples: updates
[apps/agl-service-can-low-level.git] / conf.d / cmake / config.cmake
1 ###########################################################################
2 # Copyright 2015, 2016, 2017 IoT.bzh
3 #
4 # author: Fulup Ar Foll <fulup@iot.bzh>
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 #     http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 ###########################################################################
18
19 # Project Info
20 # ------------------
21 set(PROJECT_NAME agl-service-can-low-level)
22 set(PROJECT_PRETTY_NAME "Low level CAN binding")
23 set(PROJECT_DESCRIPTION "Expose CAN Low Level APIs through AGL Framework")
24 set(PROJECT_URL "https://gerrit.automotivelinux.org/gerrit/apps/agl-service-can-low-level")
25 set(PROJECT_ICON "icon.png")
26 set(PROJECT_AUTHOR "Romain Forlot")
27 set(PROJECT_AUTHOR_MAIL "romain.forlot@iot.bzh")
28 set(PROJECT_LICENSE "APL2.0")
29 set(PROJECT_LANGUAGES "C;CXX")
30 set(API_NAME "low-can")
31
32 # Where are stored the project configuration files
33 # relative to the root project directory
34 set(PROJECT_CMAKE_CONF_DIR "conf.d")
35
36 # Which directories inspect to find CMakeLists.txt target files
37 # set(PROJECT_SRC_DIR_PATTERN "*")
38
39 # Compilation Mode (DEBUG, RELEASE)
40 # ----------------------------------
41 set(BUILD_TYPE "DEBUG" CACHE STRING "Default Build variant chosen. (Overwritten by cli if given)")
42
43 # Activate J1939
44 # Need module in kernel
45 # --------------
46
47 execute_process(COMMAND ls /usr/include/linux/can/j1939.h RESULT_VARIABLE result OUTPUT_QUIET ERROR_QUIET)
48
49 if(result)
50         message("Feature J1939 disabled")
51         set(WITH_FEATURE_J1939 OFF)
52 else()
53         message("Feature J1939 enabled")
54         set(WITH_FEATURE_J1939 ON)
55         add_definitions(-DUSE_FEATURE_J1939)
56         # Define name for ECU
57         set(J1939_NAME_ECU 0x1239)
58         add_definitions(-DJ1939_NAME_ECU=${J1939_NAME_ECU})
59 endif()
60
61 # Activate ISO TP
62 # Need module in kernel
63 # --------------
64
65 execute_process(COMMAND ls /usr/include/linux/can/isotp.h RESULT_VARIABLE result2 OUTPUT_QUIET ERROR_QUIET)
66
67 if(result2)
68     message("Feature ISO TP disabled")
69     set(WITH_FEATURE_ISOTP OFF)
70 else()
71     message("Feature ISOTP enabled")
72     set(WITH_FEATURE_ISOTP ON)
73     add_definitions(-DUSE_FEATURE_ISOTP)
74 endif()
75
76
77
78 # Kernel selection if needed. You can choose between a
79 # mandatory version to impose a minimal version.
80 # Or check Kernel minimal version and just print a Warning
81 # about missing features and define a preprocessor variable
82 # to be used as preprocessor condition in code to disable
83 # incompatibles features. Preprocessor define is named
84 # KERNEL_MINIMAL_VERSION_OK.
85 #
86 # NOTE*** FOR NOW IT CHECKS KERNEL Yocto environment and
87 # Yocto SDK Kernel version.
88 # -----------------------------------------------
89 #set (kernel_mandatory_version 4.8)
90 set (kernel_minimal_version 4.8)
91
92 # Compiler selection if needed. Impose a minimal version.
93 # -----------------------------------------------
94 set (gcc_minimal_version 4.9)
95
96 # PKG_CONFIG required packages
97 # -----------------------------
98 set (PKG_REQUIRED_LIST
99         json-c
100         libsystemd>=222
101         afb-daemon
102         afb-helpers
103         appcontroller
104 )
105
106 # Prefix path where will be installed the files
107 # Default: /usr/local (need root permission to write in)
108 # ------------------------------------------------------
109 set(INSTALL_PREFIX $ENV{HOME}/opt)
110
111 # Customize link option
112 # -----------------------------
113 list (APPEND link_libraries -pthread)
114
115 # Compilation options definition
116 # Use CMake generator expressions to specify only for a specific language
117 # Values are prefilled with default options that is currently used.
118 # Either separate options with ";", or each options must be quoted separately
119 # DO NOT PUT ALL OPTION QUOTED AT ONCE , COMPILATION COULD FAILED !
120 # ----------------------------------------------------------------------------
121 set(COMPILE_OPTIONS
122  -Wall
123  -Wextra
124  -Wconversion
125  -Wno-unused-parameter
126  -Wno-sign-compare
127  -Wno-sign-conversion
128  -Werror=maybe-uninitialized
129  -ffunction-sections
130  -fdata-sections
131  -fPIC
132  -DPB_FIELD_16BIT
133  CACHE STRING "Compilation flags")
134 #set(C_COMPILE_OPTIONS "" CACHE STRING "Compilation flags for C language.")
135 set(CXX_COMPILE_OPTIONS -pthread CACHE STRING "Compilation flags for C++ language.")
136 #set(PROFILING_COMPILE_OPTIONS
137 # -g
138 # -O0
139 # -pg
140 # -Wp,-U_FORTIFY_SOURCE
141 # CACHE STRING "Compilation flags for PROFILING build type.")
142 #set(DEBUG_COMPILE_OPTIONS
143 # -Og
144 # -g
145 # -ggdb
146 # -D_FORTIFY_SOURCE=2
147 # CACHE STRING "Compilation flags for DEBUG build type.")
148 #set(COVERAGE_COMPILE_OPTIONS
149 # -g
150 # -O2
151 # --coverage
152 # CACHE STRING "Compilation flags for COVERAGE build type.")
153 #set(RELEASE_COMPILE_OPTIONS
154 # -O2
155 # -D_FORTIFY_SOURCE=2
156 # CACHE STRING "Compilation flags for RELEASE build type.")
157
158 add_definitions(-DAFB_BINDING_VERSION=3)
159
160 # Optional location for config.xml.in
161 # -----------------------------------
162 #set(WIDGET_ICON "\"${CMAKE_SOURCE_DIR}conf.d/wgt/${PROJECT_ICON}\"" CACHE PATH "Path to the widget icon")
163 set(WIDGET_CONFIG_TEMPLATE "${CMAKE_SOURCE_DIR}/conf.d/wgt/config.xml.in" CACHE PATH "Path to widget config file template (config.xml.in)")
164
165 # Mandatory widget Mimetype specification of the main unit
166 # --------------------------------------------------------------------------
167 # Choose between :
168 #- text/html : HTML application,
169 #       content.src designates the home page of the application
170 #
171 #- application/vnd.agl.native : AGL compatible native,
172 #       content.src designates the relative path of the binary.
173 #
174 # - application/vnd.agl.service: AGL service, content.src is not used.
175 #
176 #- ***application/x-executable***: Native application,
177 #       content.src designates the relative path of the binary.
178 #       For such application, only security setup is made.
179 #
180 set(WIDGET_TYPE application/vnd.agl.service)
181
182 # Mandatory Widget entry point file of the main unit
183 # --------------------------------------------------------------
184 # This is the file that will be executed, loaded,
185 # at launch time by the application framework.
186 #
187 set(WIDGET_ENTRY_POINT lib/afb-low-can.so)
188
189 # Optional dependencies order
190 # ---------------------------
191 #set(EXTRA_DEPENDENCIES_ORDER)
192
193 # Optional Extra global include path
194 # -----------------------------------
195 #set(EXTRA_INCLUDE_DIRS)
196
197 # Optional extra libraries
198 # -------------------------
199 #set(EXTRA_LINK_LIBRARIES)
200
201 # Optional force binding Linking flag
202 # ------------------------------------
203 # set(BINDINGS_LINK_FLAG LinkOptions )
204
205 # Optional force package prefix generation, like widget
206 # -----------------------------------------------------
207 # set(PKG_PREFIX DestinationPath)
208
209 # Optional Application Framework security token
210 # and port use for remote debugging.
211 #------------------------------------------------------------
212 set(AFB_TOKEN   ""     CACHE STRING "Default binder security token")
213 set(AFB_REMPORT "1234" CACHE STRING "Default binder listening port")
214
215 # Print a helper message when every thing is finished
216 # ----------------------------------------------------
217 set(CLOSING_MESSAGE "Typical binding launch: afb-daemon --port=${AFB_REMPORT} --workdir=${CMAKE_BINARY_DIR}/package --ldpaths=lib --roothttp=htdocs  --token=\"${AFB_TOKEN}\" --tracereq=common --verbose")
218 set(PACKAGE_MESSAGE "Install widget file using in the target : afm-util install ${PROJECT_NAME}.wgt")
219
220
221 # Add Controller config
222 add_definitions(-DCONTROL_PLUGIN_PATH="${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}/lib/plugins:${CMAKE_BINARY_DIR}/package/lib/plugins:${CMAKE_BINARY_DIR}/package/var:${CMAKE_BINARY_DIR}/package-test")
223 add_definitions(-DCONTROL_CONFIG_PATH="${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}/etc:${CMAKE_BINARY_DIR}/package/etc:${CMAKE_BINARY_DIR}/package-test/")
224
225
226
227 # Optional schema validator about now only XML, LUA and JSON
228 # are supported
229 #------------------------------------------------------------
230 #set(LUA_CHECKER "luac" "-p" CACHE STRING "LUA compiler")
231 #set(XML_CHECKER "xmllint" CACHE STRING "XML linter")
232 #set(JSON_CHECKER "json_verify" CACHE STRING "JSON linter")
233
234 # This include is mandatory and MUST happens at the end
235 # of this file, else you expose you to unexpected behavior
236 #
237 # This CMake module could be found at the following url:
238 # https://gerrit.automotivelinux.org/gerrit/#/admin/projects/src/cmake-apps-module
239 # -----------------------------------------------------------
240 include(CMakeAfbTemplates)