[CMake] how to add_library with an already compiled lib in a zip file ?

Martin Koller martin.koller at etm.at
Sat Dec 1 06:24:45 EST 2012


On Wednesday 28 November 2012 14:40:47 you wrote:
> Hi Martin,
> 
> you have to add a custom command to generate your lib and make your custom
> target depending on it:
> 
> add_custom_command(
> 	OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/xxx.a
> 	COMMAND
> 		unzip -o ${CMAKE_CURRENT_SOURCE_DIR}/${ZIPFILE}
> 	DEPENDS
> 		${CMAKE_CURRENT_SOURCE_DIR}/${ZIPFILE}
> 	)
> 
> add_custom_target(
> 	${TARGET}_lib
> 	DEPENDS
> 		${CMAKE_CURRENT_BINARY_DIR}/xxx.a
> 	)
> 
> This will unzip the xxx.a only if your zipfile has changed.

Thanks for the help.

I now also finally found the problem here why the unzip was _always_ done:
The unzip restores the modification time of the file as it is inside the zipfile, which is
in the past.
To make it work correctly, I simply need to pass the option -DD to unzip to get the current
timestamp on the files, and voila!

-- 
Best regards/Schöne Grüße

Martin

A: Because it breaks the logical sequence of discussion
Q: Why is top posting bad?

()  ascii ribbon campaign - against html e-mail 
/\  www.asciiribbon.org   - against proprietary attachments

This mail was not scanned before sending.
It was sent from a secure Linux desktop.


More information about the CMake mailing list