[CMake] Simple dependency scanner,
aka GET_SOURCE_FILE_PROPERTY +INCLUDE_DIRECTORIES
Mathieu Malaterre
mathieu.malaterre at gmail.com
Tue May 29 11:03:18 EDT 2007
Hello,
I have written a very simple dependencie scanner (*). It works for
the limited usage that I have, except for one case. Let say my swig
file is:
%module FooBar
%{
#include "MyModule1.h"
#include "MyModule2.h"
#include "Python.h"
%}
Assuming the files MyModule1.h and MyModule2.h can be found by
GET_SOURCE_FILE_PROPERTY, but Python.h cannot. Is there a way to tell
GET_SOURCE_FILE_PROPERTY to use
GET_DIRECTORY_PROPERTY#INCLUDE_DIRECTORIES to figure out where
Python.h is ?
Thanks
-Mathieu
Ps: No I cannot use swig -MM option
(*)
MACRO(SWIG_GET_DEP SWIG_FILE)
# 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}")
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 )
IF( ${out} MATCHES ".*\\.h$" )
GET_SOURCE_FILE_PROPERTY(var ${out} LOCATION)
IF(EXISTS ${var} )
MESSAGE( "DEP: ${out}" )
ENDIF(EXISTS ${var} )
ENDIF( ${out} MATCHES ".*\\.h$" )
ENDIF( out1 )
ENDFOREACH(line)
ENDMACRO(SWIG_GET_DEP)
More information about the CMake
mailing list