Is there way to specify compiler flags (e.g., preprocessor macro definitions) on the node-gyp command line?
node-gyp, node.js
Solution
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
Problem
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?