aboutsummaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorMike Taves <mwtoews@gmail.com>2021-05-09 00:09:56 +1200
committerGitHub <noreply@github.com>2021-05-09 00:09:56 +1200
commit592a6017bc08d453a9a58c97a8f568105b31bdbb (patch)
tree59087838a3e36983573ffe149c6ca949bc4c2b92 /cmake
parent641ee7029c6cd6271ab5b2229f564892ca2b3750 (diff)
downloadPROJ-592a6017bc08d453a9a58c97a8f568105b31bdbb.tar.gz
PROJ-592a6017bc08d453a9a58c97a8f568105b31bdbb.zip
CMake: "make dist" workalike via CPack (#2690)
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})