[CMake] Building generated c++ code with py++ and boost.python

Filipe Sousa filipe at ipb.pt
Tue Oct 10 15:15:37 EDT 2006


Pecevski Dejan wrote:
> Hi,
> 
> As part of our build process which uses cmake, we want to generate 
> wrapper c++ files from existing sources, for python interfacing (using 
> Py++ and boost.python).
> The dependency we want to achieve is :
>     A1.cpp A2.cpp A3.cpp   A1.h A2.h A3.h  ...  <-----  Abase.h  generate.py
>    wrapLibrary.so  <-----  A1.cpp A2.cpp A3.cpp  baseLibrary.a
> where
>     - Abase.h is the header file containing the classes that are to be 
> exposed in python (INCLUDES several header files from other directories)
>     - generate.py is the python script which parses Abase.h and produces 
> the wrapper code from it
>    - A1.cpp A2.cpp A3.cpp  A1.h A2.h A3.h  - automatically generated 
> wrapper c++ files
>    - wrapLibrary.so is the library which contains the compiled wrapper 
> code along with the library which is wrapped (baseLibrary.a).
> Note that the automatically generated c++ file list are NOT KNOWN 
> apriori (they are dependent on the contents of Abase.h and generate.py).

ADD_CUSTOM_COMMAND(
  OUTPOUT ${CMAKE_CURRENT_BINARY_DIR}/A1.cpp
${CMAKE_CURRENT_BINARY_DIR}/A1.h .. A2.cpp ...
  COMMAND generate.py ${CMAKE_CURRENT_BINARY_DIR}/Abase.h
  DEPENDS genereate.py ${CMAKE_CURRENT_BINARY_DIR}/Abase.h
)
You have to add the genareated file to ADD_LIBRARY() or ADD_EXECUTABLE()

> I have two questions on how to setup this with cmake:
> 1. To setup the first dependency rule properly, one should also add as 
> dependencies the files that Abase.h file includes
>     so that when you change the code in these files, wrapper code is 
> recreated. For example if Abase.h includes another header file B.h, and 
> B.h (but not Abase.h)   is changed then the rule should be activated.
>     Is there some way to setup this in cmake?
>     It seems like the scanning mechanism for the dependencies of c++ 
> sources doesn't work for ADD_CUSTOM_TARGET.
>    
> 2. For the second rule to work, one should include dynamically the list 
> of all generated files in the rule. The file list that is to be included 
> can be retrieved with a FILE(GLOB ...) command (that is after they are 
> created).
> I have some vague idea how to setup this with recursive calling of cmake 
> commands, but I'm not really sure it can work out. Is this setup 
> possible, and is there some elegant way to do this?
> 
> Any help would be appreciated!
> 
> Thanks,
> Dejan
>    
>    
>    
>    
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
> 
> 


-- 
Filipe Sousa

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: OpenPGP digital signature
Url : http://public.kitware.com/pipermail/cmake/attachments/20061010/63512230/signature.pgp


More information about the CMake mailing list