summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/cmMakefile.cxx14
-rw-r--r--Tests/RunCMake/CMakeLists.txt1
-rw-r--r--Tests/RunCMake/configure_file/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/configure_file/NO-BOM.cmake2
-rw-r--r--Tests/RunCMake/configure_file/NO-BOM.txt.in1
-rw-r--r--Tests/RunCMake/configure_file/RunCMakeTest.cmake8
-rw-r--r--Tests/RunCMake/configure_file/UTF16BE-BOM-result.txt1
-rw-r--r--Tests/RunCMake/configure_file/UTF16BE-BOM-stderr.txt6
-rw-r--r--Tests/RunCMake/configure_file/UTF16BE-BOM.cmake2
-rw-r--r--Tests/RunCMake/configure_file/UTF16BE-BOM.txt.inbin0 -> 26 bytes
-rw-r--r--Tests/RunCMake/configure_file/UTF16LE-BOM-result.txt1
-rw-r--r--Tests/RunCMake/configure_file/UTF16LE-BOM-stderr.txt6
-rw-r--r--Tests/RunCMake/configure_file/UTF16LE-BOM.cmake2
-rw-r--r--Tests/RunCMake/configure_file/UTF16LE-BOM.txt.inbin0 -> 26 bytes
-rw-r--r--Tests/RunCMake/configure_file/UTF32BE-BOM-result.txt1
-rw-r--r--Tests/RunCMake/configure_file/UTF32BE-BOM-stderr.txt6
-rw-r--r--Tests/RunCMake/configure_file/UTF32BE-BOM.cmake2
-rw-r--r--Tests/RunCMake/configure_file/UTF32BE-BOM.txt.inbin0 -> 52 bytes
-rw-r--r--Tests/RunCMake/configure_file/UTF32LE-BOM-result.txt1
-rw-r--r--Tests/RunCMake/configure_file/UTF32LE-BOM-stderr.txt6
-rw-r--r--Tests/RunCMake/configure_file/UTF32LE-BOM.cmake2
-rw-r--r--Tests/RunCMake/configure_file/UTF32LE-BOM.txt.inbin0 -> 52 bytes
-rw-r--r--Tests/RunCMake/configure_file/UTF8-BOM.cmake2
-rw-r--r--Tests/RunCMake/configure_file/UTF8-BOM.txt.in1
-rwxr-xr-xbootstrap1
25 files changed, 69 insertions, 0 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 93a06f0..f82acc8 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -3526,6 +3526,20 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile,
return 0;
}
+ cmsys::FStream::BOM bom = cmsys::FStream::ReadBOM(fin);
+ if(bom != cmsys::FStream::BOM_None &&
+ bom != cmsys::FStream::BOM_UTF8)
+ {
+ cmOStringStream e;
+ e << "File starts with a Byte-Order-Mark that is not UTF-8:\n "
+ << sinfile;
+ this->IssueMessage(cmake::FATAL_ERROR, e.str());
+ return 0;
+ }
+ // rewind to copy BOM to output file
+ fin.seekg(0);
+
+
// now copy input to output and expand variables in the
// input file at the same time
std::string inLine;
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index f9d590a..7691f32 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -96,6 +96,7 @@ add_RunCMake_test(TargetPolicies)
add_RunCMake_test(alias_targets)
add_RunCMake_test(interface_library)
add_RunCMake_test(no_install_prefix)
+add_RunCMake_test(configure_file)
find_package(Qt4 QUIET)
find_package(Qt5Core QUIET)
diff --git a/Tests/RunCMake/configure_file/CMakeLists.txt b/Tests/RunCMake/configure_file/CMakeLists.txt
new file mode 100644
index 0000000..2897109
--- /dev/null
+++ b/Tests/RunCMake/configure_file/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.0)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/configure_file/NO-BOM.cmake b/Tests/RunCMake/configure_file/NO-BOM.cmake
new file mode 100644
index 0000000..003d526
--- /dev/null
+++ b/Tests/RunCMake/configure_file/NO-BOM.cmake
@@ -0,0 +1,2 @@
+
+configure_file(NO-BOM.txt.in ${CMAKE_CURRENT_BINARY_DIR}/NO-BOM.txt)
diff --git a/Tests/RunCMake/configure_file/NO-BOM.txt.in b/Tests/RunCMake/configure_file/NO-BOM.txt.in
new file mode 100644
index 0000000..557db03
--- /dev/null
+++ b/Tests/RunCMake/configure_file/NO-BOM.txt.in
@@ -0,0 +1 @@
+Hello World
diff --git a/Tests/RunCMake/configure_file/RunCMakeTest.cmake b/Tests/RunCMake/configure_file/RunCMakeTest.cmake
new file mode 100644
index 0000000..c8bfa57
--- /dev/null
+++ b/Tests/RunCMake/configure_file/RunCMakeTest.cmake
@@ -0,0 +1,8 @@
+include(RunCMake)
+
+run_cmake(NO-BOM)
+run_cmake(UTF8-BOM)
+run_cmake(UTF16LE-BOM)
+run_cmake(UTF16BE-BOM)
+run_cmake(UTF32LE-BOM)
+run_cmake(UTF32BE-BOM)
diff --git a/Tests/RunCMake/configure_file/UTF16BE-BOM-result.txt b/Tests/RunCMake/configure_file/UTF16BE-BOM-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF16BE-BOM-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/configure_file/UTF16BE-BOM-stderr.txt b/Tests/RunCMake/configure_file/UTF16BE-BOM-stderr.txt
new file mode 100644
index 0000000..5132c4d
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF16BE-BOM-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at UTF16BE-BOM.cmake:2 \(configure_file\):
+ File starts with a Byte-Order-Mark that is not UTF-8:
+
+ .*/Tests/RunCMake/configure_file/UTF16BE-BOM.txt.in
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/configure_file/UTF16BE-BOM.cmake b/Tests/RunCMake/configure_file/UTF16BE-BOM.cmake
new file mode 100644
index 0000000..c570742
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF16BE-BOM.cmake
@@ -0,0 +1,2 @@
+
+configure_file(UTF16BE-BOM.txt.in ${CMAKE_CURRENT_BINARY_DIR}/UTF16BE-BOM.txt)
diff --git a/Tests/RunCMake/configure_file/UTF16BE-BOM.txt.in b/Tests/RunCMake/configure_file/UTF16BE-BOM.txt.in
new file mode 100644
index 0000000..70fd9cb
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF16BE-BOM.txt.in
Binary files differ
diff --git a/Tests/RunCMake/configure_file/UTF16LE-BOM-result.txt b/Tests/RunCMake/configure_file/UTF16LE-BOM-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF16LE-BOM-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/configure_file/UTF16LE-BOM-stderr.txt b/Tests/RunCMake/configure_file/UTF16LE-BOM-stderr.txt
new file mode 100644
index 0000000..8f997bc
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF16LE-BOM-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at UTF16LE-BOM.cmake:2 \(configure_file\):
+ File starts with a Byte-Order-Mark that is not UTF-8:
+
+ .*/Tests/RunCMake/configure_file/UTF16LE-BOM.txt.in
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/configure_file/UTF16LE-BOM.cmake b/Tests/RunCMake/configure_file/UTF16LE-BOM.cmake
new file mode 100644
index 0000000..05c9cd7
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF16LE-BOM.cmake
@@ -0,0 +1,2 @@
+
+configure_file(UTF16LE-BOM.txt.in ${CMAKE_CURRENT_BINARY_DIR}/UTF16LE-BOM.txt)
diff --git a/Tests/RunCMake/configure_file/UTF16LE-BOM.txt.in b/Tests/RunCMake/configure_file/UTF16LE-BOM.txt.in
new file mode 100644
index 0000000..036f8c5
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF16LE-BOM.txt.in
Binary files differ
diff --git a/Tests/RunCMake/configure_file/UTF32BE-BOM-result.txt b/Tests/RunCMake/configure_file/UTF32BE-BOM-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF32BE-BOM-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/configure_file/UTF32BE-BOM-stderr.txt b/Tests/RunCMake/configure_file/UTF32BE-BOM-stderr.txt
new file mode 100644
index 0000000..12811aa
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF32BE-BOM-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at UTF32BE-BOM.cmake:2 \(configure_file\):
+ File starts with a Byte-Order-Mark that is not UTF-8:
+
+ .*/Tests/RunCMake/configure_file/UTF32BE-BOM.txt.in
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/configure_file/UTF32BE-BOM.cmake b/Tests/RunCMake/configure_file/UTF32BE-BOM.cmake
new file mode 100644
index 0000000..0c6ea87
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF32BE-BOM.cmake
@@ -0,0 +1,2 @@
+
+configure_file(UTF32BE-BOM.txt.in ${CMAKE_CURRENT_BINARY_DIR}/UTF32BE-BOM.txt)
diff --git a/Tests/RunCMake/configure_file/UTF32BE-BOM.txt.in b/Tests/RunCMake/configure_file/UTF32BE-BOM.txt.in
new file mode 100644
index 0000000..c87cfd5
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF32BE-BOM.txt.in
Binary files differ
diff --git a/Tests/RunCMake/configure_file/UTF32LE-BOM-result.txt b/Tests/RunCMake/configure_file/UTF32LE-BOM-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF32LE-BOM-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/configure_file/UTF32LE-BOM-stderr.txt b/Tests/RunCMake/configure_file/UTF32LE-BOM-stderr.txt
new file mode 100644
index 0000000..fa9e01a
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF32LE-BOM-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at UTF32LE-BOM.cmake:2 \(configure_file\):
+ File starts with a Byte-Order-Mark that is not UTF-8:
+
+ .*/Tests/RunCMake/configure_file/UTF32LE-BOM.txt.in
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/configure_file/UTF32LE-BOM.cmake b/Tests/RunCMake/configure_file/UTF32LE-BOM.cmake
new file mode 100644
index 0000000..b6351b0
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF32LE-BOM.cmake
@@ -0,0 +1,2 @@
+
+configure_file(UTF32LE-BOM.txt.in ${CMAKE_CURRENT_BINARY_DIR}/UTF32LE-BOM.txt)
diff --git a/Tests/RunCMake/configure_file/UTF32LE-BOM.txt.in b/Tests/RunCMake/configure_file/UTF32LE-BOM.txt.in
new file mode 100644
index 0000000..27c8183
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF32LE-BOM.txt.in
Binary files differ
diff --git a/Tests/RunCMake/configure_file/UTF8-BOM.cmake b/Tests/RunCMake/configure_file/UTF8-BOM.cmake
new file mode 100644
index 0000000..af2adae
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF8-BOM.cmake
@@ -0,0 +1,2 @@
+
+configure_file(UTF8-BOM.txt.in ${CMAKE_CURRENT_BINARY_DIR}/UTF8-BOM.txt)
diff --git a/Tests/RunCMake/configure_file/UTF8-BOM.txt.in b/Tests/RunCMake/configure_file/UTF8-BOM.txt.in
new file mode 100644
index 0000000..abc0aca
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF8-BOM.txt.in
@@ -0,0 +1 @@
+Hello World
diff --git a/bootstrap b/bootstrap
index 69dcbce..4e61f3e 100755
--- a/bootstrap
+++ b/bootstrap
@@ -329,6 +329,7 @@ fi
KWSYS_CXX_SOURCES="\
Directory \
EncodingCXX \
+ FStream \
Glob \
RegularExpression \
SystemTools"