X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=cmake%2Fcmake.d%2F02-variables.cmake;h=dc1c313ee0cc1bdb13106257143bc6df0a9286ee;hb=a3c312ece0a77310a9d8ecde1dd0f1267646f4ff;hp=4a4e5037018a8e465c2c0385319fa1e93262ef40;hpb=73f75d57e84f00830fd82d7cb76ee8c83f7fc6c7;p=apps%2Fapp-templates.git diff --git a/cmake/cmake.d/02-variables.cmake b/cmake/cmake.d/02-variables.cmake index 4a4e503..dc1c313 100644 --- a/cmake/cmake.d/02-variables.cmake +++ b/cmake/cmake.d/02-variables.cmake @@ -48,17 +48,6 @@ endif() # Native packaging name set(NPKG_PROJECT_NAME agl-${PROJECT_NAME}) -if(DEFINED ENV{SDKTARGETSYSROOT}) - file(STRINGS $ENV{SDKTARGETSYSROOT}/usr/include/linux/version.h LINUX_VERSION_CODE_LINE REGEX "LINUX_VERSION_CODE") - set(BUILD_ENV_SYSROOT $ENV{SDKTARGETSYSROOT}) -elseif(DEFINED ENV{PKG_CONFIG_SYSROOT_DIR}) - file(STRINGS $ENV{PKG_CONFIG_SYSROOT_DIR}/usr/include/linux/version.h LINUX_VERSION_CODE_LINE REGEX "LINUX_VERSION_CODE") - set(BUILD_ENV_SYSROOT $ENV{PKG_CONFIG_SYSROOT_DIR}) -else() - file(STRINGS /usr/include/linux/version.h LINUX_VERSION_CODE_LINE REGEX "LINUX_VERSION_CODE") - set(BUILD_ENV_SYSROOT "") -endif() - string(REGEX MATCH "[0-9]+" LINUX_VERSION_CODE ${LINUX_VERSION_CODE_LINE}) math(EXPR a "${LINUX_VERSION_CODE} >> 16") math(EXPR b "(${LINUX_VERSION_CODE} >> 8) & 255") @@ -66,30 +55,46 @@ math(EXPR c "(${LINUX_VERSION_CODE} & 255)") set(KERNEL_VERSION "${a}.${b}.${c}") -# Get the os type -# Used to package .deb -set(OS_RELEASE_PATH "${BUILD_ENV_SYSROOT}/etc/os-release") -if(EXISTS ${OS_RELEASE_PATH}) - execute_process(COMMAND bash "-c" "grep -E '^ID(_LIKE)?=' ${OS_RELEASE_PATH} | tail -n 1" - OUTPUT_VARIABLE TMP_OSRELEASE - ) - - if (NOT TMP_OSRELEASE STREQUAL "") - string(REGEX REPLACE ".*=\"?([0-9a-z\._-]*)\"?\n" "\\1" OSRELEASE ${TMP_OSRELEASE}) - else() - set(OSRELEASE "NOT COMPATIBLE !") - endif() - -else() - set(OSRELEASE "NOT COMPATIBLE ! Missing ${OS_RELEASE_PATH} file.") -endif() -message(STATUS "Distribution used ${OSRELEASE}") +# Setup project and app-templates version variables +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 +) + +# Get the git commit hash to append to the version +execute_process(COMMAND git rev-parse --short HEAD + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE COMMIT_HASH + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +# Detect unstaged or untracked changes +execute_process(COMMAND git status --short + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE DIRTY_FLAG + OUTPUT_STRIP_TRAILING_WHITESPACE +) # Include project configuration # ------------------------------ +if(NOT DEFINED PROJECT_VERSION) + set(PROJECT_VERSION ${GIT_PROJECT_VERSION}) +endif() + +# Release additionnals informations isn't supported so setting project +# attributes then add the dirty flag if git repo not sync'ed project(${PROJECT_NAME} VERSION ${PROJECT_VERSION} LANGUAGES ${PROJECT_LANGUAGES}) -set(PROJECT_LIBDIR "${CMAKE_SOURCE_DIR}/libs" CACHE PATH "Subpath to libraries") -set(PROJECT_RESOURCES "${CMAKE_SOURCE_DIR}/data" CACHE PATH "Subpath to data") +if(NOT ${DIRTY_FLAG}) + set(PROJECT_VERSION "${PROJECT_VERSION}-${COMMIT_HASH}-dirty") +else() + set(PROJECT_VERSION "${PROJECT_VERSION}-${COMMIT_HASH}") +endif() set(AFB_TOKEN "" CACHE PATH "Default AFB_TOKEN") set(AFB_REMPORT "1234" CACHE PATH "Default AFB_TOKEN") @@ -135,13 +140,15 @@ else() endif() # Paths to templates files -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") +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") -string(REGEX REPLACE "^(.*)/.*$" "\\1" ENTRY_POINT "${PKG_TEMPLATE_PREFIX}") +string(REGEX REPLACE "^(.*)/.*$" "\\1" ENTRY_POINT "${BARE_PKG_TEMPLATE_PREFIX}") 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") -set(WIDGET_CONFIG_TEMPLATE ${TEMPLATE_DIR}/config.xml.in CACHE PATH "Path to widget config file template (config.xml.in)") +if(NOT WIDGET_CONFIG_TEMPLATE) + set(WIDGET_CONFIG_TEMPLATE ${TEMPLATE_DIR}/config.xml.in CACHE PATH "Path to widget config file template (config.xml.in)") +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") @@ -171,4 +178,19 @@ set(GDB_INITIAL_BREAK "personality" CACHE STRING "Initial Break Point for GDB re # Dummy checker about JSON. set(LUA_CHECKER "luac" "-p" CACHE STRING "LUA compiler") set(XML_CHECKER "xmllint" CACHE STRING "XML linter") -set(JSON_CHECKER "echo" CACHE STRING "JSON linter") +set(JSON_CHECKER "" CACHE STRING "JSON linter") + +# Default GNU directories path variables +set(BINDIR bin CACHE PATH "User executables") +set(ETCDIR etc CACHE PATH "Read only system configuration data") +set(LIBDIR lib CACHE PATH "System library directory") +set(HTTPDIR htdocs CACHE PATH "HTML5 data directory") +set(DATADIR var CACHE PATH "External data resources files") + +# Normally CMake uses the build tree for the RPATH when building executables +# etc on systems that use RPATH. When the software is installed the executables +# etc are relinked by CMake to have the install RPATH. If this variable is set +# to true then the software is always built with the install path for the RPATH +# and does not need to be relinked when installed. +# Rpath could be set and controlled by target property INSTALL_RPATH +set(CMAKE_BUILD_WITH_INSTALL_RPATH true)