[CMake] add_dependency on a custom target
Dear List, I'm using a file glob to extract a list of xml files to pass to a custom target to generate a pot file with getttext, most of the heavy lifting is handled by a Macro. include(FindMsgfmt) macro (MakePot BIN_NAME CPP_SOURCES XML_SOURCES) set(CPP_SRCS ${CPP_SOURCES}) set(XML_SRCS ${XML_SOURCES}) set(POT_FILE ${BIN_NAME}.pot) if (XGETTEXT_FOUND) message(STATUS "Adding Target Potfile: ${POT_FILE}") if (XML_SRCS) add_custom_target(${POT_FILE} ALL COMMAND ${XGETTEXT_EXECUTABLE} --language=C++ --force-po -kN_ -kNN_:1,2 -o ${POT_FILE} ${CPP_SRCS} COMMAND ${XGETTEXT_EXECUTABLE} --language=Glade --force-po -j -o ${POT_FILE} ${XML_SRCS} ) else (XML_SRCS) add_custom_target(${POT_FILE} ALL COMMAND ${XGETTEXT_EXECUTABLE} --language=C++ --force-po -kN_ -kNN_:1,2 -o ${POT_FILE} ${CPP_SRCS}) endif(XML_SRCS) add_dependencies(${POT_FILE} ${XML_SOURCES} ${CPP_SRCS}) else (XGETTEXT_FOUND) message(STATUS "Cannot find xgettext") endif(XGETTEXT_FOUND) endmacro (MakePot POT_NAME) The only problem is, if the list of xml files changes (e.g. a deletion) the cmake cache doesn't get regenerated and thus the xml files are not reglobbed and so the custom command fails. Any suggestions? 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] add_dependency on a custom target
Whoops, forgot to reply on list, sorry! > From: cmake-boun...@cmake.org > [mailto:cmake-boun...@cmake.org] On Behalf Of Andreas Pakulat > Sent: 15 September 2010 13:03 > To: cmake@cmake.org > Subject: Re: [CMake] add_dependency on a custom target > > On 15.09.10 12:34:43, Nick Davidson wrote: > > Dear List, > > > > I'm using a file glob to extract a list of xml files to pass to a > > custom target to generate a pot file with getttext, most of > the heavy > > lifting is handled by a Macro. > > > > include(FindMsgfmt) > > macro (MakePot BIN_NAME CPP_SOURCES XML_SOURCES) > > set(CPP_SRCS ${CPP_SOURCES}) > > set(XML_SRCS ${XML_SOURCES}) > > set(POT_FILE ${BIN_NAME}.pot) > > if (XGETTEXT_FOUND) > > message(STATUS "Adding Target Potfile: ${POT_FILE}") > > if (XML_SRCS) > > add_custom_target(${POT_FILE} ALL > > COMMAND ${XGETTEXT_EXECUTABLE} --language=C++ > --force-po > > -kN_ -kNN_:1,2 -o ${POT_FILE} ${CPP_SRCS} > > COMMAND ${XGETTEXT_EXECUTABLE} --language=Glade > > --force-po -j -o ${POT_FILE} ${XML_SRCS} ) > > else (XML_SRCS) > add_custom_target(${POT_FILE} ALL > > COMMAND ${XGETTEXT_EXECUTABLE} --language=C++ > --force-po > > -kN_ -kNN_:1,2 -o ${POT_FILE} ${CPP_SRCS}) > > endif(XML_SRCS) > > add_dependencies(${POT_FILE} ${XML_SOURCES} ${CPP_SRCS}) > > else (XGETTEXT_FOUND) > > message(STATUS "Cannot find xgettext") > > endif(XGETTEXT_FOUND) > > endmacro (MakePot POT_NAME) > > > > The only problem is, if the list of xml files changes (e.g. a > > deletion) the cmake cache doesn't get regenerated and thus the xml > > files are not reglobbed and so the custom command fails. > > > > Any suggestions? > > Don't use a glob (list the files individually) or remember to touch > the cmakelists.txt file after adding new files. I don't think there's > a way to have cmake re-run when calling just make within > cmakelists.txt. Ok, but why doesn't adding the files as dependencies work? The glob is stored in the cache - fine, there isn't a way for Cmake to automatically figure out what files it should check to see if anything has changed. Having added those files as dependencies of the target that uses the glob manually then surely it's just a list of files? Is there a fundamental difference between a list variable made from a globbed set of files and a list made from a manually specified set? > > Andreas > > -- Nickd __ 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
[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