-
Notifications
You must be signed in to change notification settings - Fork 12
/
CMakeLists.txt
53 lines (46 loc) · 1.97 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
project(ProtocolDescription)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(UtilGit)
find_package(Git REQUIRED)
Set(D16 "[0-9a-f]") # matches a (lower-case) hexadecimal digit
# Matches the a dev version postfix (".1-<#commits>-g<SHA1> <branch>")
Set(VERSION_REGEX "-([0-9]+)-g(${D16}${D16}${D16}${D16}${D16}${D16}${D16})")
Git_Util_Describe(VERSION "${CMAKE_CURRENT_SOURCE_DIR}" "*")
if("${VERSION}" MATCHES "${VERSION_REGEX}")
message(STATUS "Develop version ${VERSION}")
set(RELEASE FALSE)
else()
message(STATUS "Release version ${VERSION}")
set(RELEASE TRUE)
endif()
find_program( XSLTPROC xsltproc )
cmake_minimum_required(VERSION 2.8)
message( STATUS "${XSLTPROC}" )
if( NOT EXISTS ${XSLTPROC} )
message(FATAL_ERROR "xsltproc not found, can't continue!")
endif()
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ProtocolDescription.html
COMMAND ${XSLTPROC} ${CMAKE_CURRENT_SOURCE_DIR}/ProtocolDescription_xml2html.xsl
${CMAKE_CURRENT_SOURCE_DIR}/ProtocolDescription.xml > ${CMAKE_CURRENT_BINARY_DIR}/ProtocolDescription.html
DEPENDS ProtocolDescription.xml ProtocolDescription_xml2html.xsl
)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/index.html
COMMAND ${XSLTPROC} ${CMAKE_CURRENT_SOURCE_DIR}/index.xsl
${CMAKE_CURRENT_SOURCE_DIR}/ProtocolDescription.xml > ${CMAKE_CURRENT_BINARY_DIR}/index.html
DEPENDS ProtocolDescription.xml index.xsl
)
add_custom_target(docs ALL
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/index.html ${CMAKE_CURRENT_BINARY_DIR}/ProtocolDescription.html
)
if(RELEASE)
set(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/releases/${VERSION}")
add_custom_command(TARGET docs POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${OUTPUT}
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/ProtocolDescription.html ${OUTPUT}/ProtocolDescription.html
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/index.html ${OUTPUT}/index.html
COMMENT "created ${VERSION} release folder"
)
add_dependencies(docs test)
endif()