[CMake] Make add_custom_target depends on cmake macro/function
Petr Kmoch
petr.kmoch at gmail.com
Mon Feb 23 07:52:33 EST 2015
You could have the custom target execute CMake in script mode:
add_custom_target(
dummy ALL
COMMAND ${CMAKE_COMMAND} -P timescript.cmake
)
The file timescript.cmake could look like this:
string(TIMESTAMP curdate UTC)
message("${curdate}")
Feel free to play around with stdout/stderr distinction etc. You could also
generate the script from the master CMake file using file(WRITE) instead of
storing it as a stand-alone file.
Petr
On Mon, Feb 23, 2015 at 1:37 PM, Mathieu Malaterre <
mathieu.malaterre at gmail.com> wrote:
> Hi there,
>
> I am trying to setup a rule which always execute, however it needs to
> depends on a cmake macro. Here is an equivalent code:
>
> [...]
> cmake_minimum_required(VERSION 3.0)
> string(TIMESTAMP curdate UTC)
> add_custom_target(
> dummy ALL
> COMMAND echo "${curdate}"
> )
> [...]
>
> Is there any simple way to have the `dummy` rule re-execute the above
> cmake TIMESTAMP macro ?
>
> Thanks much,
> --
> Mathieu
> --
>
> 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/20150223/802e70ad/attachment.html>
More information about the CMake
mailing list