CMake Configure File Build Rule?

I do not think this has an easy answer. I see two options.

Up vote 0 down vote favorite share g+ share fb share tw.

I'm using CMake for my build system and in the project, we will have a bunch of configuration files. Some of them will just need to be copied over, some will need to be modified per computer. I'm currently using CMake's "configure_file" command to copy/replace parts of the file.

This works great, and I love how I can use any variable from CMake in the configure routine. But if you change the original file, CMake will not pick this up and you have to rerun cmake for it to configure the directory. When I run "make", I want it to pick up that I've changed the file and rerun configure.

It will also reconfigure files always, even if the file it is overwriting is newer. I want it to act like a custom target. I think I can do this with add_custom_command, but I don't think I can run a CMake command from add_custom_command.

So is there anyway to duplicate the behaviour that configure_file does in CMake? Cmake link|improve this question asked Aug 21 '10 at 4:38Jonathan Sternberg1,806119 75% accept rate.

I do not think this has an easy answer. I see two options: To trigger a re-run of cmake if an input changes, you might be able to make your input file depend on CMakeLists.txt. To run a cmake command as part of and add_custom_command, there is the variable ${CMAKE_COMMAND}, which will give you the path to the running cmake.

You could, as part of the configure step, generate a fragment of CMake code (that calls configure_file) that is invoked using the -P option. Either pass substitutions on the command line using -D, or write them to the CMake fragment.

I recently upgraded to CMake 2.8. It seems like it automatically has the exact behavior I wanted.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions