Re: [CMake] ADD_CUSTOM_COMMAND and Dependencies
Am Montag, den 25.07.2011, 15:49 +0200 schrieb Michael Wild: On 07/25/2011 03:24 PM, Micha Renner wrote: There is following sequence: ADD_EXECUTEABLE(generator gen.c) ADD_CUSTOM_COMMAND(OUTPUT tlib.h COMMAND generator tlib.h) ADD_LIBRARY(tlib tlib.c tlib.h) The question: Is it sure that ADD_EXECUTEABLE is invoked before the library is build or is here an ADD_DEPENDENCIES(tlib generator) necessary? Greetings Micha Yes, CMake should recognize that generator is a target and create the dependency of tlib.h on generator automagically. And since it knows that tlib.h is GENERATED, it will also add a dependency of tlib on tlib.h. If you want to make really sure that CMake understands that generator is a target, use generator expressions, like $TARGET_FILE:generator, but that works only since 2.8.4. So really clear is this not. After studying the documentation, to get more information for target_file, I found this line in the add_custom_command documentation: Additionally, if the target is an executable or library a file-level dependency is created to cause the custom command to re-run whenever the target is recompiled. ADD_CUSTOM_COMMAND(OUTPUT tlib.h COMMAND generator tlib.h DEPENDS generator) should solve my problem. But what is the difference to ADD_CUSTOM_COMMAND(OUTPUT tlib.h COMMAND $TARGET_FILE:generator generator tlib.h)? Greetings Micha ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] ADD_CUSTOM_COMMAND and Dependencies
On 08/01/2011 09:32 AM, Micha Renner wrote: Am Montag, den 25.07.2011, 15:49 +0200 schrieb Michael Wild: On 07/25/2011 03:24 PM, Micha Renner wrote: There is following sequence: ADD_EXECUTEABLE(generator gen.c) ADD_CUSTOM_COMMAND(OUTPUT tlib.h COMMAND generator tlib.h) ADD_LIBRARY(tlib tlib.c tlib.h) The question: Is it sure that ADD_EXECUTEABLE is invoked before the library is build or is here an ADD_DEPENDENCIES(tlib generator) necessary? Greetings Micha Yes, CMake should recognize that generator is a target and create the dependency of tlib.h on generator automagically. And since it knows that tlib.h is GENERATED, it will also add a dependency of tlib on tlib.h. If you want to make really sure that CMake understands that generator is a target, use generator expressions, like $TARGET_FILE:generator, but that works only since 2.8.4. So really clear is this not. After studying the documentation, to get more information for target_file, I found this line in the add_custom_command documentation: Additionally, if the target is an executable or library a file-level dependency is created to cause the custom command to re-run whenever the target is recompiled. ADD_CUSTOM_COMMAND(OUTPUT tlib.h COMMAND generator tlib.h DEPENDS generator) should solve my problem. You don't need the DEPENDS option, since CMake automatically determines that generator is a executable target, and adds the dependency by itself. But what is the difference to ADD_CUSTOM_COMMAND(OUTPUT tlib.h COMMAND $TARGET_FILE:generator generator tlib.h)? None, it is just more explicit, and allows for greater flexibility. The $...:... notation also allows one to retrieve other paths, not just target output files. Michael ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] ADD_CUSTOM_COMMAND and Dependencies
On 07/25/2011 03:24 PM, Micha Renner wrote: There is following sequence: ADD_EXECUTEABLE(generator gen.c) ADD_CUSTOM_COMMAND(OUTPUT tlib.h COMMAND generator tlib.h) ADD_LIBRARY(tlib tlib.c tlib.h) The question: Is it sure that ADD_EXECUTEABLE is invoked before the library is build or is here an ADD_DEPENDENCIES(tlib generator) necessary? Greetings Micha Yes, CMake should recognize that generator is a target and create the dependency of tlib.h on generator automagically. And since it knows that tlib.h is GENERATED, it will also add a dependency of tlib on tlib.h. If you want to make really sure that CMake understands that generator is a target, use generator expressions, like $TARGET_FILE:generator, but that works only since 2.8.4. HTH Michael ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake