jeudi 13 août 2015

Precompile C++ vendor Libraries (#include api.h)

First of all, I have to say, that I am an absolute beginner in c++ and all the compiler stuff that is going on for native development.

What I am actually trying to do, is to create a NodeJS binding, to wrap an existing library. The library itself has a api.h which I can include in my wrapper an use it to built my Wrapper methods. The problem which I have, is that the library itself is quite large:

  src/  
    vendor/
      libA/..
      libB/..
      libC/..
      api.h 
      api.cpp 
    addon.cpp (where I am including the "vendor/api.h")

so every time I am compiling my addon.cpp all the libraries have to be recompiled again and again, which sucks. So what is the best way to compile the api once and use it in my addon.cpp (I am not using any of the libs in my addon only the api.h!)

By the way I am working on a Ubuntu 14.04 and I am using Cmake to perform the compilation:

To compile my addon with all the libraries, I am defining all the SOURCE_FILES like this:

file(GLOB SOURCE_FILES
 "src/addon.cpp"
 "src/vendor/*.cpp" "src/vendor/*.h"
 "src/vendor/libA/*.c" "src/vendor/libA/*.h"
 "src/vendor/libB/*.cpp" "src/vendor/libB/*.h"
 "src/vendor/libC/*.c" "src/vendor/libC/*.h"
)

...
add_library(addon SHARED ${SOURCE_FILES})

To compile it, I am calling

cmake-js rebuild

cmake-js because it also loads some NodeJS required stuff, but the CMakeLists.txt file uses the normal cmake syntax

So any help would be really awesome, thanks!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire