This project contains the MASD C++ Reference Implementation, generated using Dogen v1.0.08. The objective of a MASD reference implementation is to exercise all of the available functionality within Dogen and to unit test it to ensure it works as specified. The models used to generate the reference implementation are available under projects/models. As the objective of the reference implementation is to exercise Dogen as much as possible, the models are available in both Dia and JSON formats.
In order to build the C++ Reference Implementation you will need a C++ toolchain. On Linux and OSX, you'll need a moderately recent compiler - such as GCC 6 or Clang 3.7 - and Ninja or GNU Make. On Windows you'll need Visual Studio 2015 or later. Note though that we try to always use the most recent releases with Dogen so, if you can, stick to those.
Dogen has the following additional dependencies, across all operative systems:
| Name | Type | Version | Description |
|---|---|---|---|
| CMake | Mandatory | 3.3 or later. | Required to generate the build files. |
| Boost | Mandatory | 1.61 or later. | Earlier versions may also work, but patches are required. Very Important: We link statically against Boost at present, so be sure to build and install the static libraries. |
| LibXml2 | Mandatory | 2.9.4 | Earlier versions may work but haven't been tested. |
| ODB | Optional | 2.4.0 | Required to build the ORM model. |
| Doxygen | Optional | Any recent | Required to build the source code documentation. |
Though the C++ Reference Implementation should build fine with package manager supplied libraries - or even with hand-built dependencies - the easiest way to setup a development environment on all supported platforms is by using vcpkg. Compile it as per vcpkg documentation, then run:
./vcpkg install libxml2 boost-system boost-serialization boost-date-time boost-log boost-filesystem boost-program-options boost-test libodb libodb-pgsql
Warning: the default vcpkg triplet on windows is
32-bit. Also, note
that you can skip the ODB libs (e.g. libodb libodb-pgsql) if you
are not targeting ORM support. Once you have all dependencies set up,
you can then clone the repository and create the build directory:
git clone https://github.com/MASD-Project/cpp_ref_impl.git
cd cpp_ref_impl/build
mkdir output
cd output
On Linux and OSX, you can build using GNU Make as follows:
cmake -DCMAKE_TOOLCHAIN_FILE=${PATH_TO_VCPKG_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake ../..
make -j${CORES}
Where PATH_TO_VCPKG_DIR is the directory in which you've
downloaded and built vcpkg and CORES is the number of cores
available on your machine. Alternatively, you can use Ninja:
cmake -DCMAKE_TOOLCHAIN_FILE=${PATH_TO_VCPKG_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake ../.. -G Ninja
ninja -j${CORES}
On Windows, the incantation is slightly different:
cmake -DCMAKE_TOOLCHAIN_FILE=${PATH_TO_VCPKG_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake ../.. -DCMAKE_BUILD_TYPE=Release -G 'Visual Studio 14 2015 Win64'
cmake --build . --config Release --target ALL_BUILD
If you are not using vcpkg, you can omit
-DCMAKE_TOOLCHAIN_FILE. However if the dependencies are not on
the standard paths, you must not forget to set
CMAKE_INCLUDE_PATH and CMAKE_LIBRARY_PATH accordingly:
CMAKE_INCLUDE_PATH=/my/include/path CMAKE_LIBRARY_PATH=/my/lib/path cmake ../..
If you'd like to run the project tests, execute the target
run_all_tests or its abbreviation rat.
If you'd like to run Dogen to regenerate all models, you can do so by
using the target knit_all or its abbreviation ka. This is
useful, for example, to update the Reference Implementation to the
latest version of Dogen, or just to see how Dogen works. However, note
that Dogen must be on the path for the target to become available. If you
installed Dogen via a package, it's probably already in the right
location. If not, you need to tell CMake of its location by setting
CMAKE_PROGRAM_PATH:
CMAKE_PROGRAM_PATH=/path/to/dogen/binary cmake ../..
After regeneration, you can then use git diff to inspect the
differences produced by regeneration, if any. The build directory
contains all of the logs, under the directory log.
If you have found any issues with the generated C++ code, we ask you to please report it in order to make the code generator better. Examples of issues with the generated code:
- it may be using non-idiomatic C++, or following old idioms;
- it may work, but you know of a better way of doing it;
- it is just wrong, and we've missed it.
Issues can be submitted using github Issues.