[CMake] Make add_custom_target depends on cmake macro/function
Mathieu Malaterre
mathieu.malaterre at gmail.com
Mon Feb 23 07:46:45 EST 2015
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 ?
Nevermind, that was easy:
cmake_minimum_required(VERSION 3.0)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/dummy.cmake
"string(TIMESTAMP curdate UTC)
execute_process(COMMAND echo \"\${curdate}\")"
)
add_custom_target(
dummy ALL
COMMAND cmake -P ${CMAKE_CURRENT_BINARY_DIR}/dummy.cmake
)
Sorry for the noise,
--
Mathieu
More information about the CMake
mailing list