Debian Codegraph @

doc/news/changes/create_changes_h.cmake

raw
1 ## ------------------------------------------------------------------------
2 ##
3 ## Copyright (C) 2016 - 2022 by the deal.II Authors
4 ##
5 ## This file is part of the deal.II library.
6 ##
7 ## Part of the source code is dual licensed under Apache-2.0 WITH
8 ## LLVM-exception OR LGPL-2.1-or-later. Detailed license information
9 ## governing the source code and code contributions can be found in
10 ## LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
11 ##
12 ## ------------------------------------------------------------------------
13
14 # Auxiliary functions
15 function(cat IN_FILE OUT_FILE INDENT)
16 file(READ ${IN_FILE} CONTENTS)
17 if(${INDENT} MATCHES "TRUE")
18 file(STRINGS ${IN_FILE} LINESTMP)
19 foreach(LINETMP ${LINESTMP})
20 file(APPEND ${OUT_FILE} " ${LINETMP}\n")
21 endforeach()
22 else()
23 file(APPEND ${OUT_FILE} "${CONTENTS}")
24 endif()
25 endfunction()
26
27 function(process IN_DIR OUT_FILE)
28 file(APPEND ${OUT_FILE} "<ol>\n")
29 file(GLOB ENTRY_LIST ${IN_DIR}/[0-9]*)
30 list(SORT ENTRY_LIST)
31 list(REVERSE ENTRY_LIST)
32 foreach(ENTRY ${ENTRY_LIST})
33 file(APPEND ${OUT_FILE} "\n <li>\n")
34 CAT(${ENTRY} ${OUT_FILE} "TRUE")
35 file(APPEND ${OUT_FILE} " </li>\n")
36 endforeach()
37 file(APPEND ${OUT_FILE} "\n</ol>\n")
38 endfunction()
39
40 # Generate 'changes.h'.
41
42 # First, create a file 'changes.h.in' based on all changelog fragments.
43 set(OUTPUT_FILE_TEMP "${OUTPUT_FILE}.in")
44 file(WRITE ${OUTPUT_FILE_TEMP} "")
45 CAT (${CMAKE_CURRENT_SOURCE_DIR}/header
46 ${OUTPUT_FILE_TEMP} "FALSE")
47 CAT (${CMAKE_CURRENT_SOURCE_DIR}/header_incompatibilities
48 ${OUTPUT_FILE_TEMP} "FALSE")
49 PROCESS(${CMAKE_CURRENT_SOURCE_DIR}/incompatibilities
50 ${OUTPUT_FILE_TEMP})
51 CAT (${CMAKE_CURRENT_SOURCE_DIR}/header_major
52 ${OUTPUT_FILE_TEMP} "FALSE")
53 PROCESS(${CMAKE_CURRENT_SOURCE_DIR}/major
54 ${OUTPUT_FILE_TEMP})
55 CAT (${CMAKE_CURRENT_SOURCE_DIR}/header_minor
56 ${OUTPUT_FILE_TEMP} "FALSE")
57 PROCESS(${CMAKE_CURRENT_SOURCE_DIR}/minor
58 ${OUTPUT_FILE_TEMP})
59 CAT (${CMAKE_CURRENT_SOURCE_DIR}/footer
60 ${OUTPUT_FILE_TEMP} "FALSE")
61
62 # Copy it over to 'changes.h' but only touch the time stamp
63 # if the file actually changed (this is what CONFIGURE_FILE does).
64 message(STATUS "Generating changelog file: ${OUTPUT_FILE}")
65 configure_file(${OUTPUT_FILE_TEMP} ${OUTPUT_FILE} COPYONLY)