/alps/pcitool

To get this branch, use:
bzr branch http://suren.me/webbzr/alps/pcitool
348 by Suren A. Chilingaryan
Add build information
1
cmake_minimum_required(VERSION 2.6)
2
351 by Suren A. Chilingaryan
Fix build system
3
list(APPEND CMAKE_MODULE_PATH "${PCILIB_SOURCE_DIR}/cmake/")
348 by Suren A. Chilingaryan
Add build information
4
5
find_package(BAZAAR QUIET)
6
7
set(PCILIB_BUILD_DATE "")
8
set(PCILIB_LAST_MODIFICATION "")
9
set(PCILIB_REVISION "0")
10
set(PCILIB_REVISION_BRANCH "")
11
set(PCILIB_REVISION_AUTHOR "")
12
set(PCILIB_REVISION_MODIFICATIONS "")
13
14
execute_process(
15
    COMMAND date "+%Y/%m/%d %H:%M:%S"
16
    RESULT_VARIABLE _retcode
17
    OUTPUT_VARIABLE _output
18
    OUTPUT_STRIP_TRAILING_WHITESPACE
19
)
20
21
if (${_retcode} EQUAL 0)
22
    set(PCILIB_BUILD_DATE ${_output})
23
endif (${_retcode} EQUAL 0)
24
25
execute_process(
351 by Suren A. Chilingaryan
Fix build system
26
    COMMAND find ${PCILIB_SOURCE_DIR} -type f -name "*.[ch]" -printf "%TY/%Tm/%Td %TH:%TM:%TS  %p\n"
348 by Suren A. Chilingaryan
Add build information
27
    COMMAND sort -n
28
    COMMAND grep -E -v "build.h|config.h|CMakeFiles|./apps"
29
    COMMAND tail -n 1
30
    COMMAND cut -d " " -f 1-2
31
    COMMAND cut -d "." -f 1
32
    RESULT_VARIABLE _retcode
33
    OUTPUT_VARIABLE _output
34
    OUTPUT_STRIP_TRAILING_WHITESPACE
35
)
36
37
if (${_retcode} EQUAL 0)
38
    set(PCILIB_LAST_MODIFICATION ${_output})
39
endif (${_retcode} EQUAL 0)
40
398 by Suren A. Chilingaryan
Fix also building of driver for bazaar-exported zip archives
41
if (BAZAAR_FOUND AND EXISTS ${PCILIB_SOURCE_DIR}/.bzr)
348 by Suren A. Chilingaryan
Add build information
42
    execute_process(
351 by Suren A. Chilingaryan
Fix build system
43
	COMMAND ${BAZAAR_EXECUTABLE} revno --tree ${PCILIB_SOURCE_DIR}
348 by Suren A. Chilingaryan
Add build information
44
	RESULT_VARIABLE _retcode
45
	OUTPUT_VARIABLE _output
46
	OUTPUT_STRIP_TRAILING_WHITESPACE
47
    )
48
49
    if (${_retcode} EQUAL 0)
50
	set(PCILIB_REVISION ${_output})
51
52
	execute_process(
351 by Suren A. Chilingaryan
Fix build system
53
	    COMMAND ${BAZAAR_EXECUTABLE} log -r${PCILIB_REVISION} ${PCILIB_SOURCE_DIR}
348 by Suren A. Chilingaryan
Add build information
54
	    RESULT_VARIABLE _retcode
55
	    OUTPUT_VARIABLE _output
56
	    OUTPUT_STRIP_TRAILING_WHITESPACE
57
	)
58
59
	if (${_retcode} EQUAL 0)
60
	    string(REGEX REPLACE "^(.*\n)?committer: ([^\n]+).*"
352 by Suren A. Chilingaryan
Do not complain if no changes since last revision
61
                    "\\2" PCILIB_REVISION_AUTHOR "${_output}" )
348 by Suren A. Chilingaryan
Add build information
62
	    string(REGEX REPLACE "^(.*\n)?branch nick: ([^\n]+).*"
352 by Suren A. Chilingaryan
Do not complain if no changes since last revision
63
                    "\\2" PCILIB_REVISION_BRANCH "${_output}" )
348 by Suren A. Chilingaryan
Add build information
64
	endif (${_retcode} EQUAL 0)
65
    endif (${_retcode} EQUAL 0)
66
67
    execute_process(
68
	COMMAND ${BAZAAR_EXECUTABLE} status -SV
69
	COMMAND cut -c 5-
351 by Suren A. Chilingaryan
Fix build system
70
	WORKING_DIRECTORY ${PCILIB_SOURCE_DIR}
348 by Suren A. Chilingaryan
Add build information
71
	RESULT_VARIABLE _retcode
72
	OUTPUT_VARIABLE _output
73
	OUTPUT_STRIP_TRAILING_WHITESPACE
74
    )
75
76
    if (${_retcode} EQUAL 0)
352 by Suren A. Chilingaryan
Do not complain if no changes since last revision
77
	string(REGEX REPLACE "\n+" ";" PCILIB_REVISION_MODIFICATIONS "${_output}")
348 by Suren A. Chilingaryan
Add build information
78
#	set(PCILIB_REVISION_MODIFICATIONS ${_output})
79
    endif (${_retcode} EQUAL 0)
398 by Suren A. Chilingaryan
Fix also building of driver for bazaar-exported zip archives
80
endif(BAZAAR_FOUND AND EXISTS ${PCILIB_SOURCE_DIR}/.bzr)
348 by Suren A. Chilingaryan
Add build information
81
351 by Suren A. Chilingaryan
Fix build system
82
configure_file(${PCILIB_SOURCE_DIR}/pcilib/build.h.in ${PCILIB_BINARY_DIR}/pcilib/build.h)