Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have something like the following snippet in a CMakeLists.txt:

file(READ api.yaml API_YAML)
configure_file(schemautil.h.in schemautil.h)

The variable ${API_YAML} is used in schemautil.h.in

When I go to build, the configured file schemautil.h does not regenerate when I make changes to api.yaml.

How do I make updates to api.yaml trigger the configure_file line?

Also, if there is a better way to accomplish what I'm doing here -- i.e. stuffing api.yaml into source code at compile time, I'm interested.

question from:https://stackoverflow.com/questions/65945012/how-to-add-fileread-as-a-dependency-to-configure-file

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.3k views
Welcome To Ask or Share your Answers For Others

1 Answer

You can create a dependency on that file to trigger a re-configure by adding

set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS api.yaml)

See CMAKE_CONFIGURE_DEPENDS in the CMake documentation.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...