[CMake] add_custom_target always runs?

Martin Apel martin.apel at simpack.de
Wed Dec 17 02:45:01 EST 2008


Tyler Roscoe wrote:
> On Tue, Dec 16, 2008 at 09:44:38PM +0100, Eric NOULARD wrote:
>   
>>> Ok, so is it simply impossible to do delta builds if my build process
>>> needs add_custom_command/add_custom_target invocations? Is there some
>>> better way to have CMake create the headers for me? Does this behavior
>>> of add_custom_target only occur when I add a new target dependent on
>>> ALL?
>>>       
>> Why do you add "ALL" in your case?
>>
>> Won't generateheader be called when needed when you remove the ALL
>> argument to add_custom_target?
>>
>> Note that another way to go is completely remove the add_custom_target
>> and add the generated header to the concerned add_executable /
>> add_library command.
>>
>> then you have to:
>>
>> set_source_files_properties(results/header.h PROPERTIES GENERATED true)
>>  in order to avoid to make add_library/add_executable shout at you
>> about missing files.
>>
>> Then when the concerned libraries and/or executable are built
>> CMake should automatically run your add_custom_command since it
>> advertise it has the missing "results/header.h" as output.
>>     
>
> I presented a simplified version of my problem. In reality, I have a
> cmake project that takes a bunch of headers, mangles them with scripts,
> and then collects them in a directory so I can have a single
> INCLUDE_DIR.
>
> I would like to handle all these headers by themselves rather than
> having DEPENDS references to them all over the source tree. The way I
> have it now, BigLibrary1... BigLibraryN INCLUDE() Headers/CMakeLists.txt
> so that all the headers can be "built" before trying to build one of the
> BigLibraries.
>
> Am I thinking about this the wrong way? I find that the way I think
> about build problems is often quite different from how CMake thinks
> about those same problems.
>   
I had a similar problem some time ago. I worked around it by first
generating the header files into ${CMAKE_CURRENT_BINARY_DIR} and then
execute 'cmake -E
copy_if_different' to their target location. This way dependent files
will only be rebuilt, if the header has actually changed.

Hope this helps,

Martin




____________
Virus checked by G DATA AntiVirus
Version: AVF 19.189 from 16.12.2008




More information about the CMake mailing list