Print CMake and OS version info to configuration log

Instead of asking the user which distribution it is, this will now be
visible from the log (which is included when uploading CTest runs)
This commit is contained in:
Roland Kaufmann 2013-02-15 10:13:14 +01:00
parent c423fc7a86
commit b2520ab9cb
2 changed files with 27 additions and 0 deletions

View File

@ -18,6 +18,10 @@ enable_language (CXX)
set (opm-core_MODULE_DIR "${PROJECT_SOURCE_DIR}/cmake/Modules")
list (APPEND CMAKE_MODULE_PATH ${opm-core_MODULE_DIR})
# print system information to better pinpoint issues from log alone
include (UseSystemInfo)
system_info ()
# very early try to print repo id (to pinpoint version if something goes wrong)
include (UseVCSInfo)
vcs_info ()

View File

@ -0,0 +1,23 @@
# - Print CMake and OS distribution version
#
function (system_info)
message (STATUS "CMake version: ${CMAKE_VERSION}")
if (CMAKE_SYSTEM MATCHES "Linux")
read_lsb (ID INTO DISTRIB_ID)
read_lsb (RELEASE INTO DISTRIB_RELEASE)
read_lsb (CODENAME INTO DISTRIB_CODENAME)
message (STATUS "Linux distribution: ${DISTRIB_ID} \"${DISTRIB_CODENAME}\" ${DISTRIB_RELEASE}")
else (CMAKE_SYSTEM MATCHES "Linux")
message (STATUS "Operating system: ${CMAKE_SYSTEM}")
endif (CMAKE_SYSTEM MATCHES "Linux")
endfunction (system_info)
# read property from LSB information
function (read_lsb suffix INTO varname)
file (STRINGS /etc/lsb-release _distrib
REGEX "^DISTRIB_${suffix}="
)
string (REGEX REPLACE
"^DISTRIB_${suffix}=\(.*\)" "\\1" ${varname} ${_distrib})
set (${varname} "${${varname}}" PARENT_SCOPE)
endfunction (read_lsb suffix INTO varname)