-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
project and patch simplification: node-addon-api
* add cmake build support (header-only INTERFACE library) * issue #367
- Loading branch information
Scott M Anderson
committed
Dec 30, 2022
1 parent
d0e459f
commit e72f8dc
Showing
3 changed files
with
61 additions
and
22 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,39 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
new file mode 100644 | ||
index 0000000..50585bd | ||
--- /dev/null | ||
+++ b/CMakeLists.txt | ||
@@ -0,0 +1,33 @@ | ||
+cmake_minimum_required(VERSION 3.24) | ||
+project(node-addon-api) | ||
+include(GNUInstallDirs) | ||
+include(flags OPTIONAL) | ||
+if(COMMAND xpFindPkg) | ||
+ set(XP_MODULE_PATH ${CMAKE_MODULE_PATH}) | ||
+ xpFindPkg(PKGS node) | ||
+endif() | ||
+set(lib_name ${PROJECT_NAME}) | ||
+######################################## | ||
+set(libsrcs | ||
+ napi-inl.deprecated.h | ||
+ napi-inl.h | ||
+ napi.h | ||
+ ) | ||
+######################################## | ||
+add_library(${lib_name} INTERFACE ${libsrcs}) | ||
+target_include_directories(${lib_name} INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>) | ||
+target_compile_definitions(${lib_name} INTERFACE NODE_ADDON_API_DISABLE_DEPRECATED NAPI_CPP_EXCEPTIONS) | ||
+if(TARGET xpro::node) | ||
+ target_link_libraries(${lib_name} INTERFACE xpro::node) | ||
+endif() | ||
+######################################## | ||
+set(targetsFile ${PROJECT_NAME}-targets) | ||
+install(TARGETS ${lib_name} EXPORT ${targetsFile}) | ||
+install(FILES ${libsrcs} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}) | ||
+if(DEFINED XP_NAMESPACE) | ||
+ set(nameSpace NAMESPACE ${XP_NAMESPACE}::) | ||
+endif() | ||
+if(NOT DEFINED XP_INSTALL_CMAKEDIR) | ||
+ set(XP_INSTALL_CMAKEDIR ${CMAKE_INSTALL_DATADIR}/cmake) | ||
+endif() | ||
+install(EXPORT ${targetsFile} DESTINATION ${XP_INSTALL_CMAKEDIR} ${nameSpace}) |
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