From cba39daa4827667bc0fa18c70c2e27db27ee9d4f Mon Sep 17 00:00:00 2001 From: agouby Date: Fri, 29 Sep 2023 21:34:05 +0200 Subject: [PATCH] Version done --- CMakeLists.txt | 9 +++++++++ cmake/cppcheck.cmake | 4 +++- source/CMakeLists.txt | 2 -- source/pza/core/attribute.hxx | 2 +- source/pza/core/core.cxx | 5 +++++ source/pza/core/core.hxx | 2 ++ source/pza/core/field.hxx | 5 ----- source/pza/devices/bps.cxx | 2 +- source/pza/devices/bps.hxx | 2 +- source/pza/utils/topic.hxx | 2 +- source/pza/version.hxx.in | 5 +---- 11 files changed, 24 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b9c483e..a49f6e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,6 +24,9 @@ if (CMAKE_SYSTEM_NAME MATCHES "Windows") set(CMAKE_CROSSCOMPILING_EMULATOR "wine") endif() +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) +add_library(${LIBRARY_NAME}) + add_subdirectory(source) #add_subdirectory(test) @@ -35,6 +38,7 @@ target_include_directories(${LIBRARY_NAME} PUBLIC ${CMAKE_BINARY_DIR} ) + target_link_libraries(${LIBRARY_NAME} $<$>,$>:PahoMqttCpp::paho-mqttpp3-static> $<$,$>>:PahoMqttCpp::paho-mqttpp3> @@ -43,3 +47,8 @@ target_link_libraries(${LIBRARY_NAME} magic_enum::magic_enum ) + +set_target_properties(${LIBRARY_NAME} PROPERTIES + VERSION ${PROJECT_VERSION} + SOVERSION ${PROJECT_VERSION_MAJOR} +) \ No newline at end of file diff --git a/cmake/cppcheck.cmake b/cmake/cppcheck.cmake index 2061717..3a7f938 100644 --- a/cmake/cppcheck.cmake +++ b/cmake/cppcheck.cmake @@ -3,10 +3,12 @@ find_program(CPPCHECK_EXECUTABLE cppcheck) if(CPPCHECK_EXECUTABLE) # cppcheck igner never used functions add_custom_target(check - ${CPPCHECK_EXECUTABLE} --enable=all --suppress=missingIncludeSystem + ${CPPCHECK_EXECUTABLE} --enable=all --suppress=missingIncludeSystem --suppress=unusedFunction --template "{file}:{line}:{severity}:{id}:{message}" -I ${CMAKE_SOURCE_DIR}/source ${CMAKE_SOURCE_DIR}/source COMMENT "Running Cppcheck static analysis tool" ) +else() + message(WARNING "Cppcheck not found, can't run static analysis") endif() diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index a120ea2..efaa9ca 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -1,5 +1,3 @@ -add_library(${LIBRARY_NAME}) - file(GLOB_RECURSE HEADERS ${CMAKE_SOURCE_DIR}/source/*.hxx) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/pza/version.hxx.in diff --git a/source/pza/core/attribute.hxx b/source/pza/core/attribute.hxx index c3421bc..4dfc2a2 100644 --- a/source/pza/core/attribute.hxx +++ b/source/pza/core/attribute.hxx @@ -16,7 +16,7 @@ namespace pza public: friend class interface; - attribute(const std::string &name); + explicit attribute(const std::string &name); template void add_field(const std::string &name, bool readonly) diff --git a/source/pza/core/core.cxx b/source/pza/core/core.cxx index 676a123..7e50537 100644 --- a/source/pza/core/core.cxx +++ b/source/pza/core/core.cxx @@ -10,4 +10,9 @@ void core::set_log_level(log_level level) core::log_level core::get_log_level(void) { return static_cast(spdlog::get_level()); +} + +std::string core::get_version(void) +{ + return PZACXX_VERSION; } \ No newline at end of file diff --git a/source/pza/core/core.hxx b/source/pza/core/core.hxx index 64c2bc9..1324508 100644 --- a/source/pza/core/core.hxx +++ b/source/pza/core/core.hxx @@ -1,6 +1,7 @@ #pragma once #include +#include namespace pza { @@ -23,5 +24,6 @@ namespace pza static void set_log_level(log_level level); static log_level get_log_level(void); + static std::string get_version(void); }; }; \ No newline at end of file diff --git a/source/pza/core/field.hxx b/source/pza/core/field.hxx index 0b206ba..9e27769 100644 --- a/source/pza/core/field.hxx +++ b/source/pza/core/field.hxx @@ -99,11 +99,6 @@ namespace pza return _json_type; } - const std::type_info &get_type() const - { - return typeid(_type); - } - void _set_value(const _type &value) { _value = value; diff --git a/source/pza/devices/bps.cxx b/source/pza/devices/bps.cxx index c07bb8c..d9494aa 100644 --- a/source/pza/devices/bps.cxx +++ b/source/pza/devices/bps.cxx @@ -10,7 +10,7 @@ bps_channel::bps_channel(device *device, const std::string &base_name) } -bps::bps(const std::string group, const std::string name) +bps::bps(const std::string &group, const std::string &name) : device(group, name) { diff --git a/source/pza/devices/bps.hxx b/source/pza/devices/bps.hxx index 02ed28b..461ad80 100644 --- a/source/pza/devices/bps.hxx +++ b/source/pza/devices/bps.hxx @@ -29,7 +29,7 @@ namespace pza public: using ptr = std::shared_ptr; - bps(const std::string group, const std::string name); + explicit bps(const std::string &group, const std::string &name); const std::string &get_family() override { return _family; }; size_t get_num_channels() { return channel.size(); } diff --git a/source/pza/utils/topic.hxx b/source/pza/utils/topic.hxx index 38429ff..a9735ef 100644 --- a/source/pza/utils/topic.hxx +++ b/source/pza/utils/topic.hxx @@ -9,7 +9,7 @@ namespace pza class topic { public: - topic(const std::string &topic); + explicit topic(const std::string &topic); bool is_valid() const { return _is_valid; } diff --git a/source/pza/version.hxx.in b/source/pza/version.hxx.in index 28ce604..c0a3695 100644 --- a/source/pza/version.hxx.in +++ b/source/pza/version.hxx.in @@ -1,6 +1,3 @@ #pragma once -#define PZACXX_VERSION_MAJOR @PZACXX_VERSION_MAJOR@ -#define PZACXX_VERSION_MINOR @PZACXX_VERSION_MINOR@ -#define PZACXX_VERSION_PATCH @PZACXX_VERSION_PATCH@ -#define PZACXX_VERSION @PZACXX_VERSION \ No newline at end of file +#define PZACXX_VERSION "@PROJECT_VERSION@" \ No newline at end of file