Added version.h that is prepopulated by cmake.
This commit is contained in:
parent
97d56c3f36
commit
cdc906085a
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
||||
build/
|
||||
include/yaml-cpp/version.h
|
||||
|
||||
@ -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
|
||||
|
||||
17
include/yaml-cpp/version.h.in
Normal file
17
include/yaml-cpp/version.h.in
Normal 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
27
test/version_test.cpp
Normal 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");
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user