Skip to content

Commit

Permalink
Merge pull request #280 from mtconnect/public_master
Browse files Browse the repository at this point in the history
  • Loading branch information
wsobel authored Mar 8, 2023
2 parents 56b69a3 + 157ed18 commit 24e93ce
Show file tree
Hide file tree
Showing 307 changed files with 154,121 additions and 5,677 deletions.
34 changes: 23 additions & 11 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 1)
set(AGENT_VERSION_PATCH 0)
set(AGENT_VERSION_BUILD 2)
set(AGENT_VERSION_BUILD 5)
set(AGENT_VERSION_RC "")

# This minimum version is to support Visual Studio 2017 and C++ feature checking and FetchContent
Expand All @@ -15,6 +15,7 @@ if(POLICY CMP0077)
endif()

option(AGENT_ENABLE_UNITTESTS "Enables the agent's unit tests" ON)
option(SHARED_AGENT_LIB "Generate shared agent library. Conan options: shared" OFF)
set(INSTALL_GTEST OFF FORCE)

project(cppagent LANGUAGES C CXX)
Expand All @@ -25,8 +26,8 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CXX_COMPILE_FEATURES cxx_std_17)

set(WITH_PYTHON OFF CACHE STRING "With Python Support")
set(WITH_RUBY OFF CACHE STRING "With Ruby Support")

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

# By default only generate 2 configurations (Debug and Release) for simplicity.
# The user can change this option if required for the additional ones such as 'RelWithDebInfo'.
Expand Down Expand Up @@ -64,7 +65,11 @@ if(MSVC)
endif()

if (UNIX)
add_compile_options(-fPIC -Wno-psabi -fvisibility-inlines-hidden -fvisibility=hidden)
if (SHARED_AGENT_LIB)
add_compile_options(-fPIC -Wno-psabi -fvisibility-inlines-hidden)
else()
add_compile_options(-fPIC -Wno-psabi -fvisibility-inlines-hidden -fvisibility=hidden)
endif()
ENDIF()

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
Expand All @@ -73,17 +78,24 @@ if (CONAN_USER_MRUBY_mruby)
set(WITH_RUBY ON FORCE)
endif()

conan_basic_setup(TARGETS)
conan_basic_setup(KEEP_RPATHS TARGETS)

if(SHARED_AGENT_LIB)
set(CMAKE_BUILD_RPATH "@load_path/;@executable_path/;@load_path/../lib;@executable_path/../lib")

if(WITH_PYTHON)
set(Python_USE_STATIC_LIBS ON)
if (MSVC)
include(InstallRequiredSystemLibraries)
endif()
endif()

find_package(Python3 COMPONENTS Interpreter Development Development.Embed)
message("Include dirs of Python: " ${Python3_INCLUDE_DIRS} )
message("Libs of Python: " ${Python3_LIBRARIES} )
if (MSVC)
if (CONAN_SETTINGS_COMPILER_RUNTIME MATCHES "MT")
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
else()
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
endif()
endif()

include(cmake/msvc_use_static_runtime.cmake)
include(cmake/osx_no_app_or_frameworks.cmake)
include(cmake/ClangFormat.cmake)
include(cmake/ClangTidy.cmake)
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ RUN apt-get clean \
&& apt-get update \
&& apt-get install -y \
build-essential python3.9 python3-pip git cmake make ruby rake \
&& pip install conan
&& pip install conan -v "conan==1.59.0"

# make an agent directory and cd into it
WORKDIR /root/agent
Expand Down
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ protocol and data collection framework that will work as a standalone
server. Once built, you only need to specify the XML description of
the devices and the location of the adapter.

**NOTE: This version cannot currently be built on Windows XP since there is currently no support for the XP toolchain and C++ 17.**

Pre-built binary releases for Windows are available from [Releases](https://github.com/mtconnect/cppagent/releases) for those who do not want to build the agent themselves. For *NIX users, you will need libxml2, cppunit, and cmake as well as build essentials.

Version 2.1.0 Added MQTT Sink, Agent Restart and new JSON format (version 2)
Expand Down Expand Up @@ -769,7 +771,6 @@ The following parameters must be present to enable https requests. If there is n
not found the default device if only one device is specified
in the devices file.


* `Host` - The host the adapter is located on.

*Default*: localhost
Expand Down Expand Up @@ -849,12 +850,16 @@ The following parameters must be present to enable https requests. If there is n

*Default*: Top Level Setting

* `ShdrVersion` - Specifies the SHDR protocol version used by the adapter. When greater than one (1), allows multiple complex observations, like `Condition` and `Message` on the same line. If it equials one (1), then any observation requiring more than a key/value pair need to be on separate lines. Applies to only this adapter.
* `ShdrVersion` - Specifies the SHDR protocol version used by the adapter. When greater than one
(1), allows multiple complex observations, like `Condition` and `Message` on the same line.
If it equials one (1), then any observation requiring more than a key/value pair need to be on
separate lines. Applies to only this adapter.

*Default*: 1

* `SuppressIPAddress` - Suppress the Adapter IP Address and port when creating the Agent Device ids and names.
*Default*: false
* `SuppressIPAddress` - Suppress the Adapter IP Address and port when creating the Agent Device ids and names.
*Default*: false


### Agent Adapter Configuration
Expand Down
16 changes: 11 additions & 5 deletions agent/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@ if(WIN32)
# Version info
string(TIMESTAMP AGENT_VERSION_TIME "%Y-%m-%dT%H:%M:%SZ" UTC)
set(RESOURCE_FILE "${PROJECT_BINARY_DIR}/agent/version.rc")
configure_file("${CMAKE_CURRENT_LIST_DIR}/../src/version.rc.in" "${RESOURCE_FILE}")
configure_file("${CMAKE_CURRENT_LIST_DIR}/../src/mtconnect/version.rc.in" "${RESOURCE_FILE}")
list(APPEND AGENT_SOURCES "${RESOURCE_FILE}")
endif()

add_executable(agent ${AGENT_SOURCES})

set_property(TARGET agent PROPERTY
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")

if(WITH_PYTHON)
target_compile_definitions(
agent
Expand All @@ -36,11 +33,20 @@ endif()

target_link_libraries(
agent
PRIVATE
PUBLIC
agent_lib
$<$<PLATFORM_ID:Windows>:shlwapi>
)

target_clangtidy_setup(agent_lib)

install(TARGETS agent RUNTIME DESTINATION bin)


if(SHARED_AGENT_LIB AND MSVC)
set(CMAKE_INSTALL_DEBUG_LIBRARIES ON)
include(InstallRequiredSystemLibraries)
install(FILES ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} DESTINATION bin COMPONENT Libraries)
install(DIRECTORY "${PROJECT_BINARY_DIR}/bin/" DESTINATION bin COMPONENT Libraries
FILES_MATCHING PATTERN "*.dll")
endif()
8 changes: 4 additions & 4 deletions agent/cppagent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
//

#include <boost/asio.hpp>
#include "agent.hpp"
#include "configuration/agent_config.hpp"
#include "mtconnect/agent.hpp"
#include "mtconnect/configuration/agent_config.hpp"

#include "fcntl.h"
#include "sys/stat.h"
#include <fcntl.h>
#include <sys/stat.h>

#include <cstring>

Expand Down
Loading

0 comments on commit 24e93ce

Please sign in to comment.