[CMake] Generating include files

Hendrik Sattler post at hendrik-sattler.de
Sat May 20 05:59:45 EDT 2017



Am 20. Mai 2017 11:16:54 MESZ schrieb Urs Thuermann <urs at isnogud.escape.de>:
>Craig Scott <craig.scott at crascit.com> writes:
>>     add_executable(foo foo.c)
>>     set_source_files_properties(foo.c PROPERTIES OBJECT_DEPENDS
>> ${CMAKE_BINARY_DIR}/tab.h)
>
>IMO that feels just wrong.  foo.c does NOT depend on tab.h, foo.c does
>not depend on anything, it's not even generated by the build system.
>*I* edit it.  Instead, it is the object file foo.o that depends on
>tab.h.  But it seems that cmake doesn't want the developer to see or
>talk about object files.  It hides them somewhere in subdirs (with
>unpredictable names (sometimes foo.o, sometimes a silly name like
>foo.c.o, sometimes both), so after make foo.o I don't know which one
>is current), gives error messages if I use them in CMakeLists.txt...

This is not quite correct.
Either your code generates a header file to be included by foo.c, then foo.c depends on it. Or it creates data and methods that need to be linked, then the executable depends on it.

An object file only makes the executable need unresolved symbols but that is not a dependency of the object file.

Or you simply failed to explain how parts relate to each other and the dependency between the parts is totally different.

OTOH, table-driven CRC is usually not that complicates to integrate.

CMake handles lots of compilers that REQUIRE other object file extensions than .o. It also generates for more that only make, allowing better working with IDEs. These bring their own strange rules that you cannot match to any make logic.

HS

-- 
Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.


More information about the CMake mailing list