Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgraded C++ Version to 20 and Visual Studio to 2022 #490

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ on:

jobs:
build_windows:
runs-on: windows-2019
name: "Windows 2019 Arch: ${{ matrix.arch }}, Shared: ${{ matrix.shared }}"
runs-on: windows-2022
name: "Windows 2022 Arch: ${{ matrix.arch }}, Shared: ${{ matrix.shared }}"
strategy:
matrix:
arch: ["x86", "amd64"]
Expand Down
7 changes: 4 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set(AGENT_VERSION_MAJOR 2)
set(AGENT_VERSION_MINOR 4)
set(AGENT_VERSION_PATCH 0)
set(AGENT_VERSION_BUILD 2)
set(AGENT_VERSION_BUILD 3)
set(AGENT_VERSION_RC "")

# This minimum version is to support Visual Studio 2019 and C++ feature checking and FetchContent
Expand All @@ -21,14 +21,15 @@ set(AGENT_PREFIX "" CACHE STRING "Prefix for the name of the agent and the agent
set(CMAKE_INSTALL_DATADIR "${CMAKE_INSTALL_DATADIR}/mtconnect")

message(INFO " Shared build: ${SHARED_AGENT_LIB}")
set(CMAKE_OSX_DEPLOYMENT_TARGET 13.3)

project(cppagent LANGUAGES C CXX)

# We will define these properties by default for each CMake target to be created.
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CXX_COMPILE_FEATURES cxx_std_17)
set(CXX_COMPILE_FEATURES cxx_std_20)

set(WITH_RUBY ON CACHE STRING "With Ruby Support")

Expand Down
1 change: 1 addition & 0 deletions conan/profiles/clang
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ include(default)

[settings]
compiler.libcxx=libstdc++11
compiler.cppstd=20

[env]
CC=/usr/bin/clang
Expand Down
1 change: 1 addition & 0 deletions conan/profiles/docker
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ include(default)

[settings]
compiler.libcxx=libstdc++11
compiler.cppstd=20

[options]
without_ipv6=True
Expand Down
1 change: 1 addition & 0 deletions conan/profiles/gcc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ include(default)

[settings]
compiler.libcxx=libstdc++11
compiler.cppstd=20

[system_tools]
cmake/>3.23.0
1 change: 1 addition & 0 deletions conan/profiles/gcc-appveyor
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ include(default)
[settings]
compiler.libcxx=libstdc++11
compiler.version=11
compiler.cppstd=20

3 changes: 2 additions & 1 deletion conan/profiles/macos
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ include(default)

[settings]
compiler=apple-clang
compiler.cppstd=gnu17
compiler.cppstd=20
os.version=13.3

[system_tools]
cmake/>3.26.0
3 changes: 2 additions & 1 deletion conan/profiles/vs32
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ include(default)

[settings]
compiler=msvc
compiler.cppstd=17
compiler.cppstd=20
arch=x86
compiler.runtime=static
compiler.runtime_type=Release
build_type=Release
compiler.version=194


3 changes: 2 additions & 1 deletion conan/profiles/vs32debug
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ include(default)

[settings]
compiler=msvc
compiler.cppstd=17
compiler.cppstd=20
arch=x86
compiler.runtime=static
compiler.runtime_type=Debug
build_type=Debug
compiler.version=194

3 changes: 2 additions & 1 deletion conan/profiles/vs32shared
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ include(default)

[settings]
compiler=msvc
compiler.cppstd=17
compiler.cppstd=20
arch=x86
compiler.runtime=dynamic
compiler.runtime_type=Release
build_type=Release
compiler.version=194


[options]
Expand Down
3 changes: 2 additions & 1 deletion conan/profiles/vs64
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ include(default)

[settings]
compiler=msvc
compiler.cppstd=17
compiler.cppstd=20
arch=x86_64
compiler.runtime=static
compiler.runtime_type=Release
build_type=Release
compiler.version=194
4 changes: 3 additions & 1 deletion conan/profiles/vs64debug
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ include(default)

[settings]
compiler=msvc
compiler.cppstd=17
compiler.cppstd=20
arch=x86_64
compiler.runtime=static
compiler.runtime_type=Debug
build_type=Debug
compiler.version=194

3 changes: 2 additions & 1 deletion conan/profiles/vs64shared
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ include(default)

[settings]
compiler=msvc
compiler.cppstd=17
compiler.cppstd=20
arch=x86_64
compiler.runtime=dynamic
compiler.runtime_type=Release
build_type=Release
compiler.version=194

[options]
shared=True
Expand Down
3 changes: 2 additions & 1 deletion conan/profiles/vsxp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ include(default)
[settings]
compiler=msvc
arch=x86
compiler.cppstd=17
compiler.cppstd=20
compiler.runtime=static
compiler.runtime_type=Release
build_type=Release
compiler.toolset=v141_xp
compiler.version=194

[options]
winver=0x0501
Expand Down
3 changes: 2 additions & 1 deletion conan/profiles/xcode
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
include(default)

