I want to have something in CMake that will be executed whenever I enter make
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/build_date.cc
PRE_BUILD
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/mk_build_date.py
${CMAKE_CURRENT_BINARY_DIR}/build_date.cc
)
add_custom_target(build-date-xxx
ALL
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/build_date.cc)
thats what I'm currently doing. unfortunately make build-date-xxx
will generate the file only once.
even without the add_custom_target
declaration the file is only build once.
the result should be something like this in GNU Make
.PHONY all:
echo "hallo welt"
all: foo.c bar.c
%.c:
touch $@
in that makefile whenever make is entered. since all is the first target it will always be invoked and the custom command echo "hallo welt"
is actually executed.