[CMake] How to set Overwrite or no over write in install(FILES ....)?

hce jupiter.hce at gmail.com
Mon Mar 11 05:06:23 EDT 2013


Thanks Petr. I changed to use SCRIPT, it still got syntax error either.
Please correct me what is wrong in the following statement.

install(SCRIPT "
     if (not exists "${destination}/myfile.txt")
         install(FILES "${source}/myfile.txt" DESTINATION ${destination})
     endif()
")

Also, even the syntax is fixed, I am not clear how it can work. The 
install(FILES "${source}/myfile.txt" DESTINATION ${destination}) is
basically to install ${source}/myfile.txt to %config
"${destination}/myfile.txt" in the spec, where the check "if (not exists
"${destination}/myfile.txt")" can be performed during installation?

Appreciate correct me.

Thank you.

Kind regards.

Jupiter



Petr Kmoch wrote
> Hi Jupiter,
> 
> regarding your second question: you'd need to escape the nested
> quotes. Also, I'm not sure if 'not exists' can be given in lowercase.
> 
> However, I'd strongly suggest using install(SCRIPT ...) instead of
> install(CODE ...), precisely because of the escaping issues.
> 
> Petr
> 
> On Mon, Mar 11, 2013 at 6:14 AM, hce <

> jupiter.hce@

> > wrote:
>> 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.
>>
>> install(FILES "${source}/myfile.txt" DESTINATION ${destination})
>>
>> Is there anyway to set either overwrite, or no overwrite if the file
>> exists?
>> Or any workaround to stop the conflict error?
>>
>> I also tried following code, but I've got syntax error, if the
>> install(CODE
>> ..) can make it work, could you please correct my following code?
>>
>> install(CODE "
>>     if (not exists "${destination}/myfile.txt")
>>         install(FILES "${source}/myfile.txt" DESTINATION ${destination})
>>     endif()
>> ")
>>
>> Thank you.
>>
>> Kind regards,
>>
>> Jupiter
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://cmake.3232098.n2.nabble.com/How-to-set-Overwrite-or-no-over-write-in-install-FILES-tp7583548.html
>> Sent from the CMake mailing list archive at Nabble.com.
>> --
>>
>> 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
> --
> 
> 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





--
View this message in context: http://cmake.3232098.n2.nabble.com/How-to-set-Overwrite-or-no-over-write-in-install-FILES-tp7583548p7583563.html
Sent from the CMake mailing list archive at Nabble.com.


More information about the CMake mailing list