File: DependencyVersions.cpp

package info (click to toggle)
freeorion 0.5.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 194,940 kB
  • sloc: cpp: 186,508; python: 40,969; ansic: 1,164; xml: 719; makefile: 32; sh: 7
file content (90 lines) | stat: -rw-r--r-- 2,372 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include "Version.h"

#include "Logger.h"

#include <sstream>

#include <zlib.h>
#include <boost/version.hpp>

#include <patchlevel.h>

#if defined(FREEORION_BUILD_HUMAN)
#   include <SDL2/SDL_version.h>
#   include <png.h>
#   include <ft2build.h>
#   include FT_FREETYPE_H
#   include <vorbis/codec.h>
#   include <GL/glew.h>
#endif


/** @file
 * @brief  Implement free functions to access the dependency versions.
 */

namespace {
#if defined(FREEORION_BUILD_HUMAN)
    std::string SDLVersionString() {
        std::stringstream ss;
        SDL_version version;

        SDL_GetVersion(&version);
        ss << static_cast<int>(version.major) << "."
           << static_cast<int>(version.minor) << "."
           << static_cast<int>(version.patch);
        return ss.str();
    }

    std::string FreeTypeVersionString() {
        std::stringstream ss;
        ss << FREETYPE_MAJOR << "." << FREETYPE_MINOR << "." << FREETYPE_PATCH;
        return ss.str();
    }

    // Ogg does not supply a version string in the header or from a function as far as I can tell
    //std::string OggVersionString()
    //{ return ""; }

    std::string VorbisVersionString() {
        const char* retval = vorbis_version_string();
        return retval;
    }

    std::string PNGVersionString()
    { return PNG_LIBPNG_VER_STRING; }

    std::string GLEWVersionString() {
        const GLubyte* retval = glewGetString(GLEW_VERSION);
        std::stringstream ss;
        ss << retval;
        return ss.str();
    }
#endif
}

std::map<std::string, std::string> DependencyVersions() {
    std::map<std::string, std::string> retval;
    // fill with all findable version strings...
    retval["zlib"] =        ZLIB_VERSION;
    retval["Boost"] =       BOOST_LIB_VERSION;
    retval["Python"] =      PY_VERSION;

#if defined(FREEORION_BUILD_HUMAN)
    retval["SDL"] =         SDLVersionString();
    retval["FreeType"] =    FreeTypeVersionString();
    retval["PNG"] =         PNGVersionString();
    retval["libvorbis"] =   VorbisVersionString();
    retval["GLEW"] =        GLEWVersionString();
#endif

    return retval;
}

void LogDependencyVersions() {
    InfoLogger() << "Dependency versions from headers:";
    for (const auto& version : DependencyVersions()) {
        if (!version.second.empty())
            InfoLogger() << version.first << ": " << version.second;
    }
}