Cleaning
[apps/low-level-can-service.git] / cmake / cmake.d / 02-variables.cmake
1 ###########################################################################
2 # Copyright 2015, 2016, 2017 IoT.bzh
3 #
4 # author: Fulup Ar Foll <fulup@iot.bzh>
5 # contrib: Romain Forlot <romain.forlot@iot.bzh>
6 #
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
10 #
11 #     http://www.apache.org/licenses/LICENSE-2.0
12 #
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 ###########################################################################
19
20
21 #--------------------------------------------------------------------------
22 #  WARNING:
23 #     Do not change this cmake template
24 #     Customise your preferences in "./etc/config.cmake"
25 #--------------------------------------------------------------------------
26
27 # Get colorized message output non Windows OS. You know bash ? :)
28 if(NOT WIN32)
29         string(ASCII 27 Esc)
30         set(ColourReset "${Esc}[m")
31         set(ColourBold  "${Esc}[1m")
32         set(Red         "${Esc}[31m")
33         set(Green       "${Esc}[32m")
34         set(Yellow      "${Esc}[33m")
35         set(Blue        "${Esc}[34m")
36         set(Magenta     "${Esc}[35m")
37         set(Cyan        "${Esc}[36m")
38         set(White       "${Esc}[37m")
39         set(BoldRed     "${Esc}[1;31m")
40         set(BoldGreen   "${Esc}[1;32m")
41         set(BoldYellow  "${Esc}[1;33m")
42         set(BoldBlue    "${Esc}[1;34m")
43         set(BoldMagenta "${Esc}[1;35m")
44         set(BoldCyan    "${Esc}[1;36m")
45         set(BoldWhite   "${Esc}[1;37m")
46 endif()
47
48 # Native packaging name
49 set(NPKG_PROJECT_NAME agl-${PROJECT_NAME})
50
51 string(REGEX MATCH "[0-9]+" LINUX_VERSION_CODE ${LINUX_VERSION_CODE_LINE})
52 math(EXPR a "${LINUX_VERSION_CODE} >> 16")
53 math(EXPR b "(${LINUX_VERSION_CODE} >> 8) & 255")
54 math(EXPR c "(${LINUX_VERSION_CODE} & 255)")
55
56 set(KERNEL_VERSION "${a}.${b}.${c}")
57
58 # Include project configuration
59 # ------------------------------
60 project(${PROJECT_NAME} VERSION ${PROJECT_VERSION} LANGUAGES ${PROJECT_LANGUAGES})
61 set(PROJECT_LIBDIR "\"${CMAKE_SOURCE_DIR}/libs\"" CACHE PATH "Subpath to libraries")
62 set(PROJECT_RESOURCES "\"${CMAKE_SOURCE_DIR}/data\"" CACHE PATH "Subpath to data")
63
64 set(AFB_TOKEN   ""      CACHE STRING "Default AFB_TOKEN")
65 set(AFB_REMPORT "1234" CACHE STRING "Default AFB_TOKEN")
66 # Kept for compatibility
67 set(AFB_TOKEN   ""      CACHE PATH "Default AFB_TOKEN")
68 set(AFB_REMPORT "1234" CACHE PATH "Default AFB_TOKEN")
69
70 # Check GCC minimal version
71 if (gcc_minimal_version)
72 message (STATUS "${Cyan}-- Check gcc_minimal_version (found gcc version ${CMAKE_C_COMPILER_VERSION}) \
73 (found g++ version ${CMAKE_CXX_COMPILER_VERSION})${ColourReset}")
74 if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${gcc_minimal_version} OR CMAKE_C_COMPILER_VERSION VERSION_LESS ${gcc_minimal_version})
75 message(FATAL_ERROR "${Red}**** FATAL: Require at least gcc-${gcc_minimal_version} please set CMAKE_C[XX]_COMPILER")
76 endif()
77 endif(gcc_minimal_version)
78
79 # Check Kernel mandatory version, will fail the configuration if required version not matched.
80 if (kernel_mandatory_version)
81 message (STATUS "${Cyan}-- Check kernel_mandatory_version (found kernel version ${KERNEL_VERSION})${ColourReset}")
82 if (KERNEL_VERSION VERSION_LESS ${kernel_mandatory_version})
83 message(FATAL_ERROR "${Red}**** FATAL: Require at least ${kernel_mandatory_version} please use a recent kernel or source your SDK environment then clean and reconfigure your CMake project.")
84 endif (KERNEL_VERSION VERSION_LESS ${kernel_mandatory_version})
85 endif(kernel_mandatory_version)
86
87 # Check Kernel minimal version just print a Warning about missing features
88 # and set a definition to be used as preprocessor condition in code to disable
89 # incompatibles features.
90 if (kernel_minimal_version)
91 message (STATUS "${Cyan}-- Check kernel_minimal_version (found kernel version ${KERNEL_VERSION})${ColourReset}")
92 if (KERNEL_VERSION VERSION_LESS ${kernel_minimal_version})
93 message(WARNING "${Yellow}**** Warning: Some feature(s) require at least ${kernel_minimal_version}. Please use a recent kernel or source your SDK environment then clean and reconfigure your CMake project.${ColourReset}")
94 else (KERNEL_VERSION VERSION_LESS ${kernel_minimal_version})
95 add_definitions(-DKERNEL_MINIMAL_VERSION_OK)
96 endif (KERNEL_VERSION VERSION_LESS ${kernel_minimal_version})
97 endif(kernel_minimal_version)
98
99 # Project path variables
100 # ----------------------
101 set(PKGOUT_DIR package CACHE PATH "Output directory for packages")
102
103 # Define a default package directory
104 if(PKG_PREFIX)
105         set(PROJECT_PKG_BUILD_DIR ${PKG_PREFIX}/${PKGOUT_DIR} CACHE PATH "Application contents to be packaged")
106 else()
107         set(PROJECT_PKG_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/${PKGOUT_DIR} CACHE PATH "Application contents to be packaged")
108 endif()
109
110 # Paths to templates files
111 set(TEMPLATE_DIR "${PKG_TEMPLATE_PREFIX}/template.d" CACHE PATH "Subpath to a directory where are stored needed files to launch on remote target to debuging purposes")
112
113 string(REGEX REPLACE "^(.*)/.*$" "\\1" ENTRY_POINT "${PKG_TEMPLATE_PREFIX}")
114 set(PROJECT_PKG_ENTRY_POINT ${ENTRY_POINT}/packaging CACHE PATH "Where package build files, like rpm.spec file or config.xml, are write.")
115
116 set(WIDGET_ICON "\"${ENTRY_POINT}/wgt/${PROJECT_ICON}\"" CACHE PATH "Path to the widget icon")
117 if(NOT WIDGET_CONFIG_TEMPLATE)
118         set(WIDGET_CONFIG_TEMPLATE "\"${TEMPLATE_DIR}/config.xml.in\"" CACHE PATH "Path to widget config file template (config.xml.in)")
119 endif()
120
121 # Path to autobuild template
122 set(PROJECT_TEMPLATE_AGL_AUTOBUILD_DIR ${CMAKE_SOURCE_DIR}/conf.d/autobuild/agl CACHE PATH "Subpath to a directory where are stored autobuild script")
123 set(PROJECT_TEMPLATE_LINUX_AUTOBUILD_DIR ${CMAKE_SOURCE_DIR}/conf.d/autobuild/linux CACHE PATH "Subpath to a directory where are stored autobuild script")
124
125 # Archive target variables
126 #set(ARCHIVE_OUTPUT_ARCHIVE ${PROJECT_PKG_ENTRY_POINT}/${NPKG_PROJECT_NAME}_${PROJECT_VERSION}.orig.tar)
127 #set(ARCHIVE_OUTPUT ${ARCHIVE_OUTPUT_ARCHIVE}.gz)
128 #set(TMP_ARCHIVE_SUBMODULE ${PROJECT_PKG_ENTRY_POINT}/${NPKG_PROJECT_NAME}-sub)
129 #set(CMD_ARCHIVE_SUBMODULE \'git archive --verbose --prefix=${NPKG_PROJECT_NAME}-${PROJECT_VERSION}/$$path/ --format tar HEAD --output ${TMP_ARCHIVE_SUBMODULE}-$$sha1.tar\' )
130
131 #if(OSRELEASE MATCHES "debian" AND NOT DEFINED ENV{SDKTARGETSYSROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
132         # build deb spec file from template
133 #       set(PACKAGING_DEB_OUTPUT_DSC       ${PROJECT_PKG_ENTRY_POINT}/${NPKG_PROJECT_NAME}.dsc)
134 #       set(PACKAGING_DEB_OUTPUT_INSTALL   ${PROJECT_PKG_ENTRY_POINT}/debian.${NPKG_PROJECT_NAME}.install)
135 #       set(PACKAGING_DEB_OUTPUT_CHANGELOG ${PROJECT_PKG_ENTRY_POINT}/debian.changelog)
136 #       set(PACKAGING_DEB_OUTPUT_COMPAT    ${PROJECT_PKG_ENTRY_POINT}/debian.compat)
137 #       set(PACKAGING_DEB_OUTPUT_CONTROL   ${PROJECT_PKG_ENTRY_POINT}/debian.control)
138 #       set(PACKAGING_DEB_OUTPUT_RULES     ${PROJECT_PKG_ENTRY_POINT}/debian.rules)
139 #endif()
140
141 # Break After Binding are loaded but before they get initialised
142 set(GDB_INITIAL_BREAK "personality" CACHE STRING "Initial Break Point for GDB remote")
143
144 # Define some checker binaries to verify input DATA files
145 # to be included in package. Schema aren't checked for now.
146 # Dummy checker about JSON.
147 set(LUA_CHECKER "luac" "-p" CACHE STRING "LUA compiler")
148 set(XML_CHECKER "xmllint" CACHE STRING "XML linter")
149 set(JSON_CHECKER "" CACHE STRING "JSON linter")
150
151 # Default GNU directories path variables
152 set(BINDIR bin CACHE PATH "User executables")
153 set(ETCDIR etc CACHE PATH "Read only system configuration data")
154 set(LIBDIR lib CACHE PATH "System library directory")
155 set(HTTPDIR htdocs CACHE PATH "HTML5 data directory")
156 set(DATADIR data CACHE PATH "External data resources files")