[CMake] Using Eclipse CDT, CMake resets Eclipse project configuration frequently

Jonatan Bijl jonatan.bijl at tba.nl
Fri Jan 30 10:45:51 EST 2009


Thanks! FYI, I've created some macros to do the copying. Haven't
thoroughly tested them yet, but they appear to be working.

MACRO(COPY_FILE_IF_CHANGED in_file out_file target)
	ADD_CUSTOM_COMMAND (
		TARGET     ${target}
		POST_BUILD
		COMMAND    ${CMAKE_COMMAND}
		ARGS       -E copy_if_different ${in_file} ${out_file}
	)
	message("copying: ${in_file} to ${out_file}")
ENDMACRO(COPY_FILE_IF_CHANGED)


MACRO(COPY_FILE_INTO_DIRECTORY_IF_CHANGED in_file out_dir target)
	GET_FILENAME_COMPONENT(file_name ${in_file} NAME)
	COPY_FILE_IF_CHANGED(${in_file} ${out_dir}/${file_name}
${target})	
ENDMACRO(COPY_FILE_INTO_DIRECTORY_IF_CHANGED)

MACRO(COPY_DIRECTORY_IF_CHANGED in_dir out_dir target)
	FILE(GLOB_RECURSE copy_files ${in_dir}/*)
	FOREACH(in_file ${copy_files})
		STRING(REGEX REPLACE ${in_dir} ${out_dir} out_file
${in_file})
		COPY_FILE_IF_CHANGED(${in_file} ${out_file} ${target})
	ENDFOREACH(in_file)
ENDMACRO(COPY_DIRECTORY_IF_CHANGED)

Jonatan

-------------------------------------------------------------
This e-mail is intended exclusively for the addressee. If you
are not the addressee you must not read, copy, use or
disclose the e-mail nor the content; please notify us
immediately [by clicking 'Reply'] and delete this e-mail.


More information about the CMake mailing list