Encoding: Provide option to configure CMake to use UTF-8 encoding.
This commit is contained in:
parent
82a7d54cfe
commit
91fd99b865
|
@ -36,6 +36,13 @@ if("${CMake_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
|
|||
endmacro()
|
||||
endif()
|
||||
|
||||
# option to set the internal encoding of CMake to UTF-8
|
||||
option(CMAKE_ENCODING_UTF8 "Use UTF-8 encoding internally (experimental)." OFF)
|
||||
mark_as_advanced(CMAKE_ENCODING_UTF8)
|
||||
if(CMAKE_ENCODING_UTF8)
|
||||
set(KWSYS_ENCODING_DEFAULT_CODEPAGE CP_UTF8)
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# a macro to deal with system libraries, implemented as a macro
|
||||
# simply to improve readability of the main script
|
||||
|
|
|
@ -24,6 +24,11 @@ endif()
|
|||
|
||||
set(EXECUTABLE_OUTPUT_PATH ${CMake_BIN_DIR})
|
||||
|
||||
# ensure Unicode friendly APIs are used on Windows
|
||||
if(WIN32)
|
||||
add_definitions(-DUNICODE -D_UNICODE)
|
||||
endif()
|
||||
|
||||
# configure the .h file
|
||||
configure_file(
|
||||
"${CMake_SOURCE_DIR}/Source/cmConfigure.cmake.h.in"
|
||||
|
|
|
@ -55,11 +55,6 @@ else()
|
|||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
if(WIN32 AND KWSYS_ENCODING_DEFAULT_CODEPAGE MATCHES CP_UTF8)
|
||||
add_definitions(-DKWSYS_CP_UTF8)
|
||||
endif()
|
||||
|
||||
set(SRCS
|
||||
AddCacheEntry.cxx
|
||||
AddCacheEntry.h
|
||||
|
|
|
@ -79,7 +79,7 @@ int main(int argc, char** argv)
|
|||
|
||||
QApplication app(argc, argv);
|
||||
|
||||
#if defined(KWSYS_CP_UTF8)
|
||||
#if defined(CMAKE_ENCODING_UTF8)
|
||||
QTextCodec* utf8_codec = QTextCodec::codecForName("UTF-8");
|
||||
QTextCodec::setCodecForCStrings(utf8_codec);
|
||||
QTextCodec::setCodecForLocale(utf8_codec);
|
||||
|
|
|
@ -16,4 +16,5 @@
|
|||
#cmakedefine HAVE_ENVIRON_NOT_REQUIRE_PROTOTYPE
|
||||
#cmakedefine HAVE_UNSETENV
|
||||
#cmakedefine CMAKE_USE_ELF_PARSER
|
||||
#cmakedefine CMAKE_ENCODING_UTF8
|
||||
#define CMAKE_DATA_DIR "/@CMAKE_DATA_DIR@"
|
||||
|
|
Loading…
Reference in New Issue