[CMake] Add include files

Yinon Ehrlich yinon.me at gmail.com
Tue Nov 13 03:27:17 EST 2007


Alexander Neundorf wrote:
> On Sunday 11 November 2007, Yinon Ehrlich wrote:
>   
>> Hi,
>>
>> * I'm new to CMake, trying to convert our existing GNU Makefiles to CMake.
>> * I have a GCC compilation line that uses GCC's "-include" direction
>>     
>
> The argument to -include is a file which will be included, right ?
>
>   
>> (Instead of having multiple identical "#include" lines within the source
>> code.)
>>
>>   ==> Does anyone has an idea how can I implement this feature with CMake ?
>>     
>
> You could do it using ADD_DEFINITIONS(-include ...)
> but I would suggest you actually include that file everywhere (using -include 
> *might* make the cmake dependency scanning miss some dependencies)
>
> Alex
>
>   
Thanks, Alex !

Two questions, and an idea:

1. Why it could harm the dependency checking - because when including a 
file this way it is not checked by the CMake dependency scanner ?
2. I found that MSVC 2003 & 2005 has similar option called "forced 
include" (its switch-syntax is /FI <filename>). I also saw that it 
appears in CMake's sources:
Source/cmLocalVisualStudio7Generator.cxx:353: {"ForcedIncludeFiles", 
"FI", "Forced include files", "",

The real *pain* here is compatibility. I think the best solution will be 
to write a module that adds forced includes (either "-include" for GCC 
or "/FI" for MSVC) and maybe also check their dependencies. Please tell 
me what you think.

Thanks,
Yinon



More information about the CMake mailing list