[CMake] Global dependency

Petr Kmoch petr.kmoch at gmail.com
Wed Aug 27 02:57:26 EDT 2014


Hi Jonas.

As a hacky solution, you could override add_library() and add_executable(),
like this:

function(add_library targetName)
  _add_library(${targetName} ${ARGN})
  add_dependencies(${targetName} BuildInfoDateTime)
endfunction()

Petr



On Wed, Aug 27, 2014 at 5:44 AM, Jonas Lippuner <jonas at lippuner.ca> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi all,
>
> I have a custom target called BuildInfoDateTime that generates a *.cpp
> file containing the date and time of the build. I specified the target
> with ALL, so it gets run if I simply type make. However, I would also
> like all other targets (executables and libraries) to depend on
> BuildInfoDateTime. Of course, I can add the dependency manually, but
> that is tedious and could be forgotten when new targets are added.
>
> So, is there a way to make all targets depend on my custom target
> BuildInfoDateTime?
>
>
> Thanks,
> Jonas
>
>
> - --
> My email is signed and I encrypt email on request.
> To verify my signature or send me encrypted email,
> get my public key: http://lippuner.ca/key
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1
>
> iQIcBAEBAgAGBQJT/VQTAAoJELH92qHy0gnt08AP/1rjVLQ5n0L6+VsW98H0MC3s
> ccHipuwsvoCZX01R1/q/NS3e+5QV4Lx/MplhBysucM+eNesmzFPq0u5DlPI/G6wm
> KGbLGCQnczx7nWI1Dsso0lkj1bOxsMaa83u4LL0xn9g5UJUpzRI2MMgFzasLfOcA
> e4mkQKpp6O3asQ56DECvzg3RwZRgrjIi7UAKbxyO1U6p/3XmkYzzIAFoJxfeABNi
> 5LD0SS1W1aVTUrBseu+puADC4I8K5zit7uI7zlIyujxyFyj+7SkBmvYKrgXs18nR
> Y2ycy/nruUMIxblYIdm723Tu+T9+Y51qZvHbLVuJGKergVFCjsIntkjXMcmbqyLD
> Q/uAKFSRzYOlYHPsNrNkQbuaB7dM3VDGMCtfZiJQQaWGZpI58Iyqgr0JaY+pFXPC
> ZskjI1BH7T5uKy5KG+XMfZSbSFzUi2woZpMYPROQi0DqCfgIpLiZsnyHcD6erzMv
> DTkmciltZTn0/u953lJWj7lH+8vxSRJm7KLcFmpKRMI8Nq6YLXUkQBj/1gtIt8q/
> Y98qHJOM/IcrW2hUC6i1s5yQGqgV60tzBFCVOkG/GTO9uUbA4KyXYw/lUDyb0lq+
> oKkCS0EsOIiscQxfemFwVh/sO8Vqap2Az4JaxrM8s8YDP3otYtVXBL/nn2sYrOwv
> 4BEjtuSuvJf/mz0EiqYQ
> =p1nK
> -----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:
> http://public.kitware.com/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20140827/1efa5fdc/attachment.html>


More information about the CMake mailing list