From: Sebastian Pipping Date: Fri, 11 Oct 2019 21:22:49 +0000 (+0200) Subject: CMake: Catch troublesome build combinations for -DEXPAT_CHAR_TYPE=wchar_t X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f2d53fb6cd024768d6406fad9a630551ab24f579;p=libexpat CMake: Catch troublesome build combinations for -DEXPAT_CHAR_TYPE=wchar_t --- diff --git a/expat/CMakeLists.txt b/expat/CMakeLists.txt index 72c3212c..6a2d291d 100644 --- a/expat/CMakeLists.txt +++ b/expat/CMakeLists.txt @@ -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()