[CMake] Re: custom preprocessor

Ignacio Castaño castano at gmail.com
Fri Jan 26 18:24:29 EST 2007


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?

Thanks!

-- 
Ignacio Castaño
castano at gmail.com


On 1/25/07, Ignacio Castaño <castano at gmail.com> wrote:
> Hi,
>
> I use a custom preprocessor to compile some of my files. For that to
> work I create custom commands, so that for each c file, a gen.c file
> is produced. Only the generated files are compiled. There's a
> dependency between the gen.c and the c file, so that when the c file
> changes the gen.c file is regenerated, but when a dependency of the c
> file changes, it's not regenerated, because the c file is not being
> scanned for dependencies.
>
> How can I tell cmake to do that?
>
> Thanks!
>
> --
> Ignacio Castaño
> castano at gmail.com


More information about the CMake mailing list