Am 11.03.2013 um 06:14 schrieb hce:

> Hi,
> 
> I have following statement to install a file from source directory to
> destination. It got a conflict error if the destination has already had the
> file. 
> 

Hello Jupiter,

can you post the error message here? I wasn't aware that install(FILES ...) did 
any checking besides comparing the dates and overwriting if the file to be 
installed is newer. 
Also, you misunderstood what Petr meant. You need to escape the quotes in the 
install(CODE "...") call, because you're effectively writing a string to a 
file, i.e.:

 install(CODE "
  if (NOT EXISTS \"${destination}/myfile.txt\")
        install(FILES \"${source}/myfile.txt\" DESTINATION ${destination})
    endif()
 ")

BUT: using install inside an install command smells like problems, so you 
better use the file(INSTALL...) directive, anyway:

 install(CODE "
  if (NOT EXISTS \"${destination}/myfile.txt\")
        file(INSTALL \"${source}/myfile.txt\" DESTINATION \"${destination}\")
    endif()
 ")

using the SCRIPT signature expects a cmake script file that will be included in 
the cmake_install.cmake script file. This means you would need to configure 
your paths in your cmakelists file

 configure_file(myfile_install.cmake.in myfile_install.cmake)
 install(SCRIPT myfile_install.cmake)

and in myfile_install.cmake.in you'd put

 if(NOT EXISTS "${destination}/myfile.txt")
   file(INSTALL "${source}/myfile.txt" DESTINATION "${destination}")
 endif()

Hope that helps,

Andreas

Attachment: smime.p7s
Description: S/MIME cryptographic signature

--

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

Reply via email to