Clearer coverage compilation options configuration
[apps/app-templates.git] / cmake / cmake.d / 02-variables.cmake
index f01114d..693991a 100644 (file)
@@ -67,6 +67,13 @@ execute_process(COMMAND git describe --abbrev=0
        OUTPUT_STRIP_TRAILING_WHITESPACE
 )
 
        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}
 # Detect unstaged or untracked changes
 execute_process(COMMAND git status --short
        WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
@@ -79,16 +86,16 @@ execute_process(COMMAND git status --short
 if(NOT DEFINED PROJECT_VERSION)
        set(PROJECT_VERSION ${GIT_PROJECT_VERSION})
 endif()
 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})
 if(NOT ${DIRTY_FLAG})
 # 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})
 if(NOT ${DIRTY_FLAG})
-set(PROJECT_VERSION "${PROJECT_VERSION}-dirty")
+       set(PROJECT_VERSION "${PROJECT_VERSION}-${COMMIT_HASH}-dirty")
+else()
+       set(PROJECT_VERSION "${PROJECT_VERSION}-${COMMIT_HASH}")
 endif()
 
 endif()
 
-set(PROJECT_LIBDIR "\"${CMAKE_SOURCE_DIR}/libs\"" CACHE PATH "Subpath to libraries")
-set(PROJECT_RESOURCES "\"${CMAKE_SOURCE_DIR}/data\"" CACHE PATH "Subpath to data")
-
 set(AFB_TOKEN   ""      CACHE PATH "Default AFB_TOKEN")
 set(AFB_REMPORT "1234" CACHE PATH "Default AFB_TOKEN")
 
 set(AFB_TOKEN   ""      CACHE PATH "Default AFB_TOKEN")
 set(AFB_REMPORT "1234" CACHE PATH "Default AFB_TOKEN")
 
@@ -96,7 +103,7 @@ set(AFB_REMPORT "1234" CACHE PATH "Default AFB_TOKEN")
 if (gcc_minimal_version)
 message (STATUS "${Cyan}-- Check gcc_minimal_version (found gcc version ${CMAKE_C_COMPILER_VERSION}) \
 (found g++ version ${CMAKE_CXX_COMPILER_VERSION})${ColourReset}")
 if (gcc_minimal_version)
 message (STATUS "${Cyan}-- Check gcc_minimal_version (found gcc version ${CMAKE_C_COMPILER_VERSION}) \
 (found g++ version ${CMAKE_CXX_COMPILER_VERSION})${ColourReset}")
-if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${gcc_minimal_version} OR CMAKE_C_COMPILER_VERSION VERSION_LESS ${gcc_minimal_version})
+if (("${PROJECT_LANGUAGES}" MATCHES "CXX" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${gcc_minimal_version}) OR CMAKE_C_COMPILER_VERSION VERSION_LESS ${gcc_minimal_version})
 message(FATAL_ERROR "${Red}**** FATAL: Require at least gcc-${gcc_minimal_version} please set CMAKE_C[XX]_COMPILER")
 endif()
 endif(gcc_minimal_version)
 message(FATAL_ERROR "${Red}**** FATAL: Require at least gcc-${gcc_minimal_version} please set CMAKE_C[XX]_COMPILER")
 endif()
 endif(gcc_minimal_version)
@@ -178,4 +185,12 @@ 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(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 data CACHE PATH "External data resources files")
+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)