[CMake] Only install file if it does not exist?

Bob Tanner tanner at real-time.com
Thu Sep 10 00:15:18 EDT 2009


On 2009-09-09 05:53:15 -0500, David Cole 
<david.cole at kitware.com> said:

> Or just use "install(FILES" -- it already does the "if not exists, if newer
> than" checks...

INSTALL (
	FILES ${CMAKE_CURRENT_SOURCE_DIR}/sample_features
	DESTINATION etc
	RENAME features
)

Using that, if "etc/features" exists and I run "make install" features 
gets overwritten every time.

$ file etc/features
etc/features: ASCII English text

$ echo "XXXXXXXXX" >> etc/features
$ grep "XXXXXXXXX" etc/features
XXXXXXXXX

$ cd path/in-source/build
$ make install

$ grep "XXXXXXXXX" etc/features
$ echo $?
1

Here is the Makefile login I'm attempting to mimic:

	if [ ! -f $(DESTDIR)$(SYSCONFDIR)/features ]; then \
		$(INSTALLDATA) ${srcdir}/sample_features	$(DESTDIR)$(SYSCONFDIR)/features ; \
	fi

-- 
Bob Tanner <tanner at real-time.com>                  | Phone : (952 943-8700
http://www.real-time.com, Linux, OSX, VMware | Fax   : (952)943-8500
Key fingerprint = F785 DDFC CF94 7CE8 AA87 3A9D 3895 26F1 0DDB E378




More information about the CMake mailing list