Skip to content

Commit 7151c82

Browse files
committed
Renamed weak-node-api.cmake to weak-node-api-config.cmake to follow find_package pattern
1 parent 4cbe8f2 commit 7151c82

File tree

3 files changed

+40
-17
lines changed

3 files changed

+40
-17
lines changed

packages/weak-node-api/src/weak-node-api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ export const androidPrebuildPath = path.resolve(
2222

2323
export const weakNodeApiCmakePath = path.resolve(
2424
weakNodeApiPath,
25-
"weak-node-api.cmake",
25+
"weak-node-api-config.cmake",
2626
);
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
2+
# Get the current file directory
3+
get_filename_component(WEAK_NODE_API_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" DIRECTORY)
4+
5+
if(NOT DEFINED WEAK_NODE_API_LIB)
6+
# Auto-detect library path for Android NDK builds
7+
if(ANDROID)
8+
# Define the library path pattern for Android
9+
set(WEAK_NODE_API_LIB_PATH "weak-node-api.android.node/${ANDROID_ABI}/libweak-node-api.so")
10+
11+
# Try Debug first, then Release using the packaged Android node structure
12+
set(WEAK_NODE_API_LIB_DEBUG "${WEAK_NODE_API_CMAKE_DIR}/build/Debug/${WEAK_NODE_API_LIB_PATH}")
13+
set(WEAK_NODE_API_LIB_RELEASE "${WEAK_NODE_API_CMAKE_DIR}/build/Release/${WEAK_NODE_API_LIB_PATH}")
14+
15+
if(EXISTS "${WEAK_NODE_API_LIB_DEBUG}")
16+
set(WEAK_NODE_API_LIB "${WEAK_NODE_API_LIB_DEBUG}")
17+
message(STATUS "Using Debug weak-node-api library: ${WEAK_NODE_API_LIB}")
18+
elseif(EXISTS "${WEAK_NODE_API_LIB_RELEASE}")
19+
set(WEAK_NODE_API_LIB "${WEAK_NODE_API_LIB_RELEASE}")
20+
message(STATUS "Using Release weak-node-api library: ${WEAK_NODE_API_LIB}")
21+
else()
22+
message(FATAL_ERROR "Could not find weak-node-api library for Android ABI ${ANDROID_ABI}. Expected at:\n ${WEAK_NODE_API_LIB_DEBUG}\n ${WEAK_NODE_API_LIB_RELEASE}")
23+
endif()
24+
else()
25+
message(FATAL_ERROR "WEAK_NODE_API_LIB is not set")
26+
endif()
27+
endif()
28+
29+
if(NOT DEFINED WEAK_NODE_API_INC)
30+
set(WEAK_NODE_API_INC "${WEAK_NODE_API_CMAKE_DIR}/include;${WEAK_NODE_API_CMAKE_DIR}/generated")
31+
message(STATUS "Using weak-node-api include directories: ${WEAK_NODE_API_INC}")
32+
endif()
33+
34+
add_library(weak-node-api SHARED IMPORTED)
35+
36+
set_target_properties(weak-node-api PROPERTIES
37+
IMPORTED_LOCATION "${WEAK_NODE_API_LIB}"
38+
INTERFACE_INCLUDE_DIRECTORIES "${WEAK_NODE_API_INC}"
39+
)

packages/weak-node-api/weak-node-api.cmake

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)