Skip to content

configuration header #313

@cbeck88

Description

@cbeck88

Currently, when we install the tz library using cmake, we select a bunch of configuration options, for example:

cmake -DENABLE_DATE_TESTING=NO \
             -DUSE_SYSTEM_TZ_DB=YES \
             -DTZ_CXX_STANDARD=14 \
             -DBUILD_TZ_STATIC=YES \
             -DCMAKE_CXX_FLAGS=-fPIC \
             -DCMAKE_INSTALL_PREFIX=/usr \
             .. \

However, we can't then directly use the headers as is, we also have to add a bunch of defines to the build system, per installation instructions here: https://howardhinnant.github.io/date/tz.html#Installation

So we end up writing our own configuration header like so:

#pragma once

#define USE_OS_TZDB 1

#include "date/date.h"
#include "date/tz.h"

and we tell developers that it is a bug if they include date/tz.h directly in their code and not using our in-tree configuration header.

This also means that the configuration header in-tree needs to be kept in sync with the code that is invoking cmake.

It would be nicer if, for example, the date library cmake would write its own configuration header, e.g. install tz_config.h alongside tz.h. And tz.h would itself include this header, which would contain the defines that we selected at installation time. This is the pattern followed by other common open source libraries like libpng and freetype. And it avoids the possibility of ODR violations and crashes if the installation options and the options in my hand-written header above get out of sync.

Would you guys be interested in a Pull Request that introduces such a configuration header into your cmake?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions