aboutsummaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake')
-rw-r--r--cmake/Makefile.am1
-rw-r--r--cmake/ProjReadme.cmake28
2 files changed, 29 insertions, 0 deletions
diff --git a/cmake/Makefile.am b/cmake/Makefile.am
index 1ecd784e..cdad1ff8 100644
--- a/cmake/Makefile.am
+++ b/cmake/Makefile.am
@@ -4,6 +4,7 @@ EXTRA_DIST = CMakeLists.txt \
proj_config.cmake.in \
ProjConfig.cmake \
ProjMac.cmake \
+ ProjReadme.cmake \
ProjTest.cmake \
ProjVersion.cmake \
policies.cmake \
diff --git a/cmake/ProjReadme.cmake b/cmake/ProjReadme.cmake
new file mode 100644
index 00000000..7071a381
--- /dev/null
+++ b/cmake/ProjReadme.cmake
@@ -0,0 +1,28 @@
+#
+# CMake script to modify README.md to create simpler README file
+#
+# This is equivalent to: fgrep -v "[!["
+#
+
+set(SourceFile "${PROJ_SOURCE_DIR}/README.md")
+set(DestFile "${PROJ_SOURCE_DIR}/README")
+
+# Below is based on https://stackoverflow.com/a/30227627
+
+file(READ ${SourceFile} Contents)
+
+# Set the variable "Esc" to the ASCII value 27 as a special escape value
+string(ASCII 27 Esc)
+
+# Turn the contents into a list of strings, each ending with Esc
+string(REGEX REPLACE "\n" "${Esc};" ContentsAsList "${Contents}")
+
+unset(ModifiedContents)
+foreach(Line ${ContentsAsList})
+ if(NOT "${Line}" MATCHES "\\[!\\[")
+ # Swap the appended Esc character back out in favour of a line feed
+ string(REGEX REPLACE "${Esc}" "\n" Line ${Line})
+ set(ModifiedContents "${ModifiedContents}${Line}")
+ endif()
+endforeach()
+file(WRITE ${DestFile} ${ModifiedContents})