Search code examples
node.jsnode-gypnode.js-addon

How to change library paths based on configuration?


I am building a native module that needs to link a static library. The path to that library. My binding.gyp file has the following appearance:

{
   "targets": [
      {
         "target_name": "DcpServer",
         "sources": [
            "DcpServer.cc"
         ],
         "include_dirs": [
            "../../coratools",
            "../../../boost-1.65.1"
         ],
         "libraries": [
            "<(module_root_dir)/../../coratools/release_uni64/coratools.lib"
         ],
         "defines": [ "CSIWEB_EMBEDDED", "UNICODE", "_UNICODE" ],
         "configurations": {
            "Release": {
               "msvs_settings": {
                  "VCCLCompilerTool": {
                     "ExceptionHandling": 1,
                     "RuntimeTypeInfo": "true"
                  }
               }
            },
            "Debug": {
               "msvs_settings": {
                  "VCCLCompilerTool": {
                     "ExceptionHandling": 1,
                     "RuntimeTypeInfo": "true"
                 }
               }
            }
         }
      }
   ]
}       

The path to coratools.lib will vary based upon whether the debug or release configuration is selected. The problem is that node-gyp did not allow me to place the "libraries" key within the "configurations" property. Is there a way of doing what I want by making the library path conditional?


Solution

  • I never did discover how to do this. In the end, I switched to using cmake-js to build my native module.