CMake: Catch troublesome build combinations for -DEXPAT_CHAR_TYPE=wchar_t

This commit is contained in:
Sebastian Pipping 2019-10-11 23:22:49 +02:00
parent db01810bf3
commit f2d53fb6cd

View File

@ -123,6 +123,15 @@ elseif(EXPAT_CHAR_TYPE STREQUAL "ushort")
elseif(EXPAT_CHAR_TYPE STREQUAL "wchar_t")
set(_EXPAT_UNICODE ON)
set(_EXPAT_UNICODE_WCHAR_T ON)
if(NOT WIN32)
string(FIND "${CMAKE_C_FLAGS}" "-fshort-wchar" _expat_short_wchar_found)
if(${_expat_short_wchar_found} EQUAL "-1")
message(SEND_ERROR "Configuration -DEXPAT_CHAR_TYPE=wchar_t requires -DCMAKE_{C,CXX}_FLAGS=-fshort-wchar (which was not found) and libc compiled with -fshort-wchar, too.")
endif()
if (EXPAT_BUILD_TOOLS)
message(SEND_ERROR "The xmlwf tool can not be built with option -DEXPAT_CHAR_TYPE=wchar_t outside of Windows. Please pass -DEXPAT_CHAR_TYPE=char or -DEXPAT_BUILD_TOOLS=OFF.")
endif()
endif()
else()
message(SEND_ERROR "Option -DEXPAT_CHAR_TYPE=(char|ushort|wchar_t) cannot be \"${EXPAT_CHAR_TYPE}\".")
endif()