Droping rebory and migrate to cmake-js #14

Merged
Sirherobrine23 merged 5 commits from SonicCDPast into main 2024-07-09 03:02:27 +00:00
Showing only changes of commit d0ed246bca - Show all commits

@ -11,22 +11,34 @@ set(CMAKE_C_STANDARD 17)
set(CMAKE_CXX_STANDARD 17)
include_directories(${CMAKE_JS_INC})
include_directories("node_modules/node-addon-api")
include_directories("addon")
include_directories("addon/genKey")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/addon")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/addon/genKey")
# Include N-API wrappers
# $ node -p "require('node-addon-api').include"
# "/home/will/projects/financialcpp/financialcpp/node_modules/node-addon-api"
execute_process(COMMAND node -p "require('node-addon-api').include"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE NODE_ADDON_API_DIR
)
# strip `"` and `\n` from the output above
string(REPLACE "\n" "" NODE_ADDON_API_DIR ${NODE_ADDON_API_DIR})
string(REPLACE "\"" "" NODE_ADDON_API_DIR ${NODE_ADDON_API_DIR})
include_directories(PRIVATE ${NODE_ADDON_API_DIR})
if(UNIX)
add_definitions(-fpermissive -fexceptions -w -fpermissive -fPIC)
endif()
file(GLOB GSOURCE_FILES
"addon/main.cpp"
"addon/genKey/wgkeys.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/addon/main.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/addon/genKey/wgkeys.cpp"
)
if(MSVC)
file(GLOB SOURCE_FILES "addon/win/wginterface.cpp")
include_directories("addon/win")
file(GLOB SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/addon/win/wginterface.cpp")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/addon/win")
add_compile_definitions(_HAS_EXCEPTIONS=1 ONSTARTADDON)
target_link_libraries(${PROJECT_NAME}
"wbemuuid.lib"
@ -39,10 +51,10 @@ if(MSVC)
"setupapi.lib"
)
elseif(UNIX AND NOT APPLE OR ANDROID)
include_directories("addon/linux")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/addon/linux")
file(GLOB SOURCE_FILES
"addon/linux/wireguard.c"
"addon/linux/wginterface.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/addon/linux/wireguard.c"
"${CMAKE_CURRENT_SOURCE_DIR}/addon/linux/wginterface.cpp"
)
else()
message(STATUS "Buiding go Userspace")
@ -71,9 +83,9 @@ else()
if(NOT GOCODE EQUAL "0")
message(FATAL_ERROR "cannot build go userspace code exit ${GOCODE}\n${GOBUILDLOG}")
endif()
include_directories("addon/userspace")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/addon/userspace")
set(USERSPACEOBJ ${CMAKE_CURRENT_SOURCE_DIR}/addon/userspace/wg-go.o)
file(GLOB SOURCE_FILES "addon/userspace/wginterface.cpp")
file(GLOB SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/addon/userspace/wginterface.cpp")
endif()
add_library(${PROJECT_NAME} SHARED ${GSOURCE_FILES} ${SOURCE_FILES} ${CMAKE_JS_SRC})