I'm trying to integrate a Node.js addon into an existing build system based on CMake. The addon build requires a large number of preprocessor macro definitions and library dependencies that are available in the CMake context. I would like to be able to pass these into node-gyp
when it is invoked by CMake. Unfortunately, I have not been able to find a simple way to do so.
I've tried using the approach used for plain old gyp
like this:
node-gyp configure -d -DPOSIX=1
but the -D
option doesn't seem to be passed on by node-gyp
. Looking at the source for node-gyp
, this isn't entirely surprising. Is there a straightforward, direct way to do this, or am I stuck with generating the entries in binding.gyp
programmatically, pulling in this information from the environment or something else along those lines?
Use "defines".
{
"targets": [
{
"target_name": "MyAddon",
"sources": [ "File1.cpp", "File2.cpp" ],
"libraries": [ "MyNeeded.lib" ],
"defines": [ "_UNICODE", "UNICODE" ]
}
]
}
This adds the defines to the in your config.gypi when running node-gyp configure
I'm not sure why you see a downside to using the cflags setting in binding.gyp - but I just make something similar work by setting the flags using .bashrc
export CFLAGS='-m32' export CXXFLAGS='-m32' export LDFLAGS='-m3'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With