Added version.h that is prepopulated by cmake.

This commit is contained in:
Sam Kellett 2015-12-30 19:01:37 +00:00
parent 97d56c3f36
commit cdc906085a
4 changed files with 47 additions and 0 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
build/
include/yaml-cpp/version.h

View File

@ -116,6 +116,8 @@ include_directories(${YAML_CPP_SOURCE_DIR}/include)
find_package(Boost REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
# Create version.h
configure_file(${header_directory}/version.h.in ${CMAKE_SOURCE_DIR}/${header_directory}/version.h)
###
### General compilation settings

View File

@ -0,0 +1,17 @@
#ifndef YAML_CPP_VERSION_H
#define YAML_CPP_VERSION_H
#if defined(_MSC_VER) || \
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
#pragma once
#endif
#define YAML_CPP_VERSION_MAJOR ${YAML_CPP_VERSION_MAJOR}
#define YAML_CPP_VERSION_MINOR ${YAML_CPP_VERSION_MINOR}
#define YAML_CPP_VERSION_PATCH ${YAML_CPP_VERSION_PATCH}
// String representation of the current version (ie. "0.1.2")
#define YAML_CPP_VERSION "${YAML_CPP_VERSION}"
#endif // YAML_CPP_VERSION_H

27
test/version_test.cpp Normal file
View File

@ -0,0 +1,27 @@
#include "yaml-cpp/version.h"
#include "gtest/gtest.h"
namespace YAML {
namespace {
TEST(VersionTest, Major)
{
ASSERT_EQ(YAML_CPP_VERSION_MAJOR, 0);
}
TEST(VersionTest, Minor)
{
ASSERT_EQ(YAML_CPP_VERSION_MINOR, 5);
}
TEST(VersionTest, Path)
{
ASSERT_EQ(YAML_CPP_VERSION_PATCH, 2);
}
TEST(VersionTest, String)
{
ASSERT_STREQ(YAML_CPP_VERSION, "0.5.2");
}
}
}