[CMake] QT3 and embedding images
Alexander Neundorf
a.neundorf-work at gmx.net
Fri Aug 24 08:36:07 EDT 2007
On Friday 24 August 2007 07:41, Tim Schooley wrote:
> Hi folks,
>
> I've recently ported my project to CMake from standard Makefiles, but
> missed a vital point (only just noticed by running the damn thing!).
>
> I've looked around, but can't find the answer: How to I embed images
> into QT3 apps with CMake ? The Makefile generated from qmake was
> something like:
>
> ----
>
> .obj/qmake_image_collection.o: .ui/qmake_image_collection.cpp
> $(CXX) -c $(CXXFLAGS) $(INCPATH) -o .obj/qmake_image_collection.o
> .ui/qmake_image_collection.cpp
>
> .ui/qmake_image_collection.cpp: images/gtk-about.png
> $(UIC) -embed program images/gtk-about.png ... -o
> .ui/qmake_image_collection.cpp
>
> ----
>
> Should I make custom targets for all this, or is there something simpler?
Is this just for one image ?
Yes, you need add_custom_command(), if it's for more than one image you should
put it in a macro, something like this:
macro(embed_images src img)
add_custom_command(OUTPUT ${src}
COMMAND ${QT_UIC...} ...
DEPENDS ${img} )
endmacro(embed_images src img)
embed_images("${CMAKE_CURRENT_BINARY_DIR}/image.cpp" about.png)
add_executable(foo file1.cpp ... "${CMAKE_CURRENT_BINARY_DIR}/image.cpp")
If it's more than one image you can also put this in a foreach() loop inside
the macro.
If you have that working, it would be nice if you could post the script here.
Bye
Alex
More information about the CMake
mailing list