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