Add gitreview file for Optimistic Octopus branch
[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 # Default to off
48 set(WITH_FEATURE_J1939 OFF CACHE BOOL "")
49
50 execute_process(COMMAND ls $ENV{PKG_CONFIG_SYSROOT_DIR}/usr/include/linux/can/j1939.h RESULT_VARIABLE result OUTPUT_QUIET ERROR_QUIET)
51
52 if(result)
53         message("J1939 header not detected!")
54         # Over-ride cached value
55         set(WITH_FEATURE_J1939 OFF)
56 else()
57         message("J1939 header detected")
58         # Check cache to allow over-ride
59         set(WITH_FEATURE_J1939 ON CACHE BOOL "")
60         # Define name for ECU
61         set(J1939_NAME_ECU 0x1239 CACHE STRING "")
62 endif()
63 if(WITH_FEATURE_J1939)
64         message("Feature J1939 enabled")
65         add_definitions(-DUSE_FEATURE_J1939)
66         add_definitions(-DJ1939_NAME_ECU=${J1939_NAME_ECU})
67 else()
68         message("Feature J1939 disabled")
69 endif()
70
71 # Activate ISO TP
72 # Need module in kernel
73 # --------------
74
75 # Default to off
76 set(WITH_FEATURE_ISOTP OFF CACHE BOOL "")
77
78 execute_process(COMMAND ls $ENV{PKG_CONFIG_SYSROOT_DIR}/usr/include/linux/can/isotp.h RESULT_VARIABLE result2 OUTPUT_QUIET ERROR_QUIET)
79
80 if(result2)
81         message("ISO TP header not detected!")
82         # Over-ride cached value
83         set(WITH_FEATURE_ISOTP OFF)
84 else()
85         message("ISO TP header detected")
86         # Check cache to allow over-ride
87         set(WITH_FEATURE_ISOTP ON CACHE BOOL "")
88 endif()
89 if(WITH_FEATURE_ISOTP)
90         message("Feature ISOTP enabled")
91         add_definitions(-DUSE_FEATURE_ISOTP)
92 else()
93         message("Feature ISO TP disabled")
94 endif()
95
96
97
98 # Kernel selection if needed. You can choose between a
99 # mandatory version to impose a minimal version.
100 # Or check Kernel minimal version and just print a Warning
101 # about missing features and define a preprocessor variable
102 # to be used as preprocessor condition in code to disable
103 # incompatibles features. Preprocessor define is named
104 # KERNEL_MINIMAL_VERSION_OK.
105 #
106 # NOTE*** FOR NOW IT CHECKS KERNEL Yocto environment and
107 # Yocto SDK Kernel version.
108 # -----------------------------------------------
109 #set (kernel_mandatory_version 4.8)
110 set (kernel_minimal_version 4.8)
111
112 # Compiler selection if needed. Impose a minimal version.
113 # -----------------------------------------------
114 set (gcc_minimal_version 4.9)
115
116 # PKG_CONFIG required packages
117 # -----------------------------
118 set (PKG_REQUIRED_LIST
119         json-c
120         libsystemd>=222
121         afb-daemon
122         afb-helpers
123         appcontroller
124 )
125
126 # Prefix path where will be installed the files
127 # Default: /usr/local (need root permission to write in)
128 # ------------------------------------------------------
129 set(INSTALL_PREFIX $ENV{HOME}/opt)
130
131 # Customize link option
132 # -----------------------------
133 list (APPEND link_libraries -pthread)
134
135 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
136
137 # Compilation options definition
138 # Use CMake generator expressions to specify only for a specific language
139 # Values are prefilled with default options that is currently used.
140 # Either separate options with ";", or each options must be quoted separately
141 # DO NOT PUT ALL OPTION QUOTED AT ONCE , COMPILATION COULD FAILED !
142 # ----------------------------------------------------------------------------
143 set(COMPILE_OPTIONS
144  -Wall
145  -Wextra
146  -Wconversion
147  -Wno-unused-parameter
148  -Wno-sign-compare
149  -Wno-sign-conversion
150  -Werror=maybe-uninitialized
151  -ffunction-sections
152  -fdata-sections
153  -fPIC
154  -DPB_FIELD_16BIT
155  CACHE STRING "Compilation flags")
156 #set(C_COMPILE_OPTIONS "" CACHE STRING "Compilation flags for C language.")
157 set(CXX_COMPILE_OPTIONS -pthread CACHE STRING "Compilation flags for C++ language.")
158 #set(PROFILING_COMPILE_OPTIONS
159 # -g
160 # -O0
161 # -pg
162 # -Wp,-U_FORTIFY_SOURCE
163 # CACHE STRING "Compilation flags for PROFILING build type.")
164 #set(DEBUG_COMPILE_OPTIONS
165 # -Og
166 # -g
167 # -ggdb
168 # -D_FORTIFY_SOURCE=2
169 # CACHE STRING "Compilation flags for DEBUG build type.")
170 #set(COVERAGE_COMPILE_OPTIONS
171 # -g
172 # -O2
173 # --coverage
174 # CACHE STRING "Compilation flags for COVERAGE build type.")
175 #set(RELEASE_COMPILE_OPTIONS
176 # -O2
177 # -D_FORTIFY_SOURCE=2
178 # CACHE STRING "Compilation flags for RELEASE build type.")
179
180 add_definitions(-DAFB_BINDING_VERSION=3)
181
182 # Optional location for config.xml.in
183 # -----------------------------------
184 #set(WIDGET_ICON "\"${CMAKE_SOURCE_DIR}conf.d/wgt/${PROJECT_ICON}\"" CACHE PATH "Path to the widget icon")
185 set(WIDGET_CONFIG_TEMPLATE "${CMAKE_SOURCE_DIR}/conf.d/wgt/config.xml.in" CACHE PATH "Path to widget config file template (config.xml.in)")
186
187 # Mandatory widget Mimetype specification of the main unit
188 # --------------------------------------------------------------------------
189 # Choose between :
190 #- text/html : HTML application,
191 #       content.src designates the home page of the application
192 #
193 #- application/vnd.agl.native : AGL compatible native,
194 #       content.src designates the relative path of the binary.
195 #
196 # - application/vnd.agl.service: AGL service, content.src is not used.
197 #
198 #- ***application/x-executable***: Native application,
199 #       content.src designates the relative path of the binary.
200 #       For such application, only security setup is made.
201 #
202 set(WIDGET_TYPE application/vnd.agl.service)
203
204 # Mandatory Widget entry point file of the main unit
205 # --------------------------------------------------------------
206 # This is the file that will be executed, loaded,
207 # at launch time by the application framework.
208 #
209 set(WIDGET_ENTRY_POINT lib/afb-low-can-binding.so)
210
211 # Optional dependencies order
212 # ---------------------------
213 #set(EXTRA_DEPENDENCIES_ORDER)
214
215 # Optional Extra global include path
216 # -----------------------------------
217 #set(EXTRA_INCLUDE_DIRS)
218
219 # Optional extra libraries
220 # -------------------------
221 #set(EXTRA_LINK_LIBRARIES)
222
223 # Optional force binding Linking flag
224 # ------------------------------------
225 # set(BINDINGS_LINK_FLAG LinkOptions )
226
227 # Optional force package prefix generation, like widget
228 # -----------------------------------------------------
229 # set(PKG_PREFIX DestinationPath)
230
231 # Optional Application Framework security token
232 # and port use for remote debugging.
233 #------------------------------------------------------------
234 set(AFB_TOKEN   ""     CACHE STRING "Default binder security token")
235 set(AFB_REMPORT "1234" CACHE STRING "Default binder listening port")
236
237 # Print a helper message when every thing is finished
238 # ----------------------------------------------------
239 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")
240 set(PACKAGE_MESSAGE "Install widget file using in the target : afm-util install ${PROJECT_NAME}.wgt")
241
242
243 # Add Controller config
244 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")
245 add_definitions(-DCONTROL_CONFIG_PATH="${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}/etc:${CMAKE_BINARY_DIR}/package/etc:${CMAKE_BINARY_DIR}/package-test/")
246
247
248
249 # Optional schema validator about now only XML, LUA and JSON
250 # are supported
251 #------------------------------------------------------------
252 #set(LUA_CHECKER "luac" "-p" CACHE STRING "LUA compiler")
253 #set(XML_CHECKER "xmllint" CACHE STRING "XML linter")
254 #set(JSON_CHECKER "json_verify" CACHE STRING "JSON linter")
255
256 # This include is mandatory and MUST happens at the end
257 # of this file, else you expose you to unexpected behavior
258 #
259 # This CMake module could be found at the following url:
260 # https://gerrit.automotivelinux.org/gerrit/#/admin/projects/src/cmake-apps-module
261 # -----------------------------------------------------------
262 include(CMakeAfbTemplates)