Skip to content

Commit

Permalink
minimal cmake example
Browse files Browse the repository at this point in the history
  • Loading branch information
MrCyjaneK committed Apr 22, 2024
1 parent 36e6143 commit bf759f7
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
1 change: 1 addition & 0 deletions example/cmake/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
64 changes: 64 additions & 0 deletions example/cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
cmake_minimum_required(VERSION 3.1...3.29.2)

include(CMakePrintHelpers)

set(MONERO_C_COMMIT 36e61433c78750317ced29f0fc94ad22af16111d)
set(MONERO_C_MIRROR https://git.mrcyjanek.net/mrcyjanek/monero_c)
set(MONERO_C_WOWNERO OFF)
set(MONERO_C_MONERO ON)


cmake_print_variables(MONERO_C_COMMIT)
cmake_print_variables(MONERO_C_MIRROR)
cmake_print_variables(MONERO_C_MONERO)
cmake_print_variables(MONERO_C_WOWNERO)

project(
monero_c
VERSION 0.0.0)

if(NOT EXISTS monero_c)
execute_process(COMMAND git clone https://git.mrcyjanek.net/mrcyjanek/monero_c)
endif()

execute_process(WORKING_DIRECTORY monero_c COMMAND git checkout ${MONERO_C_COMMIT})
execute_process(WORKING_DIRECTORY monero_c COMMAND git submodule update --recursive --force --init)

execute_process(COMMAND rm monero_c/monero/.patch-applied)
execute_process(COMMAND rm monero_c/wownero/.patch-applied)

# apply patches

if (MONERO_C_MONERO)
execute_process(WORKING_DIRECTORY monero_c COMMAND ./apply_patches.sh monero)
endif()

if (MONERO_C_WOWNERO)
execute_process(WORKING_DIRECTORY monero_c COMMAND ./apply_patches.sh wownero)
endif()

# actually.. build the software
if (MONERO_C_MONERO)
add_custom_command(
COMMAND ./build_single.sh monero host-apple-darwin -j8
OUTPUT monero_c/release/monero/host-apple-darwin_libwallet2_api_c.dylib.xz
WORKING_DIRECTORY monero_c
)

add_custom_command(
COMMAND unxz -f monero_c/release/monero/host-apple-darwin_libwallet2_api_c.dylib.xz
OUTPUT monero_c/release/monero/host-apple-darwin_libwallet2_api_c.dylib
DEPENDS monero_c/release/monero/host-apple-darwin_libwallet2_api_c.dylib.xz
)

add_custom_command(
COMMAND mv monero_c/release/monero/host-apple-darwin_libwallet2_api_c.dylib monero_host-apple-darwin_libwallet2_api_c.dylib
OUTPUT host-apple-darwin_monero_libwallet2_api_c.dylib
DEPENDS monero_c/release/monero/host-apple-darwin_libwallet2_api_c.dylib
)
endif()

add_custom_target(
.host-apple-darwin_monero_libwallet2_api_c.dylib ALL
DEPENDS host-apple-darwin_monero_libwallet2_api_c.dylib
)

0 comments on commit bf759f7

Please sign in to comment.