[CMake] add_dependency on a custom target

Nick Davidson Nick at toby-churchill.com
Wed Sep 15 07:34:43 EDT 2010


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 
______________________________________________________________________


More information about the CMake mailing list