diff options
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/cmake.d/01-build_options.cmake | 7 | ||||
-rw-r--r-- | cmake/cmake.d/02-variables.cmake | 27 | ||||
-rw-r--r-- | cmake/cmake.d/03-macros.cmake | 28 | ||||
-rw-r--r-- | cmake/cmake.d/04-extra_targets.cmake | 12 | ||||
-rw-r--r-- | cmake/common.cmake | 40 |
5 files changed, 52 insertions, 62 deletions
diff --git a/cmake/cmake.d/01-build_options.cmake b/cmake/cmake.d/01-build_options.cmake index 26b001d..c150d2a 100644 --- a/cmake/cmake.d/01-build_options.cmake +++ b/cmake/cmake.d/01-build_options.cmake @@ -1,8 +1,8 @@ ########################################################################### # Copyright 2015, 2016, 2017 IoT.bzh # -# author: Fulup Ar Foll <fulup@iot.bzh> -# contrib: Romain Forlot <romain.forlot@iot.bzh> +# authors: Fulup Ar Foll <fulup@iot.bzh> +# Romain Forlot <romain.forlot@iot.bzh> # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -132,8 +132,7 @@ ENDIF(${CMAKE_BUILD_TYPE} MATCHES COVERAGE) INCLUDE_DIRECTORIES(${EXTRA_INCLUDE_DIRS}) # Default Linkflag -set(PKG_TEMPLATE_PREFIX "\"${CMAKE_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}\"" CACHE PATH "Default Package Templates Directory") -set(BARE_PKG_TEMPLATE_PREFIX "${CMAKE_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}" CACHE PATH "Default Package Templates Directory") +get_filename_component(PKG_TEMPLATE_PREFIX "${CMAKE_CURRENT_LIST_DIR}/../.." REALPATH CACHE) if(NOT BINDINGS_LINK_FLAG) set(BINDINGS_LINK_FLAG "-Wl,--version-script=${PKG_TEMPLATE_PREFIX}/cmake/export.map") diff --git a/cmake/cmake.d/02-variables.cmake b/cmake/cmake.d/02-variables.cmake index 693991a..857bd44 100644 --- a/cmake/cmake.d/02-variables.cmake +++ b/cmake/cmake.d/02-variables.cmake @@ -60,11 +60,7 @@ execute_process(COMMAND git describe --abbrev=0 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE GIT_PROJECT_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE -) -execute_process(COMMAND git describe --abbrev=0 - WORKING_DIRECTORY ${BARE_PKG_TEMPLATE_PREFIX} - OUTPUT_VARIABLE APP_TEMPLATES_VERSION - OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET ) # Get the git commit hash to append to the version @@ -72,6 +68,7 @@ execute_process(COMMAND git rev-parse --short HEAD WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE COMMIT_HASH OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET ) # Detect unstaged or untracked changes @@ -79,11 +76,14 @@ execute_process(COMMAND git status --short WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE DIRTY_FLAG OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET ) # Include project configuration # ------------------------------ -if(NOT DEFINED PROJECT_VERSION) +if(NOT DEFINED PROJECT_VERSION AND NOT DEFINED GIT_PROJECT_VERSION) + message(FATAL_ERROR "${Red}No version tag found from your project's source directory and no PROJECT_VERSION set in your config.cmake file. Abort!") +elseif(NOT DEFINED PROJECT_VERSION AND DEFINED GIT_PROJECT_VERSION) set(PROJECT_VERSION ${GIT_PROJECT_VERSION}) endif() @@ -139,10 +139,11 @@ else() set(PROJECT_PKG_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/${PKGOUT_DIR} CACHE PATH "Application contents to be packaged") endif() +set(PROJECT_APP_TEMPLATES_DIR "${CMAKE_CURRENT_LIST_DIR}/../..") # Paths to templates files -set(TEMPLATE_DIR "${BARE_PKG_TEMPLATE_PREFIX}/template.d" CACHE PATH "Subpath to a directory where are stored needed files to launch on remote target to debuging purposes") +set(TEMPLATE_DIR "${PROJECT_APP_TEMPLATES_DIR}/template.d" CACHE PATH "Subpath to a directory where are stored needed files to launch on remote target to debuging purposes") -string(REGEX REPLACE "^(.*)/.*$" "\\1" ENTRY_POINT "${BARE_PKG_TEMPLATE_PREFIX}") +string(REGEX REPLACE "^(.*)/.*$" "\\1" ENTRY_POINT "${PROJECT_CMAKE_CONF_DIR}") set(PROJECT_PKG_ENTRY_POINT ${ENTRY_POINT}/packaging CACHE PATH "Where package build files, like rpm.spec file or config.xml, are write.") set(WIDGET_ICON "${ENTRY_POINT}/wgt/${PROJECT_ICON}" CACHE PATH "Path to the widget icon") @@ -151,14 +152,8 @@ if(NOT WIDGET_CONFIG_TEMPLATE) endif() # Path to autobuild template -set(PROJECT_TEMPLATE_AGL_AUTOBUILD_DIR ${CMAKE_SOURCE_DIR}/conf.d/autobuild/agl CACHE PATH "Subpath to a directory where are stored autobuild script") -set(PROJECT_TEMPLATE_LINUX_AUTOBUILD_DIR ${CMAKE_SOURCE_DIR}/conf.d/autobuild/linux CACHE PATH "Subpath to a directory where are stored autobuild script") - -# Archive target variables -set(ARCHIVE_OUTPUT_ARCHIVE ${PROJECT_PKG_ENTRY_POINT}/${NPKG_PROJECT_NAME}_${PROJECT_VERSION}.orig.tar) -set(ARCHIVE_OUTPUT ${ARCHIVE_OUTPUT_ARCHIVE}.gz) -set(TMP_ARCHIVE_SUBMODULE ${PROJECT_PKG_ENTRY_POINT}/${NPKG_PROJECT_NAME}-sub) -set(CMD_ARCHIVE_SUBMODULE \'git archive --verbose --prefix=${NPKG_PROJECT_NAME}-${PROJECT_VERSION}/$$path/ --format tar HEAD --output ${TMP_ARCHIVE_SUBMODULE}-$$sha1.tar\' ) +set(PROJECT_AGL_AUTOBUILD_DIR ${CMAKE_SOURCE_DIR}/conf.d/autobuild/agl CACHE PATH "Subpath to a directory where are stored autobuild script") +set(PROJECT_LINUX_AUTOBUILD_DIR ${CMAKE_SOURCE_DIR}/conf.d/autobuild/linux CACHE PATH "Subpath to a directory where are stored autobuild script") if(OSRELEASE MATCHES "debian" AND NOT DEFINED ENV{SDKTARGETSYSROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE) # build deb spec file from template diff --git a/cmake/cmake.d/03-macros.cmake b/cmake/cmake.d/03-macros.cmake index 4cd34e4..bb5e2b5 100644 --- a/cmake/cmake.d/03-macros.cmake +++ b/cmake/cmake.d/03-macros.cmake @@ -491,7 +491,7 @@ macro(wgt_package_build) elseif(EXISTS "${WIDGET_ICON}") set(ICON_PATH "${WIDGET_ICON}") else() - set(ICON_PATH ${CMAKE_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/wgt/icon-default.png) + set(ICON_PATH ${PROJECT_APP_TEMPLATES_DIR}/wgt/icon-default.png) endif() if(NOT WIDGET_ENTRY_POINT) @@ -525,14 +525,14 @@ macro(wgt_package_build) endif() add_custom_command(OUTPUT ${PROJECT_PKG_BUILD_DIR}/config.xml - COMMAND ${CMAKE_COMMAND} -DINFILE=${WIDGET_CONFIG_TEMPLATE} -DOUTFILE=${PROJECT_PKG_BUILD_DIR}/config.xml -DPROJECT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/cmake/configure_file.cmake + COMMAND ${CMAKE_COMMAND} -DINFILE=${WIDGET_CONFIG_TEMPLATE} -DOUTFILE=${PROJECT_PKG_BUILD_DIR}/config.xml -DPROJECT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} -P ${PROJECT_APP_TEMPLATES_DIR}/cmake/configure_file.cmake COMMAND cp ${ICON_PATH} ${PROJECT_PKG_BUILD_DIR}/${PROJECT_ICON} ) add_custom_command(OUTPUT ${PROJECT_PKG_TEST_DIR}/test-config.xml ${PROJECT_PKG_TEST_DIR}/bin/launcher - COMMAND ${CMAKE_COMMAND} -DINFILE=${CMAKE_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/test-widget/test-config.xml.in -DOUTFILE=${PROJECT_PKG_TEST_DIR}/config.xml -DPROJECT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/cmake/configure_file.cmake + COMMAND ${CMAKE_COMMAND} -DINFILE=${PROJECT_APP_TEMPLATES_DIR}/test-wgt/test-config.xml.in -DOUTFILE=${PROJECT_PKG_TEST_DIR}/config.xml -DPROJECT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} -P ${PROJECT_APP_TEMPLATES_DIR}/cmake/configure_file.cmake COMMAND mkdir -p ${PROJECT_PKG_TEST_DIR}/bin COMMAND cp ${ICON_PATH} ${PROJECT_PKG_TEST_DIR}/${PROJECT_ICON} - COMMAND cp ${CMAKE_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/test-widget/launcher.sh.in ${PROJECT_PKG_TEST_DIR}/bin/launcher + COMMAND cp ${PROJECT_APP_TEMPLATES_DIR}/test-wgt/launcher.sh.in ${PROJECT_PKG_TEST_DIR}/bin/launcher ) add_custom_command(OUTPUT ${WGT_NAME}.wgt @@ -634,23 +634,3 @@ macro(project_closing_msg) ${PROJECT_TARGETS} populate) endif() endmacro() - -macro(check_version) - if(GIT_PROJECT_VERSION) - if(${GIT_PROJECT_VERSION} VERSION_GREATER ${APP_TEMPLATES_VERSION}) - message(STATUS "${Yellow}.. Your app-templates submodule version seems outdated. You should update it with 'git submodule update --remote ${PROJECT_APP_TEMPLATES_DIR}'. - - App-templates version: ${APP_TEMPLATES_VERSION} - - Project version according AGL Git tag: ${GIT_PROJECT_VERSION}" - ) - endif() - elseif(PROJECT_VERSION) - if(${PROJECT_VERSION} VERSION_GREATER ${APP_TEMPLATES_VERSION}) - message(STATUS "${Yellow}.. Your app-templates submodule version seems outdated. You should update it with 'git submodule update --remote ${PROJECT_APP_TEMPLATES_DIR}'. - - App-templates version: ${APP_TEMPLATES_VERSION} - - Project version according AGL Git tag: ${PROJECT_VERSION}" - ) - endif() - else() - message(STATUS "${Yellow} Your git project repo doesn't have any version tags nor hosted by AGL gerrit infrastructure. Can't compare version between project and app-templates ${APP_TEMPLATES_VERSION} ${ColourReset}") - endif() -endmacro() diff --git a/cmake/cmake.d/04-extra_targets.cmake b/cmake/cmake.d/04-extra_targets.cmake index d1b446c..3b94b8c 100644 --- a/cmake/cmake.d/04-extra_targets.cmake +++ b/cmake/cmake.d/04-extra_targets.cmake @@ -45,12 +45,12 @@ endforeach() # Autobuild target # ---------------------------------------------------------------------------- -add_custom_command(OUTPUT ${PROJECT_TEMPLATE_AGL_AUTOBUILD_DIR}/autobuild ${PROJECT_TEMPLATE_LINUX_AUTOBUILD_DIR}/autobuild - DEPENDS ${CMAKE_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/template.d/autobuild/agl/autobuild.in - ${CMAKE_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/template.d/autobuild/linux/autobuild.in +add_custom_command(OUTPUT ${PROJECT_AGL_AUTOBUILD_DIR}/autobuild ${PROJECT_LINUX_AUTOBUILD_DIR}/autobuild + DEPENDS ${TEMPLATE_DIR}/autobuild/agl/autobuild.in + ${TEMPLATE_DIR}/autobuild/linux/autobuild.in - COMMAND [ ! -f "${PROJECT_TEMPLATE_AGL_AUTOBUILD_DIR}/autobuild" ] && ${CMAKE_COMMAND} -DINFILE=${CMAKE_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/template.d/autobuild/agl/autobuild.in -DOUTFILE=${PROJECT_TEMPLATE_AGL_AUTOBUILD_DIR}/autobuild -DPROJECT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} -P ${CMAKE_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/cmake/configure_file.cmake || exit 0 - COMMAND [ ! -f "${PROJECT_TEMPLATE_LINUX_AUTOBUILD_DIR}/autobuild" ] && ${CMAKE_COMMAND} -DINFILE=${CMAKE_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/template.d/autobuild/agl/autobuild.in -DOUTFILE=${PROJECT_TEMPLATE_LINUX_AUTOBUILD_DIR}/autobuild -DPROJECT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} -P ${CMAKE_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/cmake/configure_file.cmake || exit 0 + COMMAND [ ! -f "${PROJECT_AGL_AUTOBUILD_DIR}/autobuild" ] && ${CMAKE_COMMAND} -DINFILE=${TEMPLATE_DIR}/autobuild/agl/autobuild.in -DOUTFILE=${PROJECT_AGL_AUTOBUILD_DIR}/autobuild -DPROJECT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} -P ${PROJECT_APP_TEMPLATES_DIR}/cmake/configure_file.cmake && chmod a+x ${PROJECT_AGL_AUTOBUILD_DIR}/autobuild || exit 0 + COMMAND [ ! -f "${PROJECT_LINUX_AUTOBUILD_DIR}/autobuild" ] && ${CMAKE_COMMAND} -DINFILE=${TEMPLATE_DIR}/autobuild/agl/autobuild.in -DOUTFILE=${PROJECT_LINUX_AUTOBUILD_DIR}/autobuild -DPROJECT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} -P ${PROJECT_APP_TEMPLATES_DIR}/cmake/configure_file.cmake && chmod a+x ${PROJECT_LINUX_AUTOBUILD_DIR}/autobuild || exit 0 ) -add_custom_target(autobuild ALL DEPENDS ${PROJECT_TEMPLATE_AGL_AUTOBUILD_DIR}/autobuild ${PROJECT_TEMPLATE_LINUX_AUTOBUILD_DIR}/autobuild) +add_custom_target(autobuild ALL DEPENDS ${PROJECT_AGL_AUTOBUILD_DIR}/autobuild ${PROJECT_LINUX_AUTOBUILD_DIR}/autobuild) diff --git a/cmake/common.cmake b/cmake/common.cmake index f553ae0..6e43d13 100644 --- a/cmake/common.cmake +++ b/cmake/common.cmake @@ -1,5 +1,5 @@ ########################################################################### -# Copyright 2015, 2016, 2017 IoT.bzh +# Copyright 2015 - 2018 IoT.bzh # # author: Fulup Ar Foll <fulup@iot.bzh> # contrib: Romain Forlot <romain.forlot@iot.bzh> @@ -25,7 +25,7 @@ #-------------------------------------------------------------------------- # Include ExternalProject CMake module by default -include(${CMAKE_ROOT}/Modules/ExternalProject.cmake) +include(ExternalProject) if(DEFINED ENV{SDKTARGETSYSROOT}) file(STRINGS $ENV{SDKTARGETSYSROOT}/usr/include/linux/version.h LINUX_VERSION_CODE_LINE REGEX "LINUX_VERSION_CODE") @@ -57,31 +57,48 @@ elseif("${BUILD_ENV_SYSROOT}" STREQUAL "$ENV{PKG_CONFIG_SYSROOT_DIR}") else() set(OSRELEASE "NOT COMPATIBLE ! Missing ${OS_RELEASE_PATH} file.") endif() -message(STATUS "Distribution detected (separated by ';' choose one of them) ${OSRELEASE}") +message("Distribution detected (separated by ';' choose one of them) ${OSRELEASE}") -file(GLOB project_cmakefiles ${PROJECT_APP_TEMPLATES_DIR}/cmake/cmake.d/[0-9][0-9]-*.cmake) +# Include CMake modules core files +file(GLOB project_cmakefiles ${CMAKE_CURRENT_LIST_DIR}/cmake.d/[0-9][0-9]-*.cmake) + +# Include optionnal user defined OS relative CMake files foreach(OS IN LISTS OSRELEASE) - list(APPEND PATTERN "${PROJECT_APP_TEMPLATES_DIR}/../cmake/[0-9][0-9]-${OS}*.cmake") + list(APPEND PATTERN "${CMAKE_SOURCE_DIR}/${PROJECT_CMAKE_CONF_DIR}/cmake/[0-9][0-9]-${OS}*.cmake" + "${CMAKE_SOURCE_DIR}/${PROJECT_CMAKE_CONF_DIR}/cmake.d/[0-9][0-9]-${OS}*.cmake") endforeach() -list(APPEND PATTERN "${PROJECT_APP_TEMPLATES_DIR}/../cmake/[0-9][0-9]-common*.cmake") +list(APPEND PATTERN "${PROJECT_CMAKE_CONF_DIR}/../cmake/[0-9][0-9]-common*.cmake" + "${PROJECT_CMAKE_CONF_DIR}/../cmake.d/[0-9][0-9]-common*.cmake") file(GLOB distro_cmakefiles ${PATTERN}) list(SORT distro_cmakefiles) if(NOT distro_cmakefiles) - file(GLOB distro_cmakefiles ${PROJECT_APP_TEMPLATES_DIR}/../cmake/[0-9][0-9]-default*.cmake) + file(GLOB distro_cmakefiles ${CMAKE_SOURCE_DIR}/${PROJECT_CMAKE_CONF_DIR}/cmake/[0-9][0-9]-default*.cmake + ${CMAKE_SOURCE_DIR}/${PROJECT_CMAKE_CONF_DIR}/cmake.d/[0-9][0-9]-default*.cmake) endif() list(APPEND project_cmakefiles "${distro_cmakefiles}") list(SORT project_cmakefiles) -file(GLOB home_cmakefiles $ENV{HOME}/.config/app-templates/cmake.d/[0-9][0-9]-common*.cmake $ENV{HOME}/.config/app-templates/cmake.d/[0-9][0-9]-${PROJECT_NAME}*.cmake) +file(GLOB home_cmakefiles $ENV{HOME}/.config/app-templates/cmake.d/[0-9][0-9]-common*.cmake + $ENV{HOME}/.config/app-templates/cmake.d/[0-9][0-9]-${PROJECT_NAME}*.cmake + $ENV{HOME}/.config/cmake-apps-module/cmake.d/[0-9][0-9]-common*.cmake + $ENV{HOME}/.config/cmake-apps-module/cmake.d/[0-9][0-9]-${PROJECT_NAME}*.cmake + $ENV{HOME}/.config/CMakeAfbTemplates/cmake.d/[0-9][0-9]-common*.cmake + $ENV{HOME}/.config/CMakeAfbTemplates/cmake.d/[0-9][0-9]-${PROJECT_NAME}*.cmake) list(SORT home_cmakefiles) -file(GLOB system_cmakefiles /etc/app-templates/cmake.d/[0-9][0-9]-common*.cmake /etc/app-templates/cmake.d/[0-9][0-9]-${PROJECT_NAME}*.cmake) + +file(GLOB system_cmakefiles /etc/app-templates/cmake.d/[0-9][0-9]-common*.cmake + /etc/app-templates/cmake.d/[0-9][0-9]-${PROJECT_NAME}*.cmake + /etc/cmake-apps-module/cmake.d/[0-9][0-9]-common*.cmake + /etc/cmake-apps-module/cmake.d/[0-9][0-9]-${PROJECT_NAME}*.cmake + /etc/CMakeAfbTemplates/cmake.d/[0-9][0-9]-common*.cmake + /etc/CMakeAfbTemplates/cmake.d/[0-9][0-9]-${PROJECT_NAME}*.cmake) list(SORT system_cmakefiles) foreach(file ${system_cmakefiles} ${home_cmakefiles} ${project_cmakefiles}) - message(STATUS "Include: ${file}") + message("Include: ${file}") include(${file}) endforeach() @@ -94,11 +111,10 @@ else() project_subdirs_add() endif(DEFINED PROJECT_SRC_DIR_PATTERN) -configure_files_in_dir(${PROJECT_APP_TEMPLATES_DIR}/${ENTRY_POINT}/template.d) +configure_files_in_dir(${CMAKE_SOURCE_DIR}/${PROJECT_CMAKE_CONF_DIR}/template.d) configure_files_in_dir($ENV{HOME}/.config/app-templates/scripts) configure_files_in_dir(/etc/app-templates/scripts) -check_version() project_targets_populate() remote_targets_populate() project_package_build() |