No subject


Mon Dec 15 09:51:36 EST 2008


 - Somewhere on your filesystem there is a file named something.desc.

 - This file, something.desc, consists of one line something like this:

    $exec_string =3D "./abc"

 - Because of this line occurring in this file, something.desc, your
makefile becomes aware that it must create an executable file named
"abc".

So what would happen if you were to create another .desc file tomorrow,
somethingelse.desc, containing this line:

    $exec_string =3D "./xyz"

And suppose you put this file in the same directory as something.desc.
Based on what you have told us so far, which is that your makefile
creates "./abc" just because there is a .desc file with that string in
it, should we expect that now your makefile will also create a different
executable file "./xyz" in addition to the file "./abc"?  Somehow your
makefile would be able to deduce what the correct source files are to
build this new executable?

This is beyond belief.  Clearly there are important pieces of
information about your process that you have not thought to tell us
because you assumed they would be common knowledge.  They are not common
knowledge, and we are completely in the dark still.


Is it possible that the existence of this file something.desc actually
has no causal influence on your makefile at all?  Is it possible that
someone did this:

 1. They wrote a makefile that contains in it a target something like
this, so that 'make' will know that it must build the executable file
"abc":

    abc: $(SOURCEFILES)
         $(BUILD) $(SOURCEFILES) $(OPTIONS) -o abc

 2. In order to support some other part of your development process that
runs _after_ 'make' has completed, they wrote a file named
something.desc that tells this other process about "abc", analogous to
the way the makefile told 'make' about "abc":

    $exec_string =3D "./abc"

In other words, is is possible that there is actually no
cause-and-effect relationship between the .desc file and what your
makefile does, but instead both of these things are effects that were
caused by a decision someone made in the past to build and use an
executable file named "./abc" in a certain way?

If this is the case, then all CMake has to do for you is to generate a
new makefile with the target "abc" as before, for example "abc:
sourcefile1 sourcefile2", etc.  In that case CMake has no reason to
read, write, or do anything else with this file something.desc which is
intended to be used by a different tool.  Usually when one of us has
such a requirement, it means that in a CMakeLists.txt file we have a
command like this:

    ADD_EXECUTABLE(abc ${SOURCE_FILES})

where ${SOURCE_FILES} is a list of the files that must be compiled in
order to build the executable.

If this is _not_ the case, then you must tell us more about what
actually has to happen while your old makefile is executing.  All you
have told us so far is that 'make' must build an exectuable file named
"./abc", which does not tell us what is so different about your process
that you cannot simply write an ADD_EXECUTABLE command to create "abc".

If your difficulty is that your makefile must somehow _execute_ the file
"./abc" after building it, then the ADD_CUSTOM_COMMAND command in CMake
may help you, as others have suggested.  But now I am not sure this is
what you are trying to do at all; the only definite action that I
understand you require 'make' to do is to build the executable file
"./abc".

Perhaps you must lead us through the process in exact detail, step by
step, something like this:

  1. You cd to the directory where you want to build your project.

  2. You run 'make'.

  3. 'make' does some things in other parts of the project irrelevant to
the file "./abc".

  4. 'make' visits a subdirectory named ________.

  5. 'make' performs the command _____________ in this subdirectory.

  6. 'make' compiles source files that it identifies because
____________.

  7. 'make' links the compiled objects to create the executable file
"abc" because ___________.

  8. 'make' performs the command _____________ in this same
subdirectory.

  9. 'make' goes on to do other things not relevant to this discussion,
and then it is done.

I think you have told us that step 6 must occur somehow, but you haven't
really told us anything about how the makefile decides to do this or
what else it does.

David Karr



More information about the CMake mailing list