[CMake] Adding MIME-types and .desktop files using CMake

Michael Wild themiwi at gmail.com
Tue Sep 7 02:06:46 EDT 2010


On 7. Sep, 2010, at 6:45 , Amir Pakdel wrote:

> Hi developers,
> 
> I am trying to add a MIME type for "Basket Note Pads" files so that
> Desktop Environments (KDE and GNOME) can recognise them. For that
> purpose, I created a basket.xml and included the MIME type in the
> basket.desktop file; then, I have added the MIME
> type and associated this MIME type with the basket.desktop using the
> following commands:
> 
> xdg-mime install --novendor basket.xml
> xdg-desktop-menu install --novendor basket.desktop
> xdg-mime default basket.desktop application/x-basket-item
> 
> This procedure seems work fine, but I cannot add it to the CMake. I
> mean, I cannot do it automatically during installation via CMake
> rules.
> 
> Below is basket.xml:
> <?xml version="1.0" encoding="UTF-8"?>
> <mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
>  <mime-type type="application/x-basket-item">
>    <sub-class-of type="text/xml"/>
>    <sub-class-of type="application/xml"/>
>    <comment>Basket Note Pads</comment>
>    <icon>basket</icon>
>    <glob pattern=".basket" weight="50" />
>    <magic priority="90">
>        <match type="string" offset="2" value="xml">
>          <match type="string" offset="39" value="!DOCTYPE basket>"/>
>        </match>
>    </magic>
>    <root-XML localName="basket" />
>  </mime-type>
> </mime-info>
> 
> 
> And this is the basket.desktop file:
> [Desktop Entry]
> Type=Application
> Exec=basket %f
> MimeType=application/x-basket-archive;application/x-basket-template;application/x-basket-item;
> Icon=basket
> Categories=Qt;KDE;Office;
> X-DBUS-StartupType=Unique
> Name=BasKet Note Pads
> GenericName=Multi-Purpose Notepad
> Comment=Taking care of your ideas.
> 
> 
> 
> 
> 
> Can anyone help me please.
> 
> Cheers,
> 
> Amir

Write the commands to a script file (probably created using configure_file) and then invoke it in

install(SCRIPT ${CMAKE_BINARY_DIR}/script_name)

You can write a shell script, or if you prefer a CMake script that uses execute_process to run the xdg-* commands.

It would also be advisable to use find_program in your CMakeLists.txt file to find these executables and then configure them into the script, otherwise you're never sure whether the user has them actually installed.

HTH

Michael

--
There is always a well-known solution to every human problem -- neat, plausible, and wrong.
H. L. Mencken

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 195 bytes
Desc: This is a digitally signed message part
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100907/37a860bc/attachment.pgp>


More information about the CMake mailing list