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

David Cole david.cole at kitware.com
Wed Sep 9 06:53:15 EDT 2009


Or just use "install(FILES" -- it already does the "if not exists, if newer
than" checks...
Actually, what you have now is a strange combination of checking for the
file's existence at "CMake configure" time, but then running a custom
command at "make" time -- both of which happen before "make install"
entirely.


HTH,
David


On Wed, Sep 9, 2009 at 3:20 AM, Eric Noulard <eric.noulard at gmail.com> wrote:

> 2009/9/9 Bob Tanner <tanner at real-time.com>:
> > I must be missing something simple?
> >
> > During "make install" I only want to install a set of files if the do not
> > exist in destination.
> >
> > MACRO (COPY_IF_DOES_NOT_EXIST SOURCE DESTINATION)
> >        ADD_CUSTOM_COMMAND (
> >                TARGET COPY
> >                IF (NOT EXISTS ${DESTINATION})
> >                        COMMAND ${CMAKE_COMMAND} -E copy ${SOURCE}
> > ${DESTINATION}
> >                ENDIF (NOT EXISTS ${DESTINATION})
> >        )
> >
> >        ADD_CUSTOM_TARGET (
> >                COPY ALL
> >                COMMENT "Copy file: ${SOURCE} ${DESTINATION}"
> >        )
> >
> > ENDMACRO (COPY_IF_DOES_NOT_EXIST SOURCE DESTINATION)
> >
> > Works the first time, but if I delete the destination file a make install
> > won't install it again.
>
> With your current macro the file is "installed" at CMake run time and
> not during "make install".
>
> You may check that fact if you rerun cmake the file is copied again.
>
> You should look at the install(SCRIPT or install(CODE  command
> in order to execute CMake script at "install time".
>
>
>
>
> --
> Erk
> Membre de l'April - « promouvoir et défendre le logiciel libre » -
> http://www.april.org
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090909/40bcceda/attachment.htm>


More information about the CMake mailing list