[settings]
compiler.cppstd=17
compiler.cppstd=20
os.version=13.3

[system_tools]
cmake/>3.23.0
Expand Down
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def requirements(self):
if self.options.with_ruby:
self.requires("mruby/3.2.0", headers=True, libs=True, transitive_headers=True, transitive_libs=True)

self.requires("gtest/1.10.0", headers=True, libs=True, transitive_headers=True, transitive_libs=True, test=True)
self.requires("gtest/1.15.0", headers=True, libs=True, transitive_headers=True, transitive_libs=True, test=True)

def configure(self):
if self.options.shared:
Expand Down
4 changes: 2 additions & 2 deletions src/mtconnect/agent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ namespace mtconnect {
return;
}

auto callback = [=](config::AsyncContext &context) {
auto callback = [=, this](config::AsyncContext &context) {
try
{
bool changed = false;
Expand Down Expand Up @@ -573,7 +573,7 @@ namespace mtconnect {
createUniqueIds(device);

LOG(info) << "Checking if device " << *uuid << " has changed";
if (*device != *oldDev)
if (!device->equal(*oldDev))
{
LOG(info) << "Device " << *uuid << " changed, updating model";

Expand Down
4 changes: 2 additions & 2 deletions src/mtconnect/buffer/circular_buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,8 @@ namespace mtconnect::buffer {
mutable std::recursive_mutex m_sequenceLock;

// Sequence number
volatile SequenceNumber_t m_sequence;
volatile SequenceNumber_t m_firstSequence;
SequenceNumber_t m_sequence;
SequenceNumber_t m_firstSequence;

// The sliding/circular buffer to hold all of the events/sample data
unsigned int m_slidingBufferSize;
Expand Down
12 changes: 4 additions & 8 deletions src/mtconnect/entity/data_set.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,9 @@

#pragma once

#include <cmath>
#include <regex>
#include <set>
#include <boost/container/set.hpp>
#include <string>
#include <utility>
#include <variant>
#include <vector>

#include "mtconnect/config.hpp"
#include "mtconnect/logging.hpp"
Expand All @@ -33,10 +29,10 @@ namespace mtconnect::entity {
struct DataSetEntry;

/// @brief A set of data set entries
class AGENT_LIB_API DataSet : public std::set<DataSetEntry>
class DataSet : public boost::container::set<DataSetEntry>
{
public:
using base = std::set<DataSetEntry>;
using base = boost::container::set<DataSetEntry>;
using base::base;

/// @brief Get a entry for a key
Expand All @@ -55,7 +51,7 @@ namespace mtconnect::entity {

/// @brief Split the data set entries by space delimiters and account for the
/// use of single and double quotes as well as curly braces
bool parse(const std::string &s, bool table);
bool AGENT_LIB_API parse(const std::string &s, bool table);
};

/// @brief Data Set Value type enumeration
Expand Down
19 changes: 12 additions & 7 deletions src/mtconnect/entity/entity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,16 +352,21 @@ namespace mtconnect {
/// @brief get the attributes for XML generation
/// @return attribute set
const auto &getAttributes() const { return m_attributes; }

/// @brief compare two entities for equality
/// @param other the other entity
/// @return `true` if they have equal name and properties
bool operator==(const Entity &other) const;
bool equal(const Entity &other) const;

/// @brief cover method for equal
/// @param other the other entity
/// @return `true` if they have equal name and properties
bool operator==(const Entity &other) const { return equal(other); }

/// @brief compare two entities for inequality
/// @param other the other entity
/// @return `true` if they have unequal name and properties
bool operator!=(const Entity &other) const { return !(*this == other); }
bool operator!=(const Entity &other) const { return !equal(other); }

/// @brief update this entity to be the same as other
/// @param other the other entity
Expand Down Expand Up @@ -446,7 +451,7 @@ namespace mtconnect {

bool operator()(const EntityPtr &other)
{
return *std::get<EntityPtr>(m_this) == *(other.get());
return std::get<EntityPtr>(m_this)->equal(*(other.get()));
}

bool operator()(const EntityList &other)
Expand All @@ -463,15 +468,15 @@ namespace mtconnect {
auto id = (*it)->getIdentity();
auto oit =
boost::find_if(other, [&id](const auto &e) { return id == e->getIdentity(); });
if (oit == other.end() || *(it->get()) != *(oit->get()))
if (oit == other.end() || !(it->get())->equal(*(oit->get())))
return false;
}
}
else
{
for (auto oit = other.cbegin(); it != list.cend(); it++, oit++)
{
if (*(it->get()) != *(oit->get()))
if (!(it->get())->equal(*(oit->get())))
return false;
}
}
Expand Down Expand Up @@ -499,7 +504,7 @@ namespace mtconnect {

inline bool operator!=(const Value &v1, const Value &v2) { return !(v1 == v2); }

inline bool Entity::operator==(const Entity &other) const
inline bool Entity::equal(const Entity &other) const
{
if (m_name != other.m_name)
return false;
Expand Down
Loading