[odb-users] CMake FindModule for ODB

Timo Rothenpieler timo at rothenpieler.org
Thu Aug 28 12:29:59 EDT 2014


Hello,

I was in need of a CMake module for ODB, but didn't find the existing
ones sufficient, as they completely lack any functionality to locate the
odb libraries and headers.
So i wrote one, loosely based on the existing one from the wiki.

As this might be usefull for other people, i uploaded it, together with
an example, to my Github:

https://github.com/BtbN/OdbCmake

A short documentation on the variables the find module defines is in the
header of the Find module:

https://github.com/BtbN/OdbCmake/blob/master/cmake/Modules/FindODB.cmake

To use it, all that needs to be done is:

find_package(ODB REQUIRED
    COMPONENTS qt
    OPTIONAL_COMPONENTS mysql sqlite)
include(${ODB_USE_FILE})

After that it sets OSB_QT_FOUND, ODB_MYSQL_FOUND and ODB_SQLITE_FOUND to
true, if it found the said components.
ODB_LIBRARIES contains all neccessary libs for the requested and found
components, ODB_INCLUDE_DIRS the include directories.
Those are also defined for each requested component and for the libodb
core library in individual variables.

The UseODB file defines the odb_compile function, which takes headers as
input and calls the odb cli util on them to create the odb code.
It appends the list of generated sources that need compiling to the
variable it got as its fist argument.

See the example CMakeLists.txt for an example on how to use it:

https://github.com/BtbN/OdbCmake/blob/master/CMakeLists.txt


Regards,
Timo

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
Url : http://codesynthesis.com/pipermail/odb-users/attachments/20140828/8cc998cc/signature.pgp


More information about the odb-users mailing list