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

2012-12-01 Thread Martin Koller
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.
--

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


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

2012-11-28 Thread Kay-Uwe 'Kiwi' Lorenz

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.

Regards, Kiwi


On 28.11.2012 13:41, Martin Koller wrote:

Hi,

I'm struggling with the following requirement:
I have a lib stored in a zip file (the lib is not built via cmake, e.g. 
delivered from external company).

I want a target to link against this lib and want to extract the lib from the 
zip file only if
this specific target is being built, and only if it is not already unzipped.

What I tried in the libs directory:

set(TARGET xxx)

add_library(${TARGET} STATIC IMPORTED GLOBAL)

set_target_properties(${TARGET} PROPERTIES IMPORTED_LOCATION
   ${CMAKE_CURRENT_BINARY_DIR}/xxx.a)

set(ZIPFILE xxx.zip)

add_custom_target(${TARGET}_lib
   COMMAND unzip -o ${CMAKE_CURRENT_SOURCE_DIR}/${ZIPFILE}
   DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${ZIPFILE}
   )
add_dependencies(${TARGET} ${TARGET}_lib)


Then I can use this target in e.g.
target_link_libraries(myTarget xxx)

The above however unzips the lib every time, even if it is already existing.
Is it possible to avoid that ?

P.S:This is the simple example. I have other similar problems when the zip file 
not only
holds 1 library but also a bunch of headerfiles and more than 1 lib ...



--

Kay-Uwe (Kiwi) Lorenz
IT Department
ModuleWorks GmbH
Ritterstr. 12a
52072 Aachen
Germany

HRB 11871
Amtsgericht Aachen
Geschäftsführer Yavuz Murtezaoglu
--

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


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

2012-11-28 Thread Andreas Pakulat
Hi,

On Wed, Nov 28, 2012 at 1:41 PM, Martin Koller  wrote:
> Hi,
>
> I'm struggling with the following requirement:
> I have a lib stored in a zip file (the lib is not built via cmake, e.g. 
> delivered from external company).
>
> I want a target to link against this lib and want to extract the lib from the 
> zip file only if
> this specific target is being built, and only if it is not already unzipped.
>
> What I tried in the libs directory:
>
> set(TARGET xxx)
>
> add_library(${TARGET} STATIC IMPORTED GLOBAL)
>
> set_target_properties(${TARGET} PROPERTIES IMPORTED_LOCATION
>   ${CMAKE_CURRENT_BINARY_DIR}/xxx.a)
>
> set(ZIPFILE xxx.zip)
>
> add_custom_target(${TARGET}_lib
>   COMMAND unzip -o ${CMAKE_CURRENT_SOURCE_DIR}/${ZIPFILE}
>   DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${ZIPFILE}
>   )
> add_dependencies(${TARGET} ${TARGET}_lib)
>
>
> Then I can use this target in e.g.
> target_link_libraries(myTarget xxx)
>
> The above however unzips the lib every time, even if it is already existing.
> Is it possible to avoid that ?

This should be doable by splitting the custom target into a custom
command and a custom target. For the custom command you then need to
list the output files generated by the unzip and thus it'll only be
executed if the .zip is newer than the output files or an output file
is missing. The custom target is then used to provide a dummy target
(use echo or something like that as command) and depends on the output
files from the custom command and used with add_dependencies. That way
the custom-target will always be out-of-date and hence "built" but it
only depends on the output of the custom-command which in turn knows
when to re-run the command and thus only does this if necessary.

Another option would be to do this in a cmake script file manually and
run that via cmake -P as command.

Andreas
--

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


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

2012-11-28 Thread Martin Koller
Hi,

I'm struggling with the following requirement:
I have a lib stored in a zip file (the lib is not built via cmake, e.g. 
delivered from external company).

I want a target to link against this lib and want to extract the lib from the 
zip file only if
this specific target is being built, and only if it is not already unzipped.

What I tried in the libs directory:

set(TARGET xxx)

add_library(${TARGET} STATIC IMPORTED GLOBAL)

set_target_properties(${TARGET} PROPERTIES IMPORTED_LOCATION
  ${CMAKE_CURRENT_BINARY_DIR}/xxx.a)

set(ZIPFILE xxx.zip)

add_custom_target(${TARGET}_lib
  COMMAND unzip -o ${CMAKE_CURRENT_SOURCE_DIR}/${ZIPFILE}
  DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${ZIPFILE}
  )
add_dependencies(${TARGET} ${TARGET}_lib)


Then I can use this target in e.g.
target_link_libraries(myTarget xxx)

The above however unzips the lib every time, even if it is already existing.
Is it possible to avoid that ?

P.S:This is the simple example. I have other similar problems when the zip file 
not only
holds 1 library but also a bunch of headerfiles and more than 1 lib ...

-- 
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.
--

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