[CMake] Can I make the dependency scanner only look in certain include directories?

Dan Furlani dan.furlani at e-cortex.com
Thu Oct 4 21:43:53 EDT 2012


> If you hide it behind a function-like macro then you can use
> the IMPLICIT_DEPENDS_INCLUDE_TRANSFORM to tell the targets
> where you want the dependency how to get it:

Thanks, that worked.  Here's what I had to do, maybe there was an
easier way I missed.

1. Define macros MY_ADD_LIBRARY and MY_ADD_EXECUTABLE like this:

macro (MY_ADD_EXECUTABLE target)
  add_executable(
    ${target}
    ${ARGN}
  )
  set_target_properties(
    ${target} PROPERTIES
    IMPLICIT_DEPENDS_INCLUDE_TRANSFORM "MY_CMAKE_DEPENDENCY_HACK(%)=\"%\""
  )
endmacro (MY_ADD_EXECUTABLE)

2. Replace all ADD_LIBRARY and ADD_EXECUTABLE calls with
MY_ADD_LIBRARY and MY_ADD_EXECUTABLE, **except** for the code
generator executable.

3. Create a wrapper header GeneratedFile_WRAPPER.h that looks like this:

#define MY_CMAKE_DEPENDENCY_HACK(a) #a
#include MY_CMAKE_DEPENDENCY_HACK(GeneratedFile.h)
#undef MY_CMAKE_DEPENDENCY_HACK

4. Change around 20 files to include the wrapper instead of the GeneratedFile.h

Thanks again for the help Brad!
-dan


More information about the CMake mailing list