[CMake] Re: custom preprocessor

Alexander Neundorf a.neundorf-work at gmx.net
Mon Jan 29 02:25:35 EST 2007


-------- Original-Nachricht --------
Datum: Fri, 26 Jan 2007 15:24:29 -0800
Von: "Ignacio Castaño" <castano at gmail.com>
An: cmake at cmake.org
Betreff: [CMake] Re: custom preprocessor

> I could use something as follows:
> 
> GET_FILE_DEPENDENCIES(CUDEPS ${CUFILE})
> 
> ADD_CUSTOM_COMMAND (
> 	OUTPUT ${CFILE}
> 	COMMAND ${CUDA_COMPILER}
> 	ARGS -cuda ${cuda_includes} ${CUDA_OPTIONS} -o ${CFILE} ${CUFILE}
> 	MAIN_DEPENDENCY ${CUFILE}
> 	DEPENDS ${CUDEPS})
> 
> Where GET_FILE_DEPENDENCIES is a macro like:
> 
> MACRO (GET_CUFILE_DEPENDENCIES dependencies file)
> 	GET_FILENAME_COMPONENT(filepath ${file} PATH)
> 
> 	#  parse file for dependencies
> 	FILE(READ "${file}" CONTENTS)
> 	STRING(REGEX MATCHALL "#[ \t]*include[ \t]+[<\"][^>\"]*" DEPS
> "${CONTENTS}")
> 
> 	SET(${dependencies})
> 	FOREACH(DEP ${DEPS})
> 		STRING(REGEX REPLACE "#[ \t]*include[ \t]+[<\"]" "" DEP "${DEP}")
> 		MESSAGE("${DEP}")
> 		SET(${dependencies} ${${dependencies}} ${filepath}/${DEP})
> 	ENDFOREACH(DEP)
> ENDMACRO (GET_CUFILE_DEPENDENCIES)
> 
> But that does not search for dependencies through the include search
> paths properly and I'm sure there code to do that in cmake already,
> but is there any command exposing it?

AFAIK no.
So your code looks like the right way to go.
Or have a look at the cmake code itself and see whether something can be done there to have this supported more easily.
But, check out the command which is run during the build to scan for dependencies. Maybe you can call this yourself ?

Bye
Alex

-- 
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! 
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer


More information about the CMake mailing list