[CMake] call already made makefile

SK sk at metrokings.com
Thu Nov 4 19:29:08 EDT 2010


On Sat, Oct 30, 2010 at 8:31 AM, Alan W. Irwin
<irwin at beluga.phys.uvic.ca> wrote:
> On 2010-10-29 20:50-0700 mina adel wrote:
>
>>
>> Hi All
>>
>> I have an open source code that I use in my project. This open source code
>> already has Makefile coded for it.
>>
>> I want to use cmake so that before it compile my project it first call the
>> cmake of these open source code, which will compile it to .la library.
>
> ..make?
>>
>> Then using this library, it compile my code.
>
> I assume from the context you mean make rather than cmake above.
>
> To run make (or any command) at run-time, use the combination of
> add_custom_command and add_custom_target.  Basically,
> add_custom_command creates an OUTPUT file (say your library) at run
> time, and add_custom_target file-depends on that file and creates a
> CMake target corresponding to the custom command which you can add as
> a dependency of your application target.  This insures make will be run (if
> the library is not up to date) before your application is built.
>

No, this does not work when the external command is a make process.
The problem is that the "output" of add_custom_command() is a target
with it's own dependencies.  The external make process must always run
in order catch dependencies that only the external make knows about.
The only way to make sure the make process always runs is to use
add_custom_target(), but alas, add_custom_target does allow us to
specify an output.

See this thread from a few days ago: add_custom_command depends on
output from add_custom_target.

As far as I know, there is no satisfactory way to do use external
makefiles with CMake.  I'm all ears if anyone has suggestions.


More information about the CMake mailing list