-
-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Yuki Kishimoto <[email protected]>
- Loading branch information
Showing
6 changed files
with
89 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Minimum CMake version required | ||
cmake_minimum_required(VERSION 3.10) | ||
|
||
# Project Name | ||
project(NostrSDK) | ||
|
||
# Add your Rust library as a CMake target | ||
add_custom_target(nostr_sdk ALL | ||
COMMAND cargo build --release | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
) | ||
|
||
# Determine the library file extension based on the platform | ||
if(WIN32) | ||
set(LIBRARY_FILE "nostr_sdk_c.dll") | ||
elseif(APPLE) | ||
set(LIBRARY_FILE "libnostr_sdk_c.dylib") | ||
else() | ||
set(LIBRARY_FILE "libnostr_sdk_c.so") | ||
endif() | ||
|
||
# Path to the generated header and library | ||
set(HEADER_PATH "${CMAKE_CURRENT_SOURCE_DIR}/include") | ||
set(LIB_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../target/release") | ||
|
||
# Export the library's include directory | ||
include_directories(${HEADER_PATH}) | ||
link_directories(${LIB_PATH}) | ||
|
||
add_library(nostr_sdk_interface INTERFACE) | ||
target_include_directories(nostr_sdk_interface INTERFACE ${HEADER_PATH}) | ||
target_link_libraries(nostr_sdk_interface INTERFACE ${LIB_PATH}/${LIBRARY_FILE}) | ||
|
||
# Install header files | ||
install(FILES ${HEADER_PATH}/nostr_sdk.h DESTINATION include) | ||
|
||
# Install the shared library | ||
install(FILES ${LIB_PATH}/${LIBRARY_FILE} DESTINATION lib) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
cmake_minimum_required(VERSION 3.10) | ||
|
||
# Project name | ||
project(Examples) | ||
|
||
# Add the library | ||
add_subdirectory(../ nostr_sdk) | ||
include_directories("../include") | ||
link_directories("../../../target/release") | ||
|
||
# Define the C binaries | ||
add_executable(keys keys.c) | ||
add_dependencies(keys nostr_sdk) | ||
target_link_libraries(keys PRIVATE nostr_sdk_interface) | ||
|
||
add_executable(client client.c) | ||
add_dependencies(client nostr_sdk) | ||
target_link_libraries(client PRIVATE nostr_sdk_interface) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,6 @@ | ||
#!/usr/bin/env just --justfile | ||
|
||
build: | ||
cargo build --release | ||
examples: | ||
cd examples && mkdir -p build && cd build && cmake .. && make | ||
|
||
examples: build | ||
mkdir -p bin/ | ||
gcc examples/keys.c -o bin/keys -I include/ -L ../../target/release/ -lnostr_sdk_c -lpthread -ldl -lm -lrt | ||
gcc examples/client.c -o bin/client -I include/ -L ../../target/release/ -lnostr_sdk_c -lpthread -ldl -lm -lrt | ||
|