[CMake] Always build a source file

Gabriele Greco gabriele.greco at darts.it
Thu May 21 12:02:43 EDT 2015


Hi guys,

I'm a long time lurker but I've never wrote here also if I'm using cmake
since a few years.

What is the clean way to enforce the compilation of a selected source file
every time I build it (also if not changed)?

I do it this way:

add_custom_command(TARGET mytarget POST_BUILD
                   COMMAND touch ${CMAKE_CURRENT_SOURCE_DIR}/ver.cpp)


... that works, but it seems not very clean, I thought it could be possible
modifying source file properties with:

set_source_file_properties(ver.cpp ...)

But I've not found a "FORCE" property or anything remotely similar (at
least in the 2.8.12 manual, that is the cmake version I'm using for
platform 'purity' issues...)

-- 
Ing. Gabriele Greco, DARTS Engineering
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150521/265581be/attachment.html>


More information about the CMake mailing list