Skip to content

Commit

Permalink
Merge pull request hyperrealm#213 from thomastrapp/master
Browse files Browse the repository at this point in the history
Fix locale handling when building with cmake
  • Loading branch information
hyperrealm authored Nov 9, 2021
2 parents 98a52a4 + b3a1aed commit 020a9ce
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,30 +58,42 @@ set_target_properties(${libname}++
VERSION "${libconfig_VERSION}"
PUBLIC_HEADER "${libinc_cpp}")

#check_symbol_exists(uselocale "locale.h" HAVE_USELOCALE)
#check_symbol_exists(newlocale "locale.h" HAVE_NEWLOCALE)
#check_symbol_exists(freelocale "locale.h" HAVE_FREELOCALE)

if(BUILD_SHARED_LIBS)
target_compile_definitions(${libname}++ PRIVATE LIBCONFIG_STATIC)
else()
target_compile_definitions(${libname} PUBLIC LIBCONFIG_STATIC)
target_compile_definitions(${libname}++ PUBLIC LIBCONFIGXX_STATIC)
endif()

if(APPLE)
check_symbol_exists(uselocale "xlocale.h" HAVE_USELOCALE)
check_symbol_exists(newlocale "xlocale.h" HAVE_NEWLOCALE)
check_symbol_exists(freelocale "xlocale.h" HAVE_FREELOCALE)
else()
check_symbol_exists(uselocale "locale.h" HAVE_USELOCALE)
check_symbol_exists(newlocale "locale.h" HAVE_NEWLOCALE)
check_symbol_exists(freelocale "locale.h" HAVE_FREELOCALE)
endif()

if(HAVE_USELOCALE)
target_compile_definitions(${libname}
PRIVATE "HAVE_USELOCALE")
target_compile_definitions(${libname}
PRIVATE "HAVE_USELOCALE")
target_compile_definitions(${libname}++
PRIVATE "HAVE_USELOCALE")
endif()

if(HAVE_NEWLOCALE)
target_compile_definitions(${libname}
PRIVATE "HAVE_NEWLOCALE")
target_compile_definitions(${libname}
PRIVATE "HAVE_NEWLOCALE")
target_compile_definitions(${libname}++
PRIVATE "HAVE_NEWLOCALE")
endif()

if(HAVE_FREELOCALE)
target_compile_definitions(${libname}
PRIVATE "HAVE_FREELOCALE")
target_compile_definitions(${libname}
PRIVATE "HAVE_FREELOCALE")
target_compile_definitions(${libname}++
PRIVATE "HAVE_FREELOCALE")
endif()

if(MSVC)
Expand Down

0 comments on commit 020a9ce

Please sign in to comment.