0532c33a40b5009596f9e5e5b76c18a29308b21a
[apps/agl-service-data-persistence.git] / ll-database-binding / conf.d / app-templates / 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 PATH "Default AFB_TOKEN")
65 set(AFB_REMPORT "1234" CACHE PATH "Default AFB_TOKEN")
66
67 # Check GCC minimal version
68 if (gcc_minimal_version)
69 message (STATUS "${Cyan}-- Check gcc_minimal_version (found gcc version ${CMAKE_C_COMPILER_VERSION}) \
70 (found g++ version ${CMAKE_CXX_COMPILER_VERSION})${ColourReset}")
71 if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${gcc_minimal_version} OR CMAKE_C_COMPILER_VERSION VERSION_LESS ${gcc_minimal_version})
72 message(FATAL_ERROR "${Red}**** FATAL: Require at least gcc-${gcc_minimal_version} please set CMAKE_C[XX]_COMPILER")
73 endif()
74 endif(gcc_minimal_version)
75
76 # Check Kernel mandatory version, will fail the configuration if required version not matched.
77 if (kernel_mandatory_version)
78 message (STATUS "${Cyan}-- Check kernel_mandatory_version (found kernel version ${KERNEL_VERSION})${ColourReset}")
79 if (KERNEL_VERSION VERSION_LESS ${kernel_mandatory_version})
80 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.")
81 endif (KERNEL_VERSION VERSION_LESS ${kernel_mandatory_version})
82 endif(kernel_mandatory_version)
83
84 # Check Kernel minimal version just print a Warning about missing features
85 # and set a definition to be used as preprocessor condition in code to disable
86 # incompatibles features.
87 if (kernel_minimal_version)
88 message (STATUS "${Cyan}-- Check kernel_minimal_version (found kernel version ${KERNEL_VERSION})${ColourReset}")
89 if (KERNEL_VERSION VERSION_LESS ${kernel_minimal_version})
90 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}")
91 else (KERNEL_VERSION VERSION_LESS ${kernel_minimal_version})
92 add_definitions(-DKERNEL_MINIMAL_VERSION_OK)
93 endif (KERNEL_VERSION VERSION_LESS ${kernel_minimal_version})
94 endif(kernel_minimal_version)
95
96 # Project path variables
97 # ----------------------
98 set(PKGOUT_DIR package CACHE PATH "Output directory for packages")
99
100 # Define a default package directory
101 if(PKG_PREFIX)
102         set(PROJECT_PKG_BUILD_DIR ${PKG_PREFIX}/${PKGOUT_DIR} CACHE PATH "Application contents to be packaged")
103 else()
104         set(PROJECT_PKG_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/${PKGOUT_DIR} CACHE PATH "Application contents to be packaged")
105 endif()
106
107 # Paths to templates files
108 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")
109
110 string(REGEX REPLACE "^(.*)/.*$" "\\1" ENTRY_POINT "${PKG_TEMPLATE_PREFIX}")
111 set(PROJECT_PKG_ENTRY_POINT ${ENTRY_POINT}/packaging CACHE PATH "Where package build files, like rpm.spec file or config.xml, are write.")
112
113 set(WIDGET_ICON "${ENTRY_POINT}/wgt/${PROJECT_ICON}" CACHE PATH "Path to the widget icon")
114 set(WIDGET_CONFIG_TEMPLATE ${TEMPLATE_DIR}/config.xml.in CACHE PATH "Path to widget config file template (config.xml.in)")
115
116 # Path to autobuild template
117 set(PROJECT_TEMPLATE_AGL_AUTOBUILD_DIR ${CMAKE_SOURCE_DIR}/conf.d/autobuild/agl CACHE PATH "Subpath to a directory where are stored autobuild script")
118 set(PROJECT_TEMPLATE_LINUX_AUTOBUILD_DIR ${CMAKE_SOURCE_DIR}/conf.d/autobuild/linux CACHE PATH "Subpath to a directory where are stored autobuild script")
119
120 # Archive target variables
121 set(ARCHIVE_OUTPUT_ARCHIVE ${PROJECT_PKG_ENTRY_POINT}/${NPKG_PROJECT_NAME}_${PROJECT_VERSION}.orig.tar)
122 set(ARCHIVE_OUTPUT ${ARCHIVE_OUTPUT_ARCHIVE}.gz)
123 set(TMP_ARCHIVE_SUBMODULE ${PROJECT_PKG_ENTRY_POINT}/${NPKG_PROJECT_NAME}-sub)
124 set(CMD_ARCHIVE_SUBMODULE \'git archive --verbose --prefix=${NPKG_PROJECT_NAME}-${PROJECT_VERSION}/$$path/ --format tar HEAD --output ${TMP_ARCHIVE_SUBMODULE}-$$sha1.tar\' )
125
126 if(OSRELEASE MATCHES "debian" AND NOT DEFINED ENV{SDKTARGETSYSROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
127         # build deb spec file from template
128         set(PACKAGING_DEB_OUTPUT_DSC       ${PROJECT_PKG_ENTRY_POINT}/${NPKG_PROJECT_NAME}.dsc)
129         set(PACKAGING_DEB_OUTPUT_INSTALL   ${PROJECT_PKG_ENTRY_POINT}/debian.${NPKG_PROJECT_NAME}.install)
130         set(PACKAGING_DEB_OUTPUT_CHANGELOG ${PROJECT_PKG_ENTRY_POINT}/debian.changelog)
131         set(PACKAGING_DEB_OUTPUT_COMPAT    ${PROJECT_PKG_ENTRY_POINT}/debian.compat)
132         set(PACKAGING_DEB_OUTPUT_CONTROL   ${PROJECT_PKG_ENTRY_POINT}/debian.control)
133         set(PACKAGING_DEB_OUTPUT_RULES     ${PROJECT_PKG_ENTRY_POINT}/debian.rules)
134 endif()
135
136 # Break After Binding are loaded but before they get initialised
137 set(GDB_INITIAL_BREAK "personality" CACHE STRING "Initial Break Point for GDB remote")
138
139 # Define some checker binaries to verify input DATA files
140 # to be included in package. Schema aren't checked for now.
141 # Dummy checker about JSON.
142 set(LUA_CHECKER "luac" "-p" CACHE STRING "LUA compiler")
143 set(XML_CHECKER "xmllint" CACHE STRING "XML linter")
144 set(JSON_CHECKER "echo" CACHE STRING "JSON linter")