Skip to content

Commit

Permalink
re-added: compilation info when building libCEC
Browse files Browse the repository at this point in the history
  • Loading branch information
opdenkamp committed Jul 3, 2015
1 parent a356efa commit 2f7b6b4
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/libcec/CMakeLists.txt
Expand Up @@ -122,6 +122,7 @@ set(CEC_HEADERS devices/CECRecordingDevice.h
source_group("Header Files" FILES ${CEC_HEADERS}) source_group("Header Files" FILES ${CEC_HEADERS})


# platform and device specific # platform and device specific
include(cmake/SetBuildInfo.cmake)
include(cmake/CheckPlatformSupport.cmake) include(cmake/CheckPlatformSupport.cmake)


## create project groups ## create project groups
Expand Down
2 changes: 0 additions & 2 deletions src/libcec/cmake/CheckPlatformSupport.cmake
Expand Up @@ -25,8 +25,6 @@ set(RPI_LIB_DIR "" CACHE FILEPATH "root path to Raspberry Pi libs")
# Pulse-Eight devices are always supported # Pulse-Eight devices are always supported
add_definitions(-DHAVE_P8_USB) add_definitions(-DHAVE_P8_USB)


set(LIB_INFO "compiled on ${CMAKE_SYSTEM}")

if(WIN32) if(WIN32)
# Windows # Windows
add_definitions(-DTARGET_WINDOWS -DNOMINMAX -D_CRT_SECURE_NO_WARNINGS -D_WINSOCKAPI_) add_definitions(-DTARGET_WINDOWS -DNOMINMAX -D_CRT_SECURE_NO_WARNINGS -D_WINSOCKAPI_)
Expand Down
63 changes: 63 additions & 0 deletions src/libcec/cmake/SetBuildInfo.cmake
@@ -0,0 +1,63 @@
# - Set information about the system on which this was built in LIB_INFO
#
# This module sets the following variables
# LIB_INFO supported features and compilation information
#

if(WIN32)

# Windows
set(LIB_INFO "compiled on ${CMAKE_SYSTEM}")

else()
# not Windows
set(LIB_INFO "")

# add git revision to compile info
find_program(HAVE_GIT_BIN git /bin /usr/bin /usr/local/bin)
if(HAVE_GIT_BIN)
exec_program(${CMAKE_CURRENT_SOURCE_DIR}/../../support/git-rev.sh HEAD OUTPUT_VARIABLE GIT_REVISION)
message(STATUS "git found: ${GIT_REVISION}")
endif()
if (GIT_REVISION)
set(LIB_INFO "git revision: ${GIT_REVISION},")
endif()

# add compilation date to compile info
find_program(HAVE_DATE_BIN date /bin /usr/bin /usr/local/bin)
if(HAVE_DATE_BIN)
exec_program(date ARGS -u OUTPUT_VARIABLE BUILD_DATE)
set(LIB_INFO "${LIB_INFO} compiled on ${BUILD_DATE}")
else()
set(LIB_INFO "${LIB_INFO} compiled on (unknown date)")
endif()

# add user who built this to compile info
find_program(HAVE_WHOAMI_BIN whoami /bin /usr/bin /usr/local/bin)
if(HAVE_WHOAMI_BIN)
exec_program(whoami OUTPUT_VARIABLE BUILD_USER)
set(LIB_INFO "${LIB_INFO} by ${BUILD_USER}")
else()
set(LIB_INFO "${LIB_INFO} by (unknown user)")
endif()


# add host on which this was built to compile info
find_program(HAVE_HOSTNAME_BIN hostname /bin /usr/bin /usr/local/bin)
if(HAVE_HOSTNAME_BIN)
exec_program(hostname ARGS -f OUTPUT_VARIABLE BUILD_HOST)
set(LIB_INFO "${LIB_INFO}@${BUILD_HOST}")
endif()

# add host info on which this was built to compile info
find_program(HAVE_UNAME_BIN uname /bin /usr/bin /usr/local/bin)
if(HAVE_UNAME_BIN)
exec_program(uname ARGS -s OUTPUT_VARIABLE BUILD_SYSNAME)
exec_program(uname ARGS -r OUTPUT_VARIABLE BUILD_SYSVER)
exec_program(uname ARGS -m OUTPUT_VARIABLE BUILD_SYSARCH)

set(LIB_INFO "${LIB_INFO} on ${BUILD_SYSNAME} ${BUILD_SYSVER} (${BUILD_SYSARCH})")
endif()

endif()

5 changes: 5 additions & 0 deletions support/git-rev.sh
@@ -0,0 +1,5 @@
#!/bin/sh

## cmake doesn't read the variable when it doesn't end with a newline, and I haven't figured out how to have it add a newline directly...
echo -n "`git --no-pager log --abbrev=7 -n 1 --pretty=format:"%h"`\n"

0 comments on commit 2f7b6b4

Please sign in to comment.