Skip to content

Commit 7d9bcdb

Browse files
committed
Update platform-specific linking in storage examples
Refined CMake platform checks for storage_c_example and storage_example to handle Android, iOS, Linux, OHOS, and Apple platforms more accurately. Added OpenSSL and pthread linking for Linux, and clarified that Android and OHOS do not require OpenSSL due to stub implementations.
1 parent 6df14b5 commit 7d9bcdb

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

examples/storage_c_example/CMakeLists.txt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,18 @@ add_executable(storage_c_example main.c)
1212
target_link_libraries(storage_c_example PRIVATE nativeapi)
1313

1414
# Platform-specific settings
15-
if(APPLE)
15+
if(ANDROID)
16+
# Android platform doesn't need OpenSSL (secure_storage is stub implementation)
17+
elseif(CMAKE_SYSTEM_NAME STREQUAL "iOS")
18+
target_link_libraries(storage_c_example PRIVATE "-framework Security")
19+
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
20+
find_package(PkgConfig REQUIRED)
21+
pkg_check_modules(OPENSSL REQUIRED IMPORTED_TARGET openssl)
22+
target_link_libraries(storage_c_example PRIVATE PkgConfig::OPENSSL pthread)
23+
elseif(APPLE)
1624
target_link_libraries(storage_c_example PRIVATE "-framework Cocoa" "-framework Security")
25+
elseif(CMAKE_SYSTEM_NAME STREQUAL "OHOS")
26+
# OHOS platform doesn't need OpenSSL (secure_storage is stub implementation)
1727
elseif(WIN32)
1828
target_link_libraries(storage_c_example PRIVATE user32 shell32 dwmapi gdiplus crypt32)
1929
elseif(UNIX)

examples/storage_example/CMakeLists.txt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,18 @@ add_executable(storage_example main.cpp)
1212
target_link_libraries(storage_example PRIVATE nativeapi)
1313

1414
# Platform-specific settings
15-
if(APPLE)
15+
if(ANDROID)
16+
# Android platform doesn't need OpenSSL (secure_storage is stub implementation)
17+
elseif(CMAKE_SYSTEM_NAME STREQUAL "iOS")
18+
target_link_libraries(storage_example PRIVATE "-framework Security")
19+
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
20+
find_package(PkgConfig REQUIRED)
21+
pkg_check_modules(OPENSSL REQUIRED IMPORTED_TARGET openssl)
22+
target_link_libraries(storage_example PRIVATE PkgConfig::OPENSSL pthread)
23+
elseif(APPLE)
1624
target_link_libraries(storage_example PRIVATE "-framework Cocoa" "-framework Security")
25+
elseif(CMAKE_SYSTEM_NAME STREQUAL "OHOS")
26+
# OHOS platform doesn't need OpenSSL (secure_storage is stub implementation)
1727
elseif(WIN32)
1828
target_link_libraries(storage_example PRIVATE user32 shell32 dwmapi gdiplus crypt32)
1929
elseif(UNIX)

0 commit comments

Comments
 (0)