Commit 06cd2b31 authored by Mickaël Turnel's avatar Mickaël Turnel

Fix compilation on mac

parent 2aad3158
......@@ -148,15 +148,6 @@ if(CMAKE_VERSION VERSION_LESS 3.1 AND NOT APPLE AND NOT MSVC)
list(APPEND STRICT_OPTIONS_CXX "-std=c++11")
endif()
set(LINK_FLAGS )
if(APPLE)
list(APPEND LINK_FLAGS "-framework Foundation")
if(IOS)
list(APPEND LINK_FLAGS "-framework CoreFoundation" "-framework CFNetwork" "-framework UIKit")
endif()
endif()
string(REPLACE ";" " " LINK_FLAGS_STR "${LINK_FLAGS}")
if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
set(EXPORT_TARGETS_NAME "LinphoneBuilder")
else()
......
......@@ -80,6 +80,9 @@ bc_apply_compile_flags(BCTOOLBOX_OBJC_SOURCE_FILES STRICT_OPTIONS_CPP STRICT_OPT
if(ENABLE_STATIC)
add_library(bctoolbox-static STATIC ${BCTOOLBOX_SOURCE_FILES} ${BCTOOLBOX_HEADER_FILES})
target_link_libraries(bctoolbox-static INTERFACE ${CMAKE_THREAD_LIBS_INIT})
if(APPLE)
target_link_libraries(bctoolbox-static INTERFACE "-framework Foundation" "-framework AVFoundation")
endif()
if(WIN32)
target_link_libraries(bctoolbox-static INTERFACE "Winmm" "Ws2_32")
endif()
......@@ -118,6 +121,9 @@ if(ENABLE_SHARED)
PUBLIC_HEADER "${BCTOOLBOX_HEADER_FILES}"
)
endif()
if(APPLE)
target_link_libraries(bctoolbox PRIVATE "-framework Foundation" "-framework AVFoundation")
endif()
if(WIN32)
if(NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
target_link_libraries(bctoolbox PRIVATE "Winmm" "Ws2_32")
......
......@@ -17,41 +17,39 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#import "config.h"
#endif
#include <algorithm>
#include <unordered_map>
#import <Foundation/Foundation.h>
#import <Foundation/NSString.h>
#include <NSString>
#include <NSStringEncoding>
#include "bctoolbox/logging.h"
#include "bctoolbox/port.h"
#include "bctoolbox/charconv.h"
#import "bctoolbox/logging.h"
#import "bctoolbox/port.h"
#import "bctoolbox/charconv.h"
extern "C" char *bctbx_locale_to_utf8 (const char *str) {
NSString *string = [NSString initWithCString:str encoding:defaultCStringEncoding];
return bctbx_strdup([string cStringUsingEncoding:defaultCStringEncoding]);
NSString *string = [[NSString alloc] initWithCString:str encoding:[NSString defaultCStringEncoding]];
return bctbx_strdup([string UTF8String]);
}
extern "C" char *bctbx_utf8_to_locale (const char *str) {
NSString *string = [NSString initWithUTF8String:str];
return bctbx_strdup([string UTF8String]);
NSString *string = [[NSString alloc] initWithUTF8String:str];
return bctbx_strdup([string cStringUsingEncoding:[NSString defaultCStringEncoding]]);
}
extern "C" char *bctbx_convert_any_to_utf8 (const char *str, const char *encoding) {
if (!encoding)
return NULL;
NSString *encodingString = [NSString initWithCString:encoding encoding:defaultCStringEncoding];
if (encodingString == kCFStringEncodingInvalidId) {
NSString *encodingString = [[NSString alloc] initWithCString:encoding encoding:[NSString defaultCStringEncoding]];
CFStringEncoding stringEncoding = CFStringConvertIANACharSetNameToEncoding((CFStringRef) encodingString);
if (stringEncoding == kCFStringEncodingInvalidId) {
bctbx_error("Error while converting a string from '%s' to 'UTF-8': unknown charset", encoding);
return NULL;
}
NSStringEncoding encodingValue = CFStringConvertEncodingToNSStringEncoding(CFStringConvertIANACharSetNameToEncoding((CFStringRef) encodingString));
NSStringEncoding encodingValue = CFStringConvertEncodingToNSStringEncoding(stringEncoding);
NSString *string = [NSString initWithCString:str encoding:encodingValue];
NSString *string = [[NSString alloc] initWithCString:str encoding:encodingValue];
return bctbx_strdup([string UTF8String]);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment