[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cmake
Subject:    [CMake] Integrating Build Date/Time into Binary
From:       Torsten Robitzki <Torsten () Robitzki ! de>
Date:       2019-01-16 8:50:20
Message-ID: DA8DAAD4-B197-496B-A983-F77CB7C1C81A () Robitzki ! de
[Download RAW message or body]

[Attachment #2 (multipart/signed)]


Hello,

we are porting a larger set of projects (~70) to CMake. The current build has a \
feature to integrate the current timestamp of the build into the final binary / \
target. If a target is relinked, a header (id.h) is created with the current \
timestamp, a user provided C file (id.c), including that header is recompiled and \
linked into the target as well.

While thinking about how to provide a similar solutions, we came up with some ideas:

1) add_custom_command()

The projects have to move id.c into a separate library. For the main target, all \
depending targets (excluding the library containing id.c) are determined. A \
add_custom_command() creates id.h and depends on the list of determined, depending \
targets.

The drawback that I see here, is that other, additional dependencies (like introduced \
with add_custom_command()) are not taken into account and that we have to recreate \
the algorithm to determine all direct and indirect depending targets.

2) add_custom_command(TARGET <target> PRE_LINKā€¦)

The generation of both, id.h and id.c are excluded from the main target and are build \
by the add_custom_command(). The resulting object file is added as GENERATED, \
EXTERNAL_OBJECT source file to the main target.

The drawback here is, that the custom command have to compile the id.c file, using \
the right compiler, the right flags, include paths etc.

To me it doesn't sound to be a very special requirement to have some kind of hash \
(timestamp in this case) over the compiled files in the resulting binary. How do \
others solve this or similar problems? Any comments to our ideas?

TIA,

Torsten


["signature.asc" (signature.asc)]

-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEBlD/pUKd/TvZxxklxPKNInpbSZkFAlw+8EwACgkQxPKNInpb
SZngbxAAjDoEhtgxqZoBmNpvP1+Ij+ZL+vP3DCeZW9xWJeCW45hKAa3zDNwD9yH7
oZrCWV+5L0bUwUJnauW9csZA7UT9SHLcgNOL/GdqAD+6HUtHfk3TlXg9VJvu7Nw3
UAqVR/04Gl3tVkWNVWFhVsochgTFo61raHcYlI6ahvmWUuRFGiwQrqrlaSSAyszL
DjPHRPcvZqG+Jy/tAM+XxTwkVdRs+NHCxmXq5YbpaH9PNybJYKrfC7IMGDp2AP9S
IOC0ZLDlzcnbPTazF/wJvhIN372xTKDTeFjPQ/KTZLwOexuiiI09KvmcbcoOxuuj
p+l0XD7Md3A4qGqeW91506s/+lTV/hv9UmhDa8X8Mz/RUCQ13kNqqBJEMtiNw0ey
yq26sQb+5E+/0vAeyj9j0EOP+JQwH6MScwue3xJ61k+HVpntbtchEl4brxdV4DYP
f8SB0tOi+11injO3JzWkFEMyfV2sSui0wov6Fhfi2U0D724bonEiheBGz9fMae8q
CMzCk+gVaNsgllGI7TmwesTg2z7lWAH5qbanRUulEJ2KUN9HZ17HmDIx+p0lGWPD
edghn4JwCZWqorOapattICbw+FJFZ8oZSAA+otyjTKvEytnzW8ss3iTL5qe0TTdp
HeQyi5TBaK0RTzEa1hj9fn8IbtHtKGz/phMRv6qoerLRI5GKF50=
=j78E
-----END PGP SIGNATURE-----


-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: \
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information \
on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at \
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic