find_package_version_check

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

find_package_version_check

Andreas Schneider
Hi,

I had to add a version check to on of my find modules in KDE. So I started and
asked myself why do I have to right so much code to get a version check. This
should be done by CMake and not by me.

So I've created a function find_package_version_check() you can use. All you
have to do is to set the version number.

Example:
find_package(LibSSH 0.3.2 EXACT)

# check for the version and set it
set(LibSSH_VERSION 0.4.0)
find_package_version_check(LibSSH DEFAULT_MSG)

Error:
  The installed LibSSH version 0.4.0 is too new, version 0.3.2 is required.


Comments and improvements are very welcome :)


Cheers,

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

signature.asc (204 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: find_package_version_check

Eric Noulard
2009/8/13 Andreas Schneider <[hidden email]>:

> Hi,
>
> I had to add a version check to on of my find modules in KDE. So I started and
> asked myself why do I have to right so much code to get a version check. This
> should be done by CMake and not by me.
>
> So I've created a function find_package_version_check() you can use. All you
> have to do is to set the version number.
>
> Example:
> find_package(LibSSH 0.3.2 EXACT)
>
> # check for the version and set it
> set(LibSSH_VERSION 0.4.0)
> find_package_version_check(LibSSH DEFAULT_MSG)
>
> Error:
>  The installed LibSSH version 0.4.0 is too new, version 0.3.2 is required.
>
> Comments and improvements are very welcome :)

Two comments:

1)  You seems to forget to attach you CMake macro/function file for
"find_package_version_check"?

2)  Why is the existing find_package(LibSSH <version> EXACT) not
sufficient for you?

--
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org
_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: find_package_version_check

Andreas Pakulat-2
On 13.08.09 10:55:30, Eric Noulard wrote:

> 2009/8/13 Andreas Schneider <[hidden email]>:
> > I had to add a version check to on of my find modules in KDE. So I started and
> > asked myself why do I have to right so much code to get a version check. This
> > should be done by CMake and not by me.
> >
> > So I've created a function find_package_version_check() you can use. All you
> > have to do is to set the version number.
> >
> > Example:
> > find_package(LibSSH 0.3.2 EXACT)
> >
> > # check for the version and set it
> > set(LibSSH_VERSION 0.4.0)
> > find_package_version_check(LibSSH DEFAULT_MSG)
> >
> > Error:
> >  The installed LibSSH version 0.4.0 is too new, version 0.3.2 is required.
> >
> > Comments and improvements are very welcome :)
>
> 2)  Why is the existing find_package(LibSSH <version> EXACT) not
> sufficient for you?

Because that means the package in question also needs to use cmake (or
rather install the needed .cmake files for cmake to do the version check).

However I think the find-module should use this new function, not the
application's CMakeLists.txt.

Andreas

--
You have the capacity to learn from mistakes.  You'll learn a lot today.
_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: find_package_version_check

Andreas Schneider
In reply to this post by Eric Noulard
On Thursday 13 August 2009 10:55:30 Eric Noulard wrote:

> 2009/8/13 Andreas Schneider <[hidden email]>:
> > Hi,
> >
> > I had to add a version check to on of my find modules in KDE. So I
> > started and asked myself why do I have to right so much code to get a
> > version check. This should be done by CMake and not by me.
> >
> > So I've created a function find_package_version_check() you can use. All
> > you have to do is to set the version number.
> >
> > Example:
> > find_package(LibSSH 0.3.2 EXACT)
> >
> > # check for the version and set it
> > set(LibSSH_VERSION 0.4.0)
> > find_package_version_check(LibSSH DEFAULT_MSG)
> >
> > Error:
> >  The installed LibSSH version 0.4.0 is too new, version 0.3.2 is
> > required.
> >
> > Comments and improvements are very welcome :)
>
> Two comments:
>
> 1)  You seems to forget to attach you CMake macro/function file for
> "find_package_version_check"?
Sorry, you can find it here:

http://www.cynapses.org/tmp/patches/kde/FindPackageVersionCheck.cmake

>
> 2)  Why is the existing find_package(LibSSH <version> EXACT) not
> sufficient for you?

Well that's what this function supports. You have to write the code to do the
version check or use my function.

Example: http://www.cynapses.org/tmp/patches/kde/FindLibSSH.cmake


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

signature.asc (204 bytes) Download Attachment