[CMake] Problem with cmake dependencies
Carminati Federico
federico.carminati at cern.ch
Sat Feb 12 08:24:54 EST 2011
Dear All,
here I am again. I still have a problem with cmake dependencies which is a bit complicated (for me at least). I really apologise in advance if what follows is not clear, but I do need your help here. I have a coding convention checker tool that runs on all the source files to check the code for coding convention violations. The codebase is quite large (~2MLOC) and very dynamic, as there are hundreds of people that can check in. The code itself is organised in a set of subdirectories where files come and go. The dependency schema is the following
source.viol depends on source.h.xml, source.cxx.xml, ${CMAKE_BINARY_DIR}/factFile.xml
source.h.xml depends on source.h
source.cxx.xml depends on source.cxx and source.h
${CMAKE_BINARY_DIR}/factFile.xml depends on ALL the source.h.xml in ALL subdirectories
creating the source.{h,cxx}.xml is quite easy, however I do not manage to express the dependency of the viol file. I do not even manage to express the dependencies of the factFile.xml correctly.
One of the problems for me is that once I am inside a directory, I am not able to add file-level dependencies to a file target defined in the "upper" scope. As far as I understood, when you define a file target with ADD_CUSTOM_COMMAND(OUTPUT... COMMAND ... DEPENDS...) you cannot "add" to the depends as you go, because ADD_DEPENDENCIES takes a top level target as first argument. I cannot even add to a list, because there is no way to see the same variable in a ADD_SUBDIRECTORY command and in the calling scope. But even if I would manage to do so, let's say writing a file and reading it (ugly), I would still have a problem. Let's suppose my factFile depends only on one file in subdirectory STEER added previously with the command add_subdirectory(STEER).
add_custom_command(OUTPUT factFile.xml
COMMAND
DEPENDS STEER/check/source.h.xml)
cmake complains that it does not know how to make it, and it is right, because this is known only inside the subdirectory STEER and not at global scope. I hope I have been clear enough. Thanks for help. Best regards,
Federico Carminati
CERN-PH
1211 Geneva 23
Switzerland
Tel: +41 22 76 74959
Fax: +41 22 76 68505
Mobile: +41 76 487 4843
More information about the CMake
mailing list