Re: ADD_CUSTOM_COMMAND and *multiple* DEPENDS Was: [CMake] Reexecute cmake to update build.make
On 6/8/07, Brandon Van Every <[EMAIL PROTECTED]> wrote: On 6/8/07, Mathieu Malaterre <[EMAIL PROTECTED]> wrote: > Ok, > > I finally found out what was the issue. I cannot believe no one has > had the issue in the past, as it seems like a pretty easy mistake to > do: > > SET(deps foo.h bla.h) > SEPARATE_ARGUMENTS(deps) # very very important ! > ADD_CUSTOM_COMMAND( > OUTPUT ... > COMMAND ... > DEPENDS ${deps} > ) > > that fixes all my previous problems. I cannot believe I did not realize > my deps were separated by a ';' ... I really need new glasses Huh? There is no need for special argument processing for a ${deps} list in the code snippet you've given. My code is filled with such lists. Unless your dependency data itself has semicolons in it, which would indeed cause trouble. Very strange filenames if they've got semicolons. Perhaps an extraction from a path or a list that's not working properly? Your SEPARATE_ARGUMENTS sounds like a band-aid on a problem further up your pipeline. Actually you are right. For some reason I used double quotes thinking that cmake might complain when ${deps} is emtpy. But it is not... Sorry for the noise, -Mathieu ___ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake
ADD_CUSTOM_COMMAND and *multiple* DEPENDS Was: [CMake] Reexecute cmake to update build.make
On 6/8/07, Mathieu Malaterre <[EMAIL PROTECTED]> wrote: Ok, I finally found out what was the issue. I cannot believe no one has had the issue in the past, as it seems like a pretty easy mistake to do: SET(deps foo.h bla.h) SEPARATE_ARGUMENTS(deps) # very very important ! ADD_CUSTOM_COMMAND( OUTPUT ... COMMAND ... DEPENDS ${deps} ) that fixes all my previous problems. I cannot believe I did not realize my deps were separated by a ';' ... I really need new glasses Huh? There is no need for special argument processing for a ${deps} list in the code snippet you've given. My code is filled with such lists. Unless your dependency data itself has semicolons in it, which would indeed cause trouble. Very strange filenames if they've got semicolons. Perhaps an extraction from a path or a list that's not working properly? Your SEPARATE_ARGUMENTS sounds like a band-aid on a problem further up your pipeline. On 6/8/07, Pau Garcia i Quiles <[EMAIL PROTECTED]> wrote: A couple of days ago I noticed something with the ";", too. If you have a list (created either with SET or with LIST), when you try to print it with MESSAGE( mylist ) elements are not separated by ";" but if you print it with MESSAGE( "mylist" ) (with quotes), it will. This is correct and expected CMake behavior. However it's not in the documentation for MESSAGE. I've added bug #5149 about the lack of documentation. Cheers, Brandon Van Every ___ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake
Re: ADD_CUSTOM_COMMAND and *multiple* DEPENDS Was: [CMake] Reexecute cmake to update build.make
Hello, A couple of days ago I noticed something with the ";", too. If you have a list (created either with SET or with LIST), when you try to print it with MESSAGE( mylist ) elements are not separated by ";" but if you print it with MESSAGE( "mylist" ) (with quotes), it will. SET( mylist FOO BAR FIZZBUZZ ) MESSAGE( mylist ) # produces FOOBARFIZZBUZZ MESSAGE( "mylist" ) # produces FOO;BAR;FIZZBUZZ Until now I have only noticed that behavior with MESSAGE, I don't know if that's a bug or if other commands are affected. That's with CMake 2.4.6, I have not tried any other version. -- Pau Garcia i Quiles http://www.elpauer.org (Due to the amount of work, I usually need 10 days to answer) Quoting Mathieu Malaterre <[EMAIL PROTECTED]>: Ok, I finally found out what was the issue. I cannot believe no one has had the issue in the past, as it seems like a pretty easy mistake to do: SET(deps foo.h bla.h) SEPARATE_ARGUMENTS(deps) # very very important ! ADD_CUSTOM_COMMAND( OUTPUT ... COMMAND ... DEPENDS ${deps} ) that fixes all my previous problems. I cannot believe I did not realize my deps were separated by a ';' ... I really need new glasses Thanks, -Mathieu On 6/7/07, gga <[EMAIL PROTECTED]> wrote: Mathieu Malaterre wrote: It looks like you are on windows. Could you please try a nmake ("NMake Makefiles") build and do: I'm on Linux (thank god), but have also a windows box with vnc. I tried it on both, with cmake2.5 (CVS), but cmake2.4 should be the same ( I was using it before ). 1) edit foo.i $ nmake TargetName vs 2) edit foo.i $ nmake rebuild_cache $ nmake TargetName Version #1 should fail, versus #2 should rebuild build.make, and redo the correct dep. Both rebuild TargetName, as they should. I did find two bugs that were making the stuff less efficient in the modified UseSWIG.cmake file I posted. One due to python files always need regeneration due to their .py files (I was wrapping stuff for ruby, so it is now more efficient for languages other than python) and that the swig -MF invocation was also creating the wrapper needlessly. There's still one minor gotcha where you can still fool the system not to detect a dependency change, but it is somewhat obscure so I won't mention it. -- Gonzalo Garramuño [EMAIL PROTECTED] AMD4400 - ASUS48N-E GeForce7300GT Kubuntu Edgy # - SWIG module for CMake # Defines the following macros: # SWIG_ADD_MODULE(name language [ files ]) # - Define swig module with given name and specified language # SWIG_LINK_LIBRARIES(name [ libraries ]) # - Link libraries to swig module # SWIG_GET_WRAPPER_DEPENDENCIES(swigFile genWrapper language DEST_VARIABLE) # - Put dependencies of the wrapper genWrapper generated by swig from # swigFile in DEST_VARIABLE # All other macros are for internal use only. # To get the actual name of the swig module, # use: ${SWIG_MODULE_name_REAL_NAME}. # Set Source files properties such as CPLUSPLUS and SWIG_FLAGS to specify # special behavior of SWIG. Also global CMAKE_SWIG_FLAGS can be used to add # special flags to all swig calls. # Another special variable is CMAKE_SWIG_OUTDIR, it allows one to specify # where to write all the swig generated module (swig -outdir option) # The name-specific variable SWIG_MODULE__EXTRA_DEPS may be used # to specify extra dependencies for the generated modules. SET(SWIG_CXX_EXTENSION "cxx") SET(SWIG_EXTRA_LIBRARIES "") SET(SWIG_PYTHON_EXTRA_FILE_EXTENSION "py") # # Get dependencies of the generated wrapper. # MACRO(SWIG_GET_WRAPPER_DEPENDENCIES swigFile genWrapper language DEST_VARIABLE) GET_FILENAME_COMPONENT(swig_getdeps_basename ${swigFile} NAME_WE) GET_FILENAME_COMPONENT(swig_getdeps_outdir ${genWrapper} PATH) GET_SOURCE_FILE_PROPERTY(swig_getdeps_extra_flags "${swigFile}" SWIG_FLAGS) IF("${swig_getdeps_extra_flags}" STREQUAL "NOTFOUND") SET(swig_getdeps_extra_flags "") ENDIF("${swig_getdeps_extra_flags}" STREQUAL "NOTFOUND") IF(NOT swig_getdeps_outdir) SET(swig_getdeps_outdir ${CMAKE_CURRENT_BINARY_DIR}) ENDIF(NOT swig_getdeps_outdir) SET(swig_getdeps_depsfile "${swig_getdeps_outdir}/swig_${swig_getdeps_basename}_deps.txt") GET_DIRECTORY_PROPERTY(swig_getdeps_include_directories INCLUDE_DIRECTORIES) SET(swig_getdeps_include_dirs) FOREACH(it ${swig_getdeps_include_directories}) SET(swig_getdeps_include_dirs ${swig_getdeps_include_dirs} -I${it}) ENDFOREACH(it) EXECUTE_PROCESS( COMMAND ${SWIG_EXECUTABLE} -MM -MF ${swig_getdeps_depsfile} ${swig_getdeps_extra_flags} ${CMAKE_SWIG_FLAGS} -${language} -o ${genWrapper} ${swig_getdeps_include_dirs} ${swigFile} RESULT_VARIABLE swig_getdeps_result ERROR_VARIABLE swig_getdeps_error OUTPUT_STRIP_TRAILING_WHITESPACE) IF(NOT ${swig_getdeps_result} EQUAL 0) MESSAGE(SEND_ERROR "Command \"${SWIG_EXECUTABLE} -MM -MF ${swig_getdeps_depsfile} ${swig_getdeps_extra_flags} ${CMAKE_SWIG_FLAGS} -${language} -o ${genWrapper} ${swig_getdeps_include
ADD_CUSTOM_COMMAND and *multiple* DEPENDS Was: [CMake] Reexecute cmake to update build.make
Ok, I finally found out what was the issue. I cannot believe no one has had the issue in the past, as it seems like a pretty easy mistake to do: SET(deps foo.h bla.h) SEPARATE_ARGUMENTS(deps) # very very important ! ADD_CUSTOM_COMMAND( OUTPUT ... COMMAND ... DEPENDS ${deps} ) that fixes all my previous problems. I cannot believe I did not realize my deps were separated by a ';' ... I really need new glasses Thanks, -Mathieu On 6/7/07, gga <[EMAIL PROTECTED]> wrote: Mathieu Malaterre wrote: > It looks like you are on windows. Could you please try a nmake ("NMake > Makefiles") build and do: > I'm on Linux (thank god), but have also a windows box with vnc. I tried it on both, with cmake2.5 (CVS), but cmake2.4 should be the same ( I was using it before ). > 1) > edit foo.i > $ nmake TargetName > > vs > 2) > edit foo.i > $ nmake rebuild_cache > $ nmake TargetName > > Version #1 should fail, versus #2 should rebuild build.make, and redo > the correct dep. Both rebuild TargetName, as they should. I did find two bugs that were making the stuff less efficient in the modified UseSWIG.cmake file I posted. One due to python files always need regeneration due to their .py files (I was wrapping stuff for ruby, so it is now more efficient for languages other than python) and that the swig -MF invocation was also creating the wrapper needlessly. There's still one minor gotcha where you can still fool the system not to detect a dependency change, but it is somewhat obscure so I won't mention it. -- Gonzalo Garramuño [EMAIL PROTECTED] AMD4400 - ASUS48N-E GeForce7300GT Kubuntu Edgy # - SWIG module for CMake # Defines the following macros: # SWIG_ADD_MODULE(name language [ files ]) # - Define swig module with given name and specified language # SWIG_LINK_LIBRARIES(name [ libraries ]) # - Link libraries to swig module # SWIG_GET_WRAPPER_DEPENDENCIES(swigFile genWrapper language DEST_VARIABLE) # - Put dependencies of the wrapper genWrapper generated by swig from # swigFile in DEST_VARIABLE # All other macros are for internal use only. # To get the actual name of the swig module, # use: ${SWIG_MODULE_name_REAL_NAME}. # Set Source files properties such as CPLUSPLUS and SWIG_FLAGS to specify # special behavior of SWIG. Also global CMAKE_SWIG_FLAGS can be used to add # special flags to all swig calls. # Another special variable is CMAKE_SWIG_OUTDIR, it allows one to specify # where to write all the swig generated module (swig -outdir option) # The name-specific variable SWIG_MODULE__EXTRA_DEPS may be used # to specify extra dependencies for the generated modules. SET(SWIG_CXX_EXTENSION "cxx") SET(SWIG_EXTRA_LIBRARIES "") SET(SWIG_PYTHON_EXTRA_FILE_EXTENSION "py") # # Get dependencies of the generated wrapper. # MACRO(SWIG_GET_WRAPPER_DEPENDENCIES swigFile genWrapper language DEST_VARIABLE) GET_FILENAME_COMPONENT(swig_getdeps_basename ${swigFile} NAME_WE) GET_FILENAME_COMPONENT(swig_getdeps_outdir ${genWrapper} PATH) GET_SOURCE_FILE_PROPERTY(swig_getdeps_extra_flags "${swigFile}" SWIG_FLAGS) IF("${swig_getdeps_extra_flags}" STREQUAL "NOTFOUND") SET(swig_getdeps_extra_flags "") ENDIF("${swig_getdeps_extra_flags}" STREQUAL "NOTFOUND") IF(NOT swig_getdeps_outdir) SET(swig_getdeps_outdir ${CMAKE_CURRENT_BINARY_DIR}) ENDIF(NOT swig_getdeps_outdir) SET(swig_getdeps_depsfile "${swig_getdeps_outdir}/swig_${swig_getdeps_basename}_deps.txt") GET_DIRECTORY_PROPERTY(swig_getdeps_include_directories INCLUDE_DIRECTORIES) SET(swig_getdeps_include_dirs) FOREACH(it ${swig_getdeps_include_directories}) SET(swig_getdeps_include_dirs ${swig_getdeps_include_dirs} -I${it}) ENDFOREACH(it) EXECUTE_PROCESS( COMMAND ${SWIG_EXECUTABLE} -MM -MF ${swig_getdeps_depsfile} ${swig_getdeps_extra_flags} ${CMAKE_SWIG_FLAGS} -${language} -o ${genWrapper} ${swig_getdeps_include_dirs} ${swigFile} RESULT_VARIABLE swig_getdeps_result ERROR_VARIABLE swig_getdeps_error OUTPUT_STRIP_TRAILING_WHITESPACE) IF(NOT ${swig_getdeps_result} EQUAL 0) MESSAGE(SEND_ERROR "Command \"${SWIG_EXECUTABLE} -MM -MF ${swig_getdeps_depsfile} ${swig_getdeps_extra_flags} ${CMAKE_SWIG_FLAGS} -${language} -o ${genWrapper} ${swig_getdeps_include_dirs} ${swigFile}\" failed with output:\n${swig_getdeps_error}") SET(swig_getdeps_dependencies "") ELSE(NOT ${swig_getdeps_result} EQUAL 0) FILE(READ ${swig_getdeps_depsfile} ${DEST_VARIABLE}) # Remove the first line STRING(REGEX REPLACE "^.+: +\n +" "" ${DEST_VARIABLE} "${${DEST_VARIABLE}}") # Clean the end of each line STRING(REGEX REPLACE " +()?\n" "\n" ${DEST_VARIABLE} "${${DEST_VARIABLE}}") # Clean beginning of each line STRING(REGEX REPLACE "\n +" "\n" ${DEST_VARIABLE} "${${DEST_VARIABLE}}") # clean paths STRING(REGEX REPLACE "" "/" ${DEST_VARIABLE} "${${DEST_VARIABLE}}") STRING(REGEX REPLACE "\n" ";" ${DEST_VARIABLE} "${${DEST_V
Re: [CMake] Reexecute cmake to update build.make
Mathieu Malaterre wrote: > It looks like you are on windows. Could you please try a nmake ("NMake > Makefiles") build and do: > I'm on Linux (thank god), but have also a windows box with vnc. I tried it on both, with cmake2.5 (CVS), but cmake2.4 should be the same ( I was using it before ). > 1) > edit foo.i > $ nmake TargetName > > vs > 2) > edit foo.i > $ nmake rebuild_cache > $ nmake TargetName > > Version #1 should fail, versus #2 should rebuild build.make, and redo > the correct dep. Both rebuild TargetName, as they should. I did find two bugs that were making the stuff less efficient in the modified UseSWIG.cmake file I posted. One due to python files always need regeneration due to their .py files (I was wrapping stuff for ruby, so it is now more efficient for languages other than python) and that the swig -MF invocation was also creating the wrapper needlessly. There's still one minor gotcha where you can still fool the system not to detect a dependency change, but it is somewhat obscure so I won't mention it. -- Gonzalo Garramuño [EMAIL PROTECTED] AMD4400 - ASUS48N-E GeForce7300GT Kubuntu Edgy # - SWIG module for CMake # Defines the following macros: # SWIG_ADD_MODULE(name language [ files ]) # - Define swig module with given name and specified language # SWIG_LINK_LIBRARIES(name [ libraries ]) # - Link libraries to swig module # SWIG_GET_WRAPPER_DEPENDENCIES(swigFile genWrapper language DEST_VARIABLE) # - Put dependencies of the wrapper genWrapper generated by swig from # swigFile in DEST_VARIABLE # All other macros are for internal use only. # To get the actual name of the swig module, # use: ${SWIG_MODULE_name_REAL_NAME}. # Set Source files properties such as CPLUSPLUS and SWIG_FLAGS to specify # special behavior of SWIG. Also global CMAKE_SWIG_FLAGS can be used to add # special flags to all swig calls. # Another special variable is CMAKE_SWIG_OUTDIR, it allows one to specify # where to write all the swig generated module (swig -outdir option) # The name-specific variable SWIG_MODULE__EXTRA_DEPS may be used # to specify extra dependencies for the generated modules. SET(SWIG_CXX_EXTENSION "cxx") SET(SWIG_EXTRA_LIBRARIES "") SET(SWIG_PYTHON_EXTRA_FILE_EXTENSION "py") # # Get dependencies of the generated wrapper. # MACRO(SWIG_GET_WRAPPER_DEPENDENCIES swigFile genWrapper language DEST_VARIABLE) GET_FILENAME_COMPONENT(swig_getdeps_basename ${swigFile} NAME_WE) GET_FILENAME_COMPONENT(swig_getdeps_outdir ${genWrapper} PATH) GET_SOURCE_FILE_PROPERTY(swig_getdeps_extra_flags "${swigFile}" SWIG_FLAGS) IF("${swig_getdeps_extra_flags}" STREQUAL "NOTFOUND") SET(swig_getdeps_extra_flags "") ENDIF("${swig_getdeps_extra_flags}" STREQUAL "NOTFOUND") IF(NOT swig_getdeps_outdir) SET(swig_getdeps_outdir ${CMAKE_CURRENT_BINARY_DIR}) ENDIF(NOT swig_getdeps_outdir) SET(swig_getdeps_depsfile "${swig_getdeps_outdir}/swig_${swig_getdeps_basename}_deps.txt") GET_DIRECTORY_PROPERTY(swig_getdeps_include_directories INCLUDE_DIRECTORIES) SET(swig_getdeps_include_dirs) FOREACH(it ${swig_getdeps_include_directories}) SET(swig_getdeps_include_dirs ${swig_getdeps_include_dirs} -I${it}) ENDFOREACH(it) EXECUTE_PROCESS( COMMAND ${SWIG_EXECUTABLE} -MM -MF ${swig_getdeps_depsfile} ${swig_getdeps_extra_flags} ${CMAKE_SWIG_FLAGS} -${language} -o ${genWrapper} ${swig_getdeps_include_dirs} ${swigFile} RESULT_VARIABLE swig_getdeps_result ERROR_VARIABLE swig_getdeps_error OUTPUT_STRIP_TRAILING_WHITESPACE) IF(NOT ${swig_getdeps_result} EQUAL 0) MESSAGE(SEND_ERROR "Command \"${SWIG_EXECUTABLE} -MM -MF ${swig_getdeps_depsfile} ${swig_getdeps_extra_flags} ${CMAKE_SWIG_FLAGS} -${language} -o ${genWrapper} ${swig_getdeps_include_dirs} ${swigFile}\" failed with output:\n${swig_getdeps_error}") SET(swig_getdeps_dependencies "") ELSE(NOT ${swig_getdeps_result} EQUAL 0) FILE(READ ${swig_getdeps_depsfile} ${DEST_VARIABLE}) # Remove the first line STRING(REGEX REPLACE "^.+: +\n +" "" ${DEST_VARIABLE} "${${DEST_VARIABLE}}") # Clean the end of each line STRING(REGEX REPLACE " +()?\n" "\n" ${DEST_VARIABLE} "${${DEST_VARIABLE}}") # Clean beginning of each line STRING(REGEX REPLACE "\n +" "\n" ${DEST_VARIABLE} "${${DEST_VARIABLE}}") # clean paths STRING(REGEX REPLACE "" "/" ${DEST_VARIABLE} "${${DEST_VARIABLE}}") STRING(REGEX REPLACE "\n" ";" ${DEST_VARIABLE} "${${DEST_VARIABLE}}") ENDIF(NOT ${swig_getdeps_result} EQUAL 0) ENDMACRO(SWIG_GET_WRAPPER_DEPENDENCIES) # # For given swig module initialize variables associated with it # MACRO(SWIG_MODULE_INITIALIZE name language) STRING(TOUPPER "${language}" swig_uppercase_language) STRING(TOLOWER "${language}" swig_lowercase_language) SET(SWIG_MODULE_${name}_LANGUAGE "${swig_uppercase_language}") SET(SWIG_MODULE_${name}_SWIG_LANGUAGE_FLAG "${swig_lowercase_language}") IF("x${SWIG_MODULE_${name}_
Re: [CMake] Reexecute cmake to update build.make
On 6/7/07, gga <[EMAIL PROTECTED]> wrote: Mathieu Malaterre wrote: > Example, your foo.i depends on bla.h. First time your configure, > dependency will be right, for instance: > > Makefile: > ... > foo_wrap.cpp: foo.i > foo_wrap.cpp: bla.h > swig -o foo_wrap.cpp foo.i > > but now edit your foo.i file and add a new header file 'bar.h'. There > is absolutely nothing in the Makefile that will say 'Hey rebuild > foo_wrap.cpp, because it now depends on bar.h' > Sure there is, even without those files I gave you. foo.so depends on foo.obj foo.obj depends on foo_wrap.cxx foo_wrap.cxx depends on foo.i when foo.i changes on disk (you added bar.h), foo_wrap.cxx gets regenerated and recompiled. What's missing by default in cmake is: foo.i depends on bla.h and other.i (this is what swig -MF gives you) so that whenever bla.h or other.i changes, so does foo.so. With the files I gave you and a proper swig with dependencies (ie. swig -MF), you should get that too. Works beautifully. It looks like you are on windows. Could you please try a nmake ("NMake Makefiles") build and do: 1) edit foo.i $ nmake TargetName vs 2) edit foo.i $ nmake rebuild_cache $ nmake TargetName Version #1 should fail, versus #2 should rebuild build.make, and redo the correct dep. IMHO you think this is working because you are either reexecuting CMake everytime, or Visual Studio has (somehow) a better dependency checking than the Makefile generator (remember CMake is not doing dep in the Visual Studio case). In any case this is not my test case : 1. Makefile (== CMake is doing the dep) 2. Do not explicitely reexecute a configure stage Thanks anyway for your help, Mathieu ___ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Reexecute cmake to update build.make
Mathieu Malaterre wrote: > Example, your foo.i depends on bla.h. First time your configure, > dependency will be right, for instance: > > Makefile: > ... > foo_wrap.cpp: foo.i > foo_wrap.cpp: bla.h > swig -o foo_wrap.cpp foo.i > > but now edit your foo.i file and add a new header file 'bar.h'. There > is absolutely nothing in the Makefile that will say 'Hey rebuild > foo_wrap.cpp, because it now depends on bar.h' > Sure there is, even without those files I gave you. foo.so depends on foo.obj foo.obj depends on foo_wrap.cxx foo_wrap.cxx depends on foo.i when foo.i changes on disk (you added bar.h), foo_wrap.cxx gets regenerated and recompiled. What's missing by default in cmake is: foo.i depends on bla.h and other.i (this is what swig -MF gives you) so that whenever bla.h or other.i changes, so does foo.so. With the files I gave you and a proper swig with dependencies (ie. swig -MF), you should get that too. Works beautifully. -- Gonzalo Garramuño [EMAIL PROTECTED] AMD4400 - ASUS48N-E GeForce7300GT Kubuntu Edgy ___ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Reexecute cmake to update build.make
On 6/7/07, gga <[EMAIL PROTECTED]> wrote: Mathieu Malaterre wrote: > This is a follow up on a previous post. > > I have written a simple dependency scanner macro (*). There is still > one dependency missing: > I need to reexecute the CMake macro every time the swig *.i file is > modified. > > How do I do that ? > You don't. You add the dependencies directly and let CMake do its magic. There is nothing magic in cmake. If you want a special dependencie to happen on language other than C/CPP/Java/Fortran to have to specify them explicitely. BTW... in the bug list there's already a UseSWIG with dependency scanning/updating (don't recall who did it). I forgot to re-mention, that I cannot use this solution as I am using an older swig executable that do not have -MM flag... I attach my modified versions of such (which work with cmake2.5 now), and also find swig a tad better. ...but anyway the very same exact problem occurs: MACRO(SWIG_GET_WRAPPER_DEPENDENCIES swigFile genWrapper language DEST_VARIABLE) EXECUTE_PROCESS( COMMAND ${SWIG_EXECUTABLE} -MM -MF ${swig_getdeps_depsfile} ${swig_getdeps_extra_flags} ${CMAKE_SWIG_FLAGS} -${language} -o ${genWrapper} ${swig_getdeps_include_dirs} ${swigFile} ... Example, your foo.i depends on bla.h. First time your configure, dependency will be right, for instance: Makefile: ... foo_wrap.cpp: foo.i foo_wrap.cpp: bla.h swig -o foo_wrap.cpp foo.i but now edit your foo.i file and add a new header file 'bar.h'. There is absolutely nothing in the Makefile that will say 'Hey rebuild foo_wrap.cpp, because it now depends on bar.h' Thanks for help, -Mathieu ___ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Reexecute cmake to update build.make
Mathieu Malaterre wrote: > This is a follow up on a previous post. > > I have written a simple dependency scanner macro (*). There is still > one dependency missing: > I need to reexecute the CMake macro every time the swig *.i file is > modified. > > How do I do that ? > You don't. You add the dependencies directly and let CMake do its magic. BTW... in the bug list there's already a UseSWIG with dependency scanning/updating (don't recall who did it). I attach my modified versions of such (which work with cmake2.5 now), and also find swig a tad better. -- Gonzalo Garramuño [EMAIL PROTECTED] AMD4400 - ASUS48N-E GeForce7300GT Kubuntu Edgy # - Find SWIG # This module finds an installed SWIG. It sets the following variables: # SWIG_FOUND - set to true if SWIG is found # SWIG_DIR - the directory where swig is installed # SWIG_EXECUTABLE - the path to the swig executable SET(SWIG_FOUND FOOBAR) FIND_PATH(SWIG_DIR SWIGConfig.cmake /usr/local/share/swig/1.3.32 /usr/local/share/swig/1.3.31 /usr/local/share/swig/1.3.30 /usr/local/share/swig/1.3.29 /usr/local/share/swig1.3 /usr/share/swig1.3 /usr/lib/swig1.3) FIND_PATH(SWIG_DIR swig.swg /usr/local/share/swig/1.3.32 /usr/local/share/swig/1.3.31 /usr/local/share/swig/1.3.30 /usr/local/share/swig/1.3.29 /usr/local/share/swig1.3 /usr/share/swig1.3 /usr/lib/swig1.3 "$ENV{PROGRAMFILES}/swig/1.3.32" "$ENV{PROGRAMFILES}/swig/1.3.31" "$ENV{PROGRAMFILES}/swig/1.3.30" "$ENV{PROGRAMFILES}/swig/1.3.29" "$ENV{PROGRAMFILES}/swig1.3" "C:/cygwin/usr/local/share/swig/1.3.32" "C:/cygwin/usr/local/share/swig/1.3.31" "C:/cygwin/usr/local/share/swig/1.3.30" "C:/cygwin/usr/local/share/swig/1.3.29" "C:/cygwin/usr/share/swig/1.3.32" "C:/cygwin/usr/share/swig/1.3.31" "C:/cygwin/usr/share/swig/1.3.30" "C:/cygwin/usr/share/swig/1.3.29" "C:/cygwin/usr/local/share/swig1.3" ) IF(EXISTS ${SWIG_DIR}) IF("x${SWIG_DIR}x" STREQUAL "x${CMAKE_ROOT}/Modulesx") MESSAGE("SWIG_DIR should not be modules subdirectory of CMake") ENDIF("x${SWIG_DIR}x" STREQUAL "x${CMAKE_ROOT}/Modulesx") IF(EXISTS ${SWIG_DIR}/SWIGConfig.cmake) INCLUDE(${SWIG_DIR}/SWIGConfig.cmake) SET(SWIG_FOUND 1) ELSE(EXISTS ${SWIG_DIR}/SWIGConfig.cmake) FIND_PROGRAM(SWIG_EXECUTABLE NAMES swig1.3 swig PATHS ${SWIG_DIR} "${SWIG_DIR}/.." "${SWIG_DIR}/../../bin" "${SWIG_DIR}/../../../bin" ) FIND_PATH( SWIG_USE_FILE_PATH NAME UseSWIG.cmake PATHS ${CMAKE_MODULE_PATH} ${CMAKE_ROOT}/Modules ) SET( SWIG_USE_FILE "${SWIG_USE_FILE_PATH}/UseSWIG.cmake" ) ENDIF(EXISTS ${SWIG_DIR}/SWIGConfig.cmake) ENDIF(EXISTS ${SWIG_DIR}) IF("x${SWIG_FOUND}x" STREQUAL "xFOOBARx") SET(SWIG_FOUND 0) IF(EXISTS ${SWIG_DIR}) IF(EXISTS ${SWIG_USE_FILE}) IF(EXISTS ${SWIG_EXECUTABLE}) SET(SWIG_FOUND 1) ENDIF(EXISTS ${SWIG_EXECUTABLE}) ENDIF(EXISTS ${SWIG_USE_FILE}) ENDIF(EXISTS ${SWIG_DIR}) IF(NOT ${SWIG_FOUND}) IF(${SWIG_FIND_REQUIRED}) MESSAGE(FATAL_ERROR "Swig was not found on the system. Please specify the location of Swig.") ENDIF(${SWIG_FIND_REQUIRED}) ENDIF(NOT ${SWIG_FOUND}) ENDIF("x${SWIG_FOUND}x" STREQUAL "xFOOBARx") # - SWIG module for CMake # Defines the following macros: # SWIG_ADD_MODULE(name language [ files ]) # - Define swig module with given name and specified language # SWIG_LINK_LIBRARIES(name [ libraries ]) # - Link libraries to swig module # SWIG_GET_WRAPPER_DEPENDENCIES(swigFile genWrapper language DEST_VARIABLE) # - Put dependencies of the wrapper genWrapper generated by swig from # swigFile in DEST_VARIABLE # All other macros are for internal use only. # To get the actual name of the swig module, # use: ${SWIG_MODULE_name_REAL_NAME}. # Set Source files properties such as CPLUSPLUS and SWIG_FLAGS to specify # special behavior of SWIG. Also global CMAKE_SWIG_FLAGS can be used to add # special flags to all swig calls. # Another special variable is CMAKE_SWIG_OUTDIR, it allows one to specify # where to write all the swig generated module (swig -outdir option) # The name-specific variable SWIG_MODULE__EXTRA_DEPS may be used # to specify extra dependencies for the generated modules. SET(SWIG_CXX_EXTENSION "cxx") SET(SWIG_EXTRA_LIBRARIES "") SET(SWIG_PYTHON_EXTRA_FILE_EXTENSION "py") # # Get dependencies of the generated wrapper. # MACRO(SWIG_GET_WRAPPER_DEPENDENCIES swigFile genWrapper language DEST_VARIABLE) GET_FILENAME_COMPONENT(swig_getdeps_basename ${swigFile} NAME_WE) GET_FILENAME_COMPONENT(swig_getdeps_outdir ${genWrapper} PATH) GET_SOURCE_FILE_PROPERTY(swig_getdeps_extra_flags "${swigFile}" SWIG_FLAGS) IF("${swig_getdeps_extra_flags}" STREQUAL "NOTFOUND") SET(swig_getdeps_extra_flags "") ENDIF("${swig_getdeps_extra_flags}" STREQUAL "NOTFOUND") IF(NOT swig_getdeps_outdir) SET(swig_getdeps_outdir ${CMAKE_CURRENT_BINARY_DIR}) ENDIF(NOT swig_getdeps_outdir) SET(swig_getdeps_depsfile "${swig_getdeps_outdir}/swi
[CMake] Reexecute cmake to update build.make
This is a follow up on a previous post. I have written a simple dependency scanner macro (*). There is still one dependency missing: I need to reexecute the CMake macro every time the swig *.i file is modified. How do I do that ? Thanks -Mathieu (*) On 5/30/07, Mathieu Malaterre <[EMAIL PROTECTED]> wrote: ... MACRO(SWIG_GET_DEP SWIG_FILE DEP_LIST) # Read the swig file: FILE(READ ${SWIG_FILE} swig_file) # STRING MATCHALL does not work, thus do a line by line STRING MATCH STRING(REGEX REPLACE "\r?\n" ";" ENT "${swig_file}") SET( dep_list ) FOREACH(line ${ENT}) STRING(REGEX MATCH "^[ ]*[%|#]include.*$" out1 ${line}) # REGEX REPLACE is ALWAYS called, thus producing garbage most of the time. Need to couple it with # REPLACE MATCH STRING(REGEX REPLACE "^[ ]*[%|#]include[ \"]*([^\"]+)[ \"]*$" "\\1" out ${line}) IF( out1 ) # discard any `%include swig_stuff.i` by only looking at header files: IF( out MATCHES ".*\\.h$" ) GET_DIRECTORY_PROPERTY(cmake_include_directories INCLUDE_DIRECTORIES) FOREACH(dir ${cmake_include_directories}) # append to the list any file that can be found in the INCLUDE_DIRECTORIES IF(EXISTS ${dir}/${out}) LIST(APPEND dep_list ${dir}/${out}) ENDIF(EXISTS ${dir}/${out}) ENDFOREACH(dir ${cmake_include_directories}) ENDIF( out MATCHES ".*\\.h$" ) ENDIF( out1 ) ENDFOREACH(line) LIST(SORT dep_list) # I need `uniq`... SET(${DEP_LIST} ${dep_list}) ENDMACRO(SWIG_GET_DEP) ... ___ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake