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