aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom <git@thomastrapp.com>2021-11-09 09:45:21 +0100
committerTom <git@thomastrapp.com>2021-11-09 09:45:21 +0100
commitb3a1aedfcd3fa348eb72b66148be0da6d2dbdc92 (patch)
tree89b9ca889627e662c0a77940e0b81e76f8ed1eaa
parent98a52a4d76557d5adb2c58d1ec9f018389b2c4de (diff)
downloadlibconfig-b3a1aedfcd3fa348eb72b66148be0da6d2dbdc92.tar.gz
Fix locale handling when building with cmake
* Add `check_symbol_exists` for locale handling (it was commented out before) * Mac OS: use header "xlocale.h" for checks * Apply the result of these checks not only to `libconfig`, but also `libconfig++` * This fixes the build warning "No way to modify calling thread's locale!" * This also fixes the memory leak on Mac OS as described in issue #212.
-rw-r--r--lib/CMakeLists.txt32
1 files changed, 22 insertions, 10 deletions
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index fb7f095..709a1b5 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -58,10 +58,6 @@ 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()
@@ -69,19 +65,35 @@ else()
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)