Skip to content

Commit

Permalink
Make cuchar check test if c32rtomb is present in system
Browse files Browse the repository at this point in the history
Fix for mac build where cuchar is present but uchar.h is not.
  • Loading branch information
suokko committed Jun 22, 2018
1 parent 84f8a75 commit 84b1361
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,19 @@ ${CMAKE_MODULE_PATH}
# generates compile_commands.json, used for autocompletion by some editors
SET(CMAKE_EXPORT_COMPILE_COMMANDS ON)

include(CheckIncludeFileCXX)
CHECK_INCLUDE_FILE_CXX("cuchar" HAVE_CUCHAR)
if(HAVE_CUCHAR)
add_definitions("-DHAVE_CUCHAR")
include(CheckCXXSourceCompiles)
CHECK_CXX_SOURCE_COMPILES("
#include <cstdlib>
#include <cuchar>
int main(void) {
char32_t in = 0;
char out[MB_CUR_MAX];
std::mbstate_t state{};
std::c32rtomb(out, in, &state);
return 0;
}" HAVE_CUCHAR2)
if(HAVE_CUCHAR2)
add_definitions("-DHAVE_CUCHAR")
endif()

# mixing the build system with the source code is ugly and stupid. enforce the opposite :)
Expand Down

0 comments on commit 84b1361

Please sign in to comment.