1 ###########################################################################
2 # Copyright 2015, 2016, 2017 IoT.bzh
4 # author: Fulup Ar Foll <fulup@iot.bzh>
5 # contrib: Romain Forlot <romain.forlot@iot.bzh>
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
11 # http://www.apache.org/licenses/LICENSE-2.0
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 ###########################################################################
21 #--------------------------------------------------------------------------
23 # Do not change this cmake template
24 # Customise your preferences in "./etc/config.cmake"
25 #--------------------------------------------------------------------------
27 # Get colorized message output non Windows OS. You know bash ? :)
30 set(ColourReset "${Esc}[m")
31 set(ColourBold "${Esc}[1m")
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")
48 # (BUG!!!) as PKG_CONFIG_PATH does not work [should be en env variable]
49 set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH ON CACHE BOOLEAN "Flag for using prefix path")
51 # Native packaging name
52 set(NPKG_PROJECT_NAME agl-${PROJECT_NAME})
53 #No upercase in deb packaging name
54 string(TOLOWER ${NPKG_PROJECT_NAME} NPKG_PROJECT_NAME)
56 set(CMAKE_BUILD_TYPE Debug CACHE STRING "the type of build")
57 set(CMAKE_POSITION_INDEPENDENT_CODE ON)
61 # Used to package .deb
62 if(EXISTS "/etc/os-release")
63 execute_process(COMMAND grep -E "^ID(=|_LIKE=)" /etc/os-release
64 OUTPUT_VARIABLE TMP_OSRELEASE
66 if (NOT TMP_OSRELEASE STREQUAL "")
67 string(REGEX REPLACE ".*=" "" OSRELEASE ${TMP_OSRELEASE})
69 set(OSRELEASE "NOT DEBIAN OS")
71 message(STATUS "OSRELEASE = ${OSRELEASE}")
73 set(OSRELEASE "NOT DEBIAN OS")
76 # Include project configuration
77 # ------------------------------
78 project(${PROJECT_NAME} VERSION ${PROJECT_VERSION} LANGUAGES ${PROJECT_LANGUAGES})
79 set(PROJECT_LIBDIR "${CMAKE_SOURCE_DIR}/libs" CACHE PATH "Subpath to libraries")
80 set(PROJECT_RESOURCES "${CMAKE_SOURCE_DIR}/data" CACHE PATH "Subpath to data")
82 set(AFB_TOKEN "" CACHE PATH "Default AFB_TOKEN")
83 set(AFB_REMPORT "1234" CACHE PATH "Default AFB_TOKEN")
85 # Project path variables
86 # ----------------------
88 # If no install dir try to guess some smart default
89 if(BINDINGS_INSTALL_PREFIX)
90 set(BINDINGS_INSTALL_DIR ${BINDINGS_INSTALL_PREFIX}/${PROJECT_NAME} CACHE PATH "Where the binding will be installed in your system")
92 set(BINDINGS_INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME} CACHE PATH "Where the binding will be installed in your system")
95 set(PKGOUT_DIR package CACHE PATH "Output directory for packages")
97 # Define a default package directory
99 set(PROJECT_PKG_BUILD_DIR ${PKG_PREFIX}/${PKGOUT_DIR} CACHE PATH "Application contents to be packaged")
101 set(PROJECT_PKG_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/${PKGOUT_DIR} CACHE PATH "Application contents to be packaged")
104 # Paths to templates files
105 set (PKG_TEMPLATE_PREFIX ${CMAKE_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR} CACHE PATH "Default Package Templates Directory")
106 set(SSH_TEMPLATE_DIR "${PKG_TEMPLATE_PREFIX}/ssh" CACHE PATH "Subpath to a directory where are stored needed files to launch on remote target to debuging purposes")
107 set(GDB_TEMPLATE_DIR "${PKG_TEMPLATE_PREFIX}/gdb" CACHE PATH "Subpath to a directory where are stored needed files to launch debuging server on a remote target. Use gdbserver.")
108 set(WGT_TEMPLATE_DIR "${PKG_TEMPLATE_PREFIX}/wgt" CACHE PATH "Subpath to a directory where are stored needed files to build widget")
109 if(NOT WIDGET_CONFIG_TEMPLATE)
110 set(WIDGET_CONFIG_TEMPLATE ${WGT_TEMPLATE_DIR}/config.xml.in CACHE PATH "Path to widget config file template (config.xml.in)")
112 set(RPM_TEMPLATE_DIR "${PKG_TEMPLATE_PREFIX}/rpm" CACHE PATH "Subpath to a directory where are stored needed files to build rpm package")
113 set(DEB_TEMPLATE_DIR "${PKG_TEMPLATE_PREFIX}/deb" CACHE PATH "Subpath to a directory where are stored needed files to build deb package")
115 string(REGEX REPLACE "^(.*)/.*$" "\\1" ENTRY_POINT "${PKG_TEMPLATE_PREFIX}")
116 set(PROJECT_PKG_ENTRY_POINT ${ENTRY_POINT}/packaging CACHE PATH "Where package build files, like rpm.spec file or config.xml, are write.")
118 # Path to autobuild template
119 set(PROJECT_TEMPLATE_AGL_AUTOBUILD_DIR ${CMAKE_SOURCE_DIR}/conf.d/autobuild/agl CACHE PATH "Subpath to a directory where are stored autobuild script")
120 set(PROJECT_TEMPLATE_LINUX_AUTOBUILD_DIR ${CMAKE_SOURCE_DIR}/conf.d/autobuild/linux CACHE PATH "Subpath to a directory where are stored autobuild script")
122 # Archive target variables
123 set(ARCHIVE_OUTPUT_ARCHIVE ${PROJECT_PKG_ENTRY_POINT}/${NPKG_PROJECT_NAME}_${PROJECT_VERSION}.orig.tar)
124 set(ARCHIVE_OUTPUT ${ARCHIVE_OUTPUT_ARCHIVE}.gz)
125 set(TMP_ARCHIVE_SUBMODULE ${PROJECT_PKG_ENTRY_POINT}/${NPKG_PROJECT_NAME}-sub)
126 set(CMD_ARCHIVE_SUBMODULE \'git archive --verbose --prefix=${NPKG_PROJECT_NAME}-${PROJECT_VERSION}/$$path/ --format tar HEAD --output ${TMP_ARCHIVE_SUBMODULE}-$$sha1.tar\' )
128 if(OSRELEASE MATCHES "debian" AND NOT DEFINED ENV{SDKTARGETSYSROOT})
129 # build deb spec file from template
130 set(PACKAGING_DEB_OUTPUT_DSC ${PROJECT_PKG_ENTRY_POINT}/${NPKG_PROJECT_NAME}.dsc)
131 set(PACKAGING_DEB_OUTPUT_INSTALL ${PROJECT_PKG_ENTRY_POINT}/debian.${NPKG_PROJECT_NAME}.install)
132 set(PACKAGING_DEB_OUTPUT_CHANGELOG ${PROJECT_PKG_ENTRY_POINT}/debian.changelog)
133 set(PACKAGING_DEB_OUTPUT_COMPAT ${PROJECT_PKG_ENTRY_POINT}/debian.compat)
134 set(PACKAGING_DEB_OUTPUT_CONTROL ${PROJECT_PKG_ENTRY_POINT}/debian.control)
135 set(PACKAGING_DEB_OUTPUT_RULES ${PROJECT_PKG_ENTRY_POINT}/debian.rules)
136 endif(OSRELEASE MATCHES "debian" AND NOT DEFINED ENV{SDKTARGETSYSROOT})