generated.h
is created by a script replaced with touch
for now. How can I achieve that this file is regenrated each time I run make
? Calling rm
like in the below example produces error.
cmake_minimum_required(VERSION 3.5.1)
project(MyProject)
set_source_files_properties(generated.h PROPERTIES GENERATED TRUE)
add_executable(jr
jr.cpp
generated.h
)
add_custom_command(
OUTPUT generated.h
COMMAND rm generated.h
COMMAND touch generated.h
)
Instead of add_custom_command
use add_custom_target : it will be executed every time build is run:
add_custom_target(regenerate
COMMAND rm -f generated.h # Remove file if it exists.
COMMAND touch generated.h
)
# Force executable to be compiled after regeneration takes a place
add_dependencies(jr regenerate)
# You need to hint compiler about location of the header file generated.
include_directories(${CMAKE_CURRENT_BINARY_DIR})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.