Skip to content
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
11 changes: 5 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# The version number.
set(AGENT_VERSION_MAJOR 2)
set(AGENT_VERSION_MINOR 8)
set(AGENT_VERSION_PATCH 0)
set(AGENT_VERSION_BUILD 4)
set(AGENT_VERSION_RC "")
include(cmake/get_version_number.cmake)


# This minimum version is to support Visual Studio 2019 and C++ feature checking and FetchContent
cmake_minimum_required(VERSION 3.23 FATAL_ERROR)
Expand All @@ -28,7 +25,9 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CXX_COMPILE_FEATURES cxx_std_20)

project(cppagent LANGUAGES C CXX)
project(cppagent
VERSION ${AGENT_VERSION_MAJOR}.${AGENT_VERSION_MINOR}.${AGENT_VERSION_PATCH}.${AGENT_VERSION_BUILD}
LANGUAGES C CXX)

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

Expand Down
1 change: 1 addition & 0 deletions agent_version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.8.0.5
22 changes: 22 additions & 0 deletions cmake/get_version_number.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
set(AGENT_VERSION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/agent_version.txt")

# Read the first line and trim whitespace / stray \r from CRLF files
file(STRINGS "${AGENT_VERSION_FILE}" _agent_version_line LIMIT_COUNT 1)
string(STRIP "${_agent_version_line}" _agent_version_line)

# MAJOR.MINOR.PATCH.BUILD with an optional RC suffix: 2.8.0.4, 2.8.0.4-RC1, 2.8.0.4_RC1, 2.8.0.4RC1
if(NOT _agent_version_line MATCHES
"^([0-9]+)\\.([0-9]+)\\.([0-9]+)\\.([0-9]+)([-_]?(RC[0-9]+))?$")
message(FATAL_ERROR
"Invalid version '${_agent_version_line}' in ${AGENT_VERSION_FILE}; "
"expected MAJOR.MINOR.PATCH.BUILD[-RCn]")
endif()

set(AGENT_VERSION_MAJOR ${CMAKE_MATCH_1})
set(AGENT_VERSION_MINOR ${CMAKE_MATCH_2})
set(AGENT_VERSION_PATCH ${CMAKE_MATCH_3})
set(AGENT_VERSION_BUILD ${CMAKE_MATCH_4})
set(AGENT_VERSION_RC "${CMAKE_MATCH_6}") # "" when there's no RC

# Re-run configure automatically when the version file changes
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${AGENT_VERSION_FILE}")
11 changes: 7 additions & 4 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
from conan import ConanFile
from conan.tools.microsoft import is_msvc, is_msvc_static_runtime
from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout
from conan.tools.files import copy
from conan.tools.files import copy, load

import os
import io
import re

class MTConnectAgentConan(ConanFile):
name = "mtconnect_agent"
version = "2.7"
url = "https://github.com/mtconnect/cppagent.git"
license = "Apache License 2.0"
settings = "os", "compiler", "arch", "build_type"
Expand All @@ -27,7 +26,6 @@ class MTConnectAgentConan(ConanFile):
"cpack_name": [None, "ANY"],
"cpack_generator": [None, "ANY"]
}

description = "MTConnect reference C++ agent copyright Association for Manufacturing Technology"

build_policy = "missing"
Expand Down Expand Up @@ -74,7 +72,7 @@ class MTConnectAgentConan(ConanFile):
}

exports_sources = "*", "!build", "!test_package/build", "!*~"
exports = "conan/mqtt_cpp/*", "conan/mruby/*", "conan/oniguruma/*"
exports = "conan/mqtt_cpp/*", "conan/mruby/*", "conan/oniguruma/*", "agent_version.txt"

def validate(self):
if is_msvc(self) and self.options.shared and self.settings.compiler.runtime != 'dynamic':
Expand All @@ -90,6 +88,11 @@ def config_options(self):
if is_msvc(self):
self.options.rm_safe("fPIC")

def set_version(self):
if not self.version:
self.version = load(self, os.path.join(self.recipe_folder, "agent_version.txt")).splitlines()[0].strip()
print(f"Building MTConnect Version {self.version}")

def tool_requires_version(self, package, version):
self.output.info(f"Checking version of {package} > {version}")
buf = io.StringIO()
Expand Down
Loading