<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Thanks for those suggestions, I was on that path, but I can not get it to work properly:<div><br></div><div><div><div><div>foo$ cmake .</div><div>-- Configuring done</div><div>-- Generating done</div><div>-- Build files have been written to: /home/bart/foo</div><div>foo$ make</div><div>Scanning dependencies of target foo</div><div>make[2]: *** No rule to make target ` /home/bart/foo/foo_int.c', needed by `CMakeFiles/foo.dir/_/home/bart/foo/foo_int.c.o'. Stop.</div><div>make[1]: *** [CMakeFiles/foo.dir/all] Error 2</div><div>make: *** [all] Error 2</div><div>foo$ ls foo_int.c </div><div>foo_int.c</div><div>foo$ </div><div><br></div></div><div><br></div></div><div><span class="Apple-style-span" style="font-family: Times; "><pre>---------------------------
File: CMakeLists.txt
---------------------------</pre></span><div><div><div>PROJECT(foo)</div><div><br></div><div># There will be more than one source file..</div><div>SET(LIBSOURCES foo)</div><div><br></div><div>foreach(libsrc ${LIBSOURCES})</div><div><br></div><div>set(DST_I "${CMAKE_CURRENT_SOURCE_DIR}/${libsrc}_int.c")</div><div>set(DST_L "${CMAKE_CURRENT_SOURCE_DIR}/${libsrc}_long.c")</div><div><br></div><div>set(SRC "${CMAKE_CURRENT_SOURCE_DIR}/${libsrc}.c")</div><div><br></div><div>CONFIGURE_FILE(${SRC} ${DST_I} COPYONLY)</div><div>CONFIGURE_FILE(${SRC} ${DST_L} COPYONLY)</div><div><br></div><div>SET(LIBSOURCES_I "${LIBSOURCES_I} ${DST_I}")</div><div>SET(LIBSOURCES_L "${LIBSOURCES_L} ${DST_L}")</div><div><br></div><div>endforeach(libsrc)</div><div><br></div><div>SET_SOURCE_FILES_PROPERTIES({LIBSOURCES_I} PROPERTIES COMPILE_FLAGS "-DDINT")</div><div>SET_SOURCE_FILES_PROPERTIES({LIBSOURCES_L} PROPERTIES COMPILE_FLAGS "-DDLONG")</div><div>SET_SOURCE_FILES_PROPERTIES(${LIBSOURCES_I} PROPERTIES GENERATED true)</div><div>SET_SOURCE_FILES_PROPERTIES(${LIBSOURCES_L} PROPERTIES GENERATED true)</div><div><br></div><div>ADD_LIBRARY( foo ${LIBSOURCES_I} ${LIBSOURCES_L})</div></div></div><div><div><br></div><div>If I remove the generated property lines, cmake can not find the generated source files, either way there is </div><div>a problem with the dependencies as generated from my CMakeList.</div><div><br></div><div>Thanks for the help.</div><div><br></div><div><br></div><div><br></div><div>On Dec 29, 2009, at 12:52, Michael Wild wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div><br>On 29. Dec, 2009, at 21:44 , Eric Noulard wrote:<br><br><blockquote type="cite">2009/12/29 Richard Wackerbarth <<a href="mailto:richard@nfsnet.org">richard@nfsnet.org</a>>:<br></blockquote><blockquote type="cite"><blockquote type="cite">Not as a "real" solution, but more as a "workaround", you could create a "derived source file" which is just a copy of the source file and then you would have two separate files to be compiled with the appropriate flags.<br></blockquote></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">That's one solution, see below for more information.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><blockquote type="cite">On Dec 29, 2009, at 2:22 PM, Bart wrote:<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">Hi,<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">I'm trying to find a way to build a library with two different instances of the same source file.<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">for example I would like to compile foo.c with -DDINT into foo_int.o and with -DDLONG into foo_long.o<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">and have both objects added to the same library libfoo.a<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">I have experimented with custom command to generate the source files (which did not work), and would have still<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">left me with how to compile them with different -D flags.<br></blockquote></blockquote></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Same kind of question has been asked on the ML recently,<br></blockquote><blockquote type="cite">may be you can re-read the thread<br></blockquote><blockquote type="cite"><a href="http://www.cmake.org/pipermail/cmake/2009-December/033813.html">http://www.cmake.org/pipermail/cmake/2009-December/033813.html</a><br></blockquote><blockquote type="cite"><br></blockquote><br>Or you can use CONFIGURE_FILE to create "wrappers" which #include the actual source file. If it's always the same flags, you can do it statically, using something like this:<br><br>wrap_foo.c:<br>/* -------------------------- */<br>/* clean up */<br>#ifdef DINT<br>#undef DINT<br>#endif<br>#ifdef DLONG<br>#undef DLONG<br>#endif<br><br>/* compile for int */<br>#define DINT<br>#include "foo.c"<br>#undef DINT<br><br>/* compile for long */<br>#define DLONG<br>#include "foo.c"<br>#endif <br>/* -------------------------- */<br><br>Michael<br><br>_______________________________________________<br>Powered by <a href="http://www.kitware.com">www.kitware.com</a><br><br>Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br><br>Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ">http://www.cmake.org/Wiki/CMake_FAQ</a><br><br>Follow this link to subscribe/unsubscribe:<br><a href="http://www.cmake.org/mailman/listinfo/cmake">http://www.cmake.org/mailman/listinfo/cmake</a><br><br></div></blockquote></div><br></div></div></body></html>