[CMake] EXEC_PROGRAM and inheritance
Brad King
brad.king at kitware.com
Wed Jan 12 11:07:08 EST 2005
Brian Hone wrote:
> Hi folks,
>
> I see a lot of posts which seem to indicate that there is popular
> support for allowing inheritance of the EXEC_PROGRAM command to
> subdirectories.
>
> Looking at the code, commands which allow inheritance simply add the
> following to the .h file:
>
> virtual bool IsInherited <cid:part1.07070002.03030705 at baesystems.com>()
> {return true;}
>
>
> Am I missing something? Would this cause the command to be re-executed
> from sub-directories, or the value to be cached and saved? It's a real
> devil to save the value from an external command and pass it around,
> which sort of defeats the purpose of an external command.
Yes, it is easy to make the command inherited but there are also cases
where it should not be inherited. When a command is inherited it gets
executed for its own directory and again for every subdirectory. This
is desirable for commands like SET so that the state of variables is
preserved in subdirectories, but it is not necessarily desirable for
expensive commands like CONFIGURE_FILE and EXEC_PROGRAM.
This all comes from a previous methodology left from ancient CMake
versions in which CMakeLists.txt code was not supposed to be a language.
We are planning to eventually change the evaluation order to allow
things like processing subdirectories before their parents. We have
chosen to delay this EXEC_PROGRAM issue until then, though no schedule
has been set.
-Brad
More information about the CMake
mailing list