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