diff options
author | Suren A. Chilingaryan <csa@suren.me> | 2016-02-04 01:18:33 +0100 |
---|---|---|
committer | Suren A. Chilingaryan <csa@suren.me> | 2016-02-04 01:18:33 +0100 |
commit | 0e12e11ed817d66ff1e9246a32931e14e4fa6700 (patch) | |
tree | 6d2a2f2c6f374a0df45605701a0f736f2993a8a5 /cmake/build.cmake | |
parent | 333fe52eb3c7876cfe668dfe0445d34c46989d73 (diff) | |
download | pcitool-0e12e11ed817d66ff1e9246a32931e14e4fa6700.tar.gz pcitool-0e12e11ed817d66ff1e9246a32931e14e4fa6700.tar.bz2 pcitool-0e12e11ed817d66ff1e9246a32931e14e4fa6700.tar.xz pcitool-0e12e11ed817d66ff1e9246a32931e14e4fa6700.zip |
Add build information
Diffstat (limited to 'cmake/build.cmake')
-rw-r--r-- | cmake/build.cmake | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/cmake/build.cmake b/cmake/build.cmake new file mode 100644 index 0000000..3043014 --- /dev/null +++ b/cmake/build.cmake @@ -0,0 +1,82 @@ +cmake_minimum_required(VERSION 2.6) + +list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/") + +find_package(BAZAAR QUIET) + +set(PCILIB_BUILD_DATE "") +set(PCILIB_LAST_MODIFICATION "") +set(PCILIB_REVISION "0") +set(PCILIB_REVISION_BRANCH "") +set(PCILIB_REVISION_AUTHOR "") +set(PCILIB_REVISION_MODIFICATIONS "") + +execute_process( + COMMAND date "+%Y/%m/%d %H:%M:%S" + RESULT_VARIABLE _retcode + OUTPUT_VARIABLE _output + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +if (${_retcode} EQUAL 0) + set(PCILIB_BUILD_DATE ${_output}) +endif (${_retcode} EQUAL 0) + +execute_process( + COMMAND find ${CMAKE_SOURCE_DIR} -type f -name *.[ch] -printf "%TY/%Tm/%Td %TH:%TM:%TS %p\n" + COMMAND sort -n + COMMAND grep -E -v "build.h|config.h|CMakeFiles|./apps" + COMMAND tail -n 1 + COMMAND cut -d " " -f 1-2 + COMMAND cut -d "." -f 1 + RESULT_VARIABLE _retcode + OUTPUT_VARIABLE _output + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +if (${_retcode} EQUAL 0) + set(PCILIB_LAST_MODIFICATION ${_output}) +endif (${_retcode} EQUAL 0) + +if (BAZAAR_FOUND) + execute_process( + COMMAND ${BAZAAR_EXECUTABLE} revno --tree ${CMAKE_SOURCE_DIR} + RESULT_VARIABLE _retcode + OUTPUT_VARIABLE _output + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + if (${_retcode} EQUAL 0) + set(PCILIB_REVISION ${_output}) + + execute_process( + COMMAND ${BAZAAR_EXECUTABLE} log -r${PCILIB_REVISION} ${CMAKE_SOURCE_DIR} + RESULT_VARIABLE _retcode + OUTPUT_VARIABLE _output + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + if (${_retcode} EQUAL 0) + string(REGEX REPLACE "^(.*\n)?committer: ([^\n]+).*" + "\\2" PCILIB_REVISION_AUTHOR "${_output}" ) + string(REGEX REPLACE "^(.*\n)?branch nick: ([^\n]+).*" + "\\2" PCILIB_REVISION_BRANCH "${_output}" ) + endif (${_retcode} EQUAL 0) + endif (${_retcode} EQUAL 0) + + execute_process( + COMMAND ${BAZAAR_EXECUTABLE} status -SV + COMMAND cut -c 5- + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + RESULT_VARIABLE _retcode + OUTPUT_VARIABLE _output + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + if (${_retcode} EQUAL 0) + string(REGEX REPLACE "\n+" ";" PCILIB_REVISION_MODIFICATIONS ${_output}) +# set(PCILIB_REVISION_MODIFICATIONS ${_output}) + endif (${_retcode} EQUAL 0) +endif(BAZAAR_FOUND) + +configure_file(${CMAKE_SOURCE_DIR}/pcilib/build.h.in ${CMAKE_BINARY_DIR}/pcilib/build.h) |