Re: [CMake] Converting implicit makefile rules
Hi Nick, Tyler, Another option is to pass the names of the lists to the macro (one for the CPP files, one for the XML files), instead of their contents. You would then need a ${${...}} construct to get their values. The (only) downside to that solution is that you cannot pass literal string arguments anymore. Best regards, Marcel Loose. On Mon, 2009-07-06 at 11:47 -0700, Tyler Roscoe wrote: On Mon, Jul 06, 2009 at 06:07:11PM +0100, Nick Davidson wrote: macro (MakeCustomTarget TARGET_FILE CPP XML) add_custom_target(TARGET_FILE ALL COMMAND process ${TARGET_FILE} ${CPP} COMMAND process ${TARGET_FILE} ${XML}) message(STATUS Cannot find xgettext) endmacro (MakeCustomTarget TARGET_FILE CPP XML) calling MakeCustomTarget(TargetFile ${LIST1} ${LIST2}) where LIST1 and I would definitely expect that you need to put quotes around ${LIST1} and ${LIST2} to presvere their listiness. LIST2 are semi-colon separated lists causes the first two elements of whatever the LIST1 was to get passed as CPP and XML - I had to resort to quoting the arguments and then turning them back in to lists with a set. macro (MakeCustomTarget TARGET_FILE CPP XML) set(CPP_LIST ${CPP}) set(XML_LIST ${XML}) add_custom_target(TARGET_FILE ALL COMMAND process ${TARGET_FILE} ${CPP_LIST} COMMAND process ${TARGET_FILE} ${XML_LIST}) endmacro (MakeCustomTarget TARGET_FILE CPP XML) MakePot(project.pot ${LIST1} ${LIST2}) I'm not so sure about this, but you may be tripping across the fact that arguments to a macro aren't real variables but are instead like C preprocessor #defines. Look at the docs for macro() for more details. If you don't like your set() workaround, you might be able to use a function() instead of a macro(), as function() behaves a little differently. tyler ___ 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 ___ 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
[CMake] Converting implicit makefile rules
Dear List, Is there an idomatic way of converting an implicit makefile rule to a CMakeLists construct? Currently I'm resorting to writing a macro which processes list variables with foreach and adds various linked custom targets but I'm finding lots of confusion when passing lists as arguments to macros. I tried the following: macro (MakeCustomTarget TARGET_FILE CPP XML) add_custom_target(TARGET_FILE ALL COMMAND process ${TARGET_FILE} ${CPP} COMMAND process ${TARGET_FILE} ${XML}) message(STATUS Cannot find xgettext) endmacro (MakeCustomTarget TARGET_FILE CPP XML) calling MakeCustomTarget(TargetFile ${LIST1} ${LIST2}) where LIST1 and LIST2 are semi-colon separated lists causes the first two elements of whatever the LIST1 was to get passed as CPP and XML - I had to resort to quoting the arguments and then turning them back in to lists with a set. macro (MakeCustomTarget TARGET_FILE CPP XML) set(CPP_LIST ${CPP}) set(XML_LIST ${XML}) add_custom_target(TARGET_FILE ALL COMMAND process ${TARGET_FILE} ${CPP_LIST} COMMAND process ${TARGET_FILE} ${XML_LIST}) endmacro (MakeCustomTarget TARGET_FILE CPP XML) MakePot(project.pot ${LIST1} ${LIST2}) Is this behavior expected? I'm running Debian Lenny and Cmake 2.6-patch0 Thanks, Nick Davidson __ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email __ ___ 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] Converting implicit makefile rules
On Mon, Jul 06, 2009 at 06:07:11PM +0100, Nick Davidson wrote: macro (MakeCustomTarget TARGET_FILE CPP XML) add_custom_target(TARGET_FILE ALL COMMAND process ${TARGET_FILE} ${CPP} COMMAND process ${TARGET_FILE} ${XML}) message(STATUS Cannot find xgettext) endmacro (MakeCustomTarget TARGET_FILE CPP XML) calling MakeCustomTarget(TargetFile ${LIST1} ${LIST2}) where LIST1 and I would definitely expect that you need to put quotes around ${LIST1} and ${LIST2} to presvere their listiness. LIST2 are semi-colon separated lists causes the first two elements of whatever the LIST1 was to get passed as CPP and XML - I had to resort to quoting the arguments and then turning them back in to lists with a set. macro (MakeCustomTarget TARGET_FILE CPP XML) set(CPP_LIST ${CPP}) set(XML_LIST ${XML}) add_custom_target(TARGET_FILE ALL COMMAND process ${TARGET_FILE} ${CPP_LIST} COMMAND process ${TARGET_FILE} ${XML_LIST}) endmacro (MakeCustomTarget TARGET_FILE CPP XML) MakePot(project.pot ${LIST1} ${LIST2}) I'm not so sure about this, but you may be tripping across the fact that arguments to a macro aren't real variables but are instead like C preprocessor #defines. Look at the docs for macro() for more details. If you don't like your set() workaround, you might be able to use a function() instead of a macro(), as function() behaves a little differently. tyler ___ 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] Converting implicit makefile rules
On Monday 06 July 2009, Nick Davidson wrote: Dear List, Is there an idomatic way of converting an implicit makefile rule to a CMakeLists construct? Currently I'm resorting to writing a macro which processes list variables with foreach and adds various linked custom targets but I'm finding lots of confusion when passing lists as arguments to macros. I tried the following: macro (MakeCustomTarget TARGET_FILE CPP XML) add_custom_target(TARGET_FILE ALL COMMAND process ${TARGET_FILE} ${CPP} COMMAND process ${TARGET_FILE} ${XML}) message(STATUS Cannot find xgettext) endmacro (MakeCustomTarget TARGET_FILE CPP XML) calling MakeCustomTarget(TargetFile ${LIST1} ${LIST2}) where LIST1 and LIST2 are semi-colon separated lists causes the first two elements of whatever the LIST1 was to get passed as CPP and XML - I had to resort to quoting the arguments and then turning them back in to lists with a set. macro (MakeCustomTarget TARGET_FILE CPP XML) set(CPP_LIST ${CPP}) set(XML_LIST ${XML}) add_custom_target(TARGET_FILE ALL COMMAND process ${TARGET_FILE} ${CPP_LIST} COMMAND process ${TARGET_FILE} ${XML_LIST}) endmacro (MakeCustomTarget TARGET_FILE CPP XML) MakePot(project.pot ${LIST1} ${LIST2}) Is this behavior expected? Yes. What you could do is to use the names of the variables as argument, not the contents. Then in the macro you have to dereference them once to get the name of the variable, and twice to get the actual content: macro (MakeCustomTarget TARGET_FILE CPP XML) foreach(currentCpp ${${CPP}} ... endmacro... MakePot(project.pot LIST1 LIST2) I'm running Debian Lenny and Cmake 2.6-patch0 2.6.0 wasn't a very good release, I would suggest = 2.6.2. Alex ___ 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