Merge topic 'configure_file-unicode'
98383f80 Unicode: check encoding of files given to configure_file.
This commit is contained in:
commit
565213c1fd
@ -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;
|
||||
|
@ -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)
|
||||
|
3
Tests/RunCMake/configure_file/CMakeLists.txt
Normal file
3
Tests/RunCMake/configure_file/CMakeLists.txt
Normal file
@ -0,0 +1,3 @@
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
project(${RunCMake_TEST} NONE)
|
||||
include(${RunCMake_TEST}.cmake)
|
2
Tests/RunCMake/configure_file/NO-BOM.cmake
Normal file
2
Tests/RunCMake/configure_file/NO-BOM.cmake
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
configure_file(NO-BOM.txt.in ${CMAKE_CURRENT_BINARY_DIR}/NO-BOM.txt)
|
1
Tests/RunCMake/configure_file/NO-BOM.txt.in
Normal file
1
Tests/RunCMake/configure_file/NO-BOM.txt.in
Normal file
@ -0,0 +1 @@
|
||||
Hello World
|
8
Tests/RunCMake/configure_file/RunCMakeTest.cmake
Normal file
8
Tests/RunCMake/configure_file/RunCMakeTest.cmake
Normal file
@ -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)
|
1
Tests/RunCMake/configure_file/UTF16BE-BOM-result.txt
Normal file
1
Tests/RunCMake/configure_file/UTF16BE-BOM-result.txt
Normal file
@ -0,0 +1 @@
|
||||
1
|
6
Tests/RunCMake/configure_file/UTF16BE-BOM-stderr.txt
Normal file
6
Tests/RunCMake/configure_file/UTF16BE-BOM-stderr.txt
Normal file
@ -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\)
|
2
Tests/RunCMake/configure_file/UTF16BE-BOM.cmake
Normal file
2
Tests/RunCMake/configure_file/UTF16BE-BOM.cmake
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
configure_file(UTF16BE-BOM.txt.in ${CMAKE_CURRENT_BINARY_DIR}/UTF16BE-BOM.txt)
|
BIN
Tests/RunCMake/configure_file/UTF16BE-BOM.txt.in
Normal file
BIN
Tests/RunCMake/configure_file/UTF16BE-BOM.txt.in
Normal file
Binary file not shown.
1
Tests/RunCMake/configure_file/UTF16LE-BOM-result.txt
Normal file
1
Tests/RunCMake/configure_file/UTF16LE-BOM-result.txt
Normal file
@ -0,0 +1 @@
|
||||
1
|
6
Tests/RunCMake/configure_file/UTF16LE-BOM-stderr.txt
Normal file
6
Tests/RunCMake/configure_file/UTF16LE-BOM-stderr.txt
Normal file
@ -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\)
|
2
Tests/RunCMake/configure_file/UTF16LE-BOM.cmake
Normal file
2
Tests/RunCMake/configure_file/UTF16LE-BOM.cmake
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
configure_file(UTF16LE-BOM.txt.in ${CMAKE_CURRENT_BINARY_DIR}/UTF16LE-BOM.txt)
|
BIN
Tests/RunCMake/configure_file/UTF16LE-BOM.txt.in
Normal file
BIN
Tests/RunCMake/configure_file/UTF16LE-BOM.txt.in
Normal file
Binary file not shown.
1
Tests/RunCMake/configure_file/UTF32BE-BOM-result.txt
Normal file
1
Tests/RunCMake/configure_file/UTF32BE-BOM-result.txt
Normal file
@ -0,0 +1 @@
|
||||
1
|
6
Tests/RunCMake/configure_file/UTF32BE-BOM-stderr.txt
Normal file
6
Tests/RunCMake/configure_file/UTF32BE-BOM-stderr.txt
Normal file
@ -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\)
|
2
Tests/RunCMake/configure_file/UTF32BE-BOM.cmake
Normal file
2
Tests/RunCMake/configure_file/UTF32BE-BOM.cmake
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
configure_file(UTF32BE-BOM.txt.in ${CMAKE_CURRENT_BINARY_DIR}/UTF32BE-BOM.txt)
|
BIN
Tests/RunCMake/configure_file/UTF32BE-BOM.txt.in
Normal file
BIN
Tests/RunCMake/configure_file/UTF32BE-BOM.txt.in
Normal file
Binary file not shown.
1
Tests/RunCMake/configure_file/UTF32LE-BOM-result.txt
Normal file
1
Tests/RunCMake/configure_file/UTF32LE-BOM-result.txt
Normal file
@ -0,0 +1 @@
|
||||
1
|
6
Tests/RunCMake/configure_file/UTF32LE-BOM-stderr.txt
Normal file
6
Tests/RunCMake/configure_file/UTF32LE-BOM-stderr.txt
Normal file
@ -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\)
|
2
Tests/RunCMake/configure_file/UTF32LE-BOM.cmake
Normal file
2
Tests/RunCMake/configure_file/UTF32LE-BOM.cmake
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
configure_file(UTF32LE-BOM.txt.in ${CMAKE_CURRENT_BINARY_DIR}/UTF32LE-BOM.txt)
|
BIN
Tests/RunCMake/configure_file/UTF32LE-BOM.txt.in
Normal file
BIN
Tests/RunCMake/configure_file/UTF32LE-BOM.txt.in
Normal file
Binary file not shown.
2
Tests/RunCMake/configure_file/UTF8-BOM.cmake
Normal file
2
Tests/RunCMake/configure_file/UTF8-BOM.cmake
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
configure_file(UTF8-BOM.txt.in ${CMAKE_CURRENT_BINARY_DIR}/UTF8-BOM.txt)
|
1
Tests/RunCMake/configure_file/UTF8-BOM.txt.in
Normal file
1
Tests/RunCMake/configure_file/UTF8-BOM.txt.in
Normal file
@ -0,0 +1 @@
|
||||
Hello World
|
Loading…
x
Reference in New Issue
Block a user