[odb-users] Includes and CMake out-of-source builds

Per Edin info at peredin.com
Mon Aug 26 08:05:59 EDT 2013


Hi,

When using CMake to manage the build process it is recommended not to
create any build-related files in the source tree of a project. This
includes generated source files such as Qt's MOC-files and ODB
generated source files and headers.

Instead, all generated files should be placed in the build tree.

With ODB 2.2.1 this is not easily accomplished, because of output
directory and include problems.

1. Automatic sub-directory creation

Currently, all generated files are placed in the directory specified
with --output-dir. This causes some problems when subdirectories are
involved.

Given the input header files:

    /code/project/db/employee.hxx
    /code/project/db/specials/janitor.hxx

ODB should find and strip the common base directory from the input
files, which is

    /code/project/db

and create the following output files, in the --output-dir

    employee-odb.*
    specials/janitor-odb.*

2. Includes

Given the input header person.hxx the generated person-odb.cxx file
should include the full-path to person.hxx and not just "person.hxx".

It is possible to fix this by using --include-prefix, but that only
works if all input .hxx files are in the same directory.

Given the input header files:

    /code/project/employee.hxx
    /code/project/specials/janitor.hxx

and the ODB output directory

    /code/project/build/db

the #include's should be

    "/code/project/employee.hxx"
    "/code/project/specials/janitor.hxx"

A more clean solution would be to find the common base directory for
all input headers and the output directory and use relative paths in
the #includes:

    "../../employee.hxx"
    "../../specials/janitor.hxx"

What do you think about this? Is this something that's already planned
for some future version of ODB?

Kind regards,
Per Edin



More information about the odb-users mailing list