11project (NitroAvalabsCrypto)
22cmake_minimum_required (VERSION 3.9.0)
33
4- set (PACKAGE_NAME NitroAvalabsCrypto)
5- set (CMAKE_VERBOSE_MAKEFILE ON )
6- set (CMAKE_CXX_STANDARD 20)
4+ set (PACKAGE_NAME NitroAvalabsCrypto)
5+ set (CMAKE_VERBOSE_MAKEFILE ON )
6+ set (CMAKE_CXX_STANDARD 20)
77
88# Define C++ library and add all sources
9- add_library (${PACKAGE_NAME} SHARED
10- src/main/cpp/cpp-adapter.cpp
11- )
9+ file (GLOB CPP_SOURCES "../cpp/*.cpp" "../cpp/*.hpp" )
10+ add_library (${PACKAGE_NAME} SHARED src/main/cpp/cpp-adapter.cpp ${CPP_SOURCES} )
1211
13- # Add Nitrogen specs :)
12+ # Add Nitrogen specs
1413include (${CMAKE_SOURCE_DIR} /../nitrogen/generated /android/NitroAvalabsCrypto+autolinking.cmake)
1514
1615# Set up local includes
17- include_directories (
18- "src/main/cpp"
19- "../cpp"
20- )
16+ include_directories ("src/main/cpp" "../cpp" )
17+
18+ # Debug variables
19+ message ("SECP256K1_ANDROID_ROOT: ${SECP256K1_ANDROID_ROOT} " )
20+ message ("ANDROID_ABI: ${ANDROID_ABI} " )
21+ message ("SECP256K1_LIB_DIR: ${SECP256K1_ANDROID_ROOT} /${ANDROID_ABI} /lib" )
22+ file (GLOB LIB_FILES "${SECP256K1_ANDROID_ROOT} /${ANDROID_ABI} /lib/*" )
23+ message ("Files in SECP256K1_LIB_DIR: ${LIB_FILES} " )
24+
25+ # Check for secp256k1 variables
26+ if (NOT DEFINED SECP256K1_INCLUDE_DIR OR NOT DEFINED SECP256K1_ANDROID_ROOT)
27+ message (FATAL_ERROR "SECP256K1 vars not provided. Ensure Gradle passes -DSECP256K1_INCLUDE_DIR and -DSECP256K1_ANDROID_ROOT." )
28+ endif ()
29+
30+ # Set the library path directly
31+ set (SECP256K1_LIB_DIR "${SECP256K1_ANDROID_ROOT} /${ANDROID_ABI} /lib" )
32+ file (REAL_PATH "${SECP256K1_LIB_DIR} " RESOLVED_LIB_DIR)
33+ message ("Resolved SECP256K1_LIB_DIR: ${RESOLVED_LIB_DIR} " )
34+ set (SECP256K1_LIB "${RESOLVED_LIB_DIR} /libsecp256k1.so" )
35+ if (NOT EXISTS "${SECP256K1_LIB} " )
36+ message (FATAL_ERROR "libsecp256k1.so does not exist at ${SECP256K1_LIB} " )
37+ else ()
38+ file (SIZE "${SECP256K1_LIB} " LIB_SIZE)
39+ message ("libsecp256k1.so size: ${LIB_SIZE} bytes" )
40+ if (LIB_SIZE EQUAL 0)
41+ message (FATAL_ERROR "libsecp256k1.so is empty at ${SECP256K1_LIB} " )
42+ endif ()
43+ message ("Manually set libsecp256k1.so at: ${SECP256K1_LIB} " )
44+ endif ()
45+
46+ # Add headers for secp256k1
47+ include_directories ("${SECP256K1_INCLUDE_DIR} " )
2148
2249find_library (LOG_LIB log )
2350
2451# Link all libraries together
2552target_link_libraries (
26- ${PACKAGE_NAME}
27- ${LOG_LIB}
28- android # <-- Android core
29- )
53+ ${PACKAGE_NAME}
54+ ${LOG_LIB}
55+ ${SECP256K1_LIB}
56+ android
57+ )
0 commit comments