Comments (7)
I fixed it with this
target_include_directories(${PROJECT_NAME} PUBLIC "${CMAKE_SOURCE_DIR}/node_modules/node-addon-api" "${CMAKE_SOURCE_DIR}/../../node-addon-api" "src" )
But is there a better way to handle this ?
from cmake-js.
Also while not related to the issue, Is it possible to have Native Package B, depend on Native Package A such that B can import and use all headers and such defined in A? Like in my case I have a torch package that has basic tensor operations and another package for torchvision. but I do not want to have to redefine tensors and all that and instead want to use what I already have done in the previous package.
from cmake-js.
cmake-js
attempts to find node-addon-api
, and adds it to the CMAKE_JS_INC
variable if it finds it. I don't know why it wouldn't be successful in doing so
Also while not related to the issue, Is it possible to have Native Package B, depend on Native Package A such that B can import and use all headers and such defined in A?
I'm not entirely following what you are asking, but probably. It sounds like a more general cmake question than something specific to this lib
from cmake-js.
cmake-js
does a very unusual check for if a module is using node-addon-api
- based on the presence of:
"binary": {
"napi_versions": [
7
]
}
in package.json
If you include this property, it will correctly add the node-addon-api
directory.
AFAIK, currently there is no such requirement for node-addon-api
projects - but there seem to have been such an idea in the early days - napi-build-utils
and @mapbox/node-pre-gyp
both mention it.
Additionally, when cmake-js
detects the presence of this napi_versions
, it will also disable access to the low-level API - including uv.h
. Normally a node-addon-api
project is not supposed to access the low-level API - except for uv.h
.
My proposal is to make it a little bit less intelligent. Always include the low-level API as retrieved from the remote server. And try to simply detect the presence of node_modules/node-addon-api
and node_modules/nan
. This will match the behavior of node-gyp
.
from cmake-js.
@TareHimself open a separate issue with this question, and I will share my experience on this matter, which does not have a simple solution. gdal-exprtk
does this.
from cmake-js.
cmake-js attempts to find node-addon-api, and adds it to the CMAKE_JS_INC variable if it finds it. I don't know why it wouldn't be successful in doing so
I was hitting this too, and figured out why by enabling --log-level silly
and digging through the code a bit
If --directory
is set to anything other than the package.json directory, it will fail
In my project, Node is only one of the many platforms we build for. Thus we have CMakeLists.txt in the root, and electron/package.json
in a subfolder. Our build calls cmake-js --directory ../
to make this work.
The README says " -d, --directory specify CMake project's directory (where CMakeLists.txt located)` - it doesn't say package.json has to be in the same directory as the CMakeLists.txt (if it did I'm not sure why this option would exist). It also doesn't say where the directory needs to be in relation to the package.json, which is why my understanding is putting CMakeLists.txt in a parent dir should work.
this.options.isNodeApi = isNodeApi(this.log, this.options.directory)
passes that directory to isNodeApi
isNode Api does
const tmpRequire = require('module').createRequire(path.join(projectRoot, 'package.json'))
<projectRoot>/package.json
doesnt exist for me, my package.json is in <projectRoot>/electron/package.json
, so this fails
from cmake-js.
I was missing node.lib this is the fixed CMakeList https://github.com/nodeml/torch/blob/main/CMakeLists.txt
from cmake-js.
Related Issues (20)
- Electron not auto detected and runtime fail HOT 2
- Failure to parse package.json (containing trailing commas) is not reported HOT 3
- node-datachannel uses cmake-js HOT 1
- cmake-js v8 ideas HOT 18
- Problem with clang-cl toolchain on windows (and solution) HOT 1
- print-configure doesn't respect -o (specifying build directory)
- Values passed via `--CD` gets incorrectly converted to numbers
- CMake/ninja error: '**/System/Library/Frameworks/CoreAudio.framework/CoreAudio', needed by 'Release/addon.node', missing and no known rule to make it
- Error while executing the `rebuild` command HOT 2
- Builds fail in bash on Windows (PATH vs Path)
- Dull on windows after while HOT 2
- Failing to resolve node_api.h with Microsoft intellisense in Visual Studio Code HOT 2
- Add a c version of win_delay_load_hook
- ERR! OMG There is no Visual C++ compiler installed. Install Visual C++ Build Toolset or Visual Studio.
- use cmake-js without msvc
- include arm64 in release
- Having 'nan' in node_modules causes error with string sub-command FIND
- Consider introducing a CMake module
- compiled addon for nwjs not works
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cmake-js.