<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><BR><DIV> <SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; ">Hi,<BR class="Apple-interchange-newline"></SPAN> </DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>    I have recently started using CMake and find it to be an excellent tool for our cross-platform application. I am in the process of creating a set of macros for our internal use so that it abstracts out most of the CMake details and lets developers just list out their files. </DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>    The problem I am running into is that when I don't use my macro and call QT_WRAP_CPP directly in the CMakeLists.txt file, everything is fine, however when the same call is made from within my macro, I get errors from CMake. Following is an example of what I am doing and the errors from CMake.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>---- Working version -----</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>PROJECT (mylib)</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>:</DIV><DIV>:</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>SET (MOC_HEADERS</DIV><DIV>    a.h</DIV><DIV>    b.h</DIV><DIV>)</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco">QT_WRAP_CPP (mylib MOC_FILES ${MOC_HEADERS})</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco">ADD_LIBRARY (mylib STATIC ${SRCS} ${MOC_FILES})</FONT></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV>---- Non-working version -----<BR><DIV><BR class="khtml-block-placeholder"></DIV><DIV>PROJECT (mylib)</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>:</DIV><DIV>:</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>SET (MOC_HEADERS</DIV><DIV>    a.h</DIV><DIV>    b.h</DIV><DIV>)</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>OUR_MACRO_MAKE_LIB () </DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>#</DIV><DIV># MACRO (OUR_MACRO_MAKE_LIB)</DIV><DIV>#</DIV><DIV># QT_WRAP_CPP (${PROJECT_NAME} MOC_FILES ${MOC_HEADERS})</DIV><DIV># ADD_LIBRARY (${PROJECT_NAME} STATIC ${SRCS} ${MOC_FILES})</DIV><DIV>#</DIV><DIV># ENDMACRO (OUR_MACRO_MAKE_LIB)</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>---------------------------------------------</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>    I get the following error on compiling the non-working version with CMake (2.2):</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>CMake Error: Attempt to add a custom rule to output "moc_a.cxx" which already has a custom rule.</DIV><DIV>CMake Error: Attempt to add a custom rule to output "moc_b.cxx" which already has a custom rule.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>    Can someone throw light on how to solve this problem, or at least some means by which I can see more output on what's going on so that I can debug the issue.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>    Any help in this regard is much appreciated.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Thanks!</DIV><DIV>Amit</DIV><DIV><BR class="khtml-block-placeholder"></DIV></BODY></HTML>