[CMake] Reexecute cmake to update build.make
Mathieu Malaterre
mathieu.malaterre at gmail.com
Thu Jun 7 06:54:01 EDT 2007
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 <mathieu.malaterre at gmail.com> 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)
...
More information about the CMake
mailing list