gsoh83
gsoh83

Reputation: 177

How to build specific files in CMAKE everytime?

I am looking for a way to build some c, c++ files in CMAKE everytime when I type the make command whatever I modify the file or not. Because those file include build information codes such as build time. It this possible in CMAKE?

Thank you in advance.

Upvotes: 7

Views: 4904

Answers (1)

ComicSansMS
ComicSansMS

Reputation: 54737

You can use the add_custom_target command to add a target that will be executed for every build.

For example, you can use the CMake touch command to mark certain source files dirty, so they get rebuild on every run:

add_custom_target(invalidate_files ALL
                  COMMAND ${CMAKE_COMMAND} -E touch ${MY_SRC_FILE})

Upvotes: 12

Related Questions