Skip to content

Commit f26867d

Browse files
add version to cmake build and add an accessor to get the library's version string.
1 parent 71ed6e7 commit f26867d

File tree

5 files changed

+22
-1
lines changed

5 files changed

+22
-1
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cmake_minimum_required(VERSION 3.16)
2-
project(cpputest-for-qpc-lib)
2+
project(cpputest-for-qpc-lib VERSION 1.0.0)
33
include(FetchContent)
44

55
set(CMAKE_CXX_STANDARD 14)

cpputest-for-qpc-lib/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ include_directories(include)
22
include_directories(${CMS_QPC_SRC_DIR})
33
include_directories(${CMS_CPPUTEST_QP_PORT_TOP_DIR}/include)
44

5+
add_definitions(-DCPPUTEST_FOR_QPC_LIB_VERSION=\"${cpputest-for-qpc-lib_VERSION}\")
6+
57
add_library(cpputest-for-qpc-lib
68
src/cpputest_qf_port.cpp
79
src/cms_cpputest_qf_ctrl.cpp

cpputest-for-qpc-lib/include/cms_cpputest_qf_ctrl.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ void PublishAndProcess(enum_t sig,
9595
void PublishAndProcess(QEvt const * e,
9696
PublishedEventRecorder* recorder = nullptr);
9797

98+
/// Get the internal library version string.
99+
/// Uses semantic versioning.
100+
const char * GetVersion();
101+
98102
} //namespace qf_ctrl
99103
} //namespace test
100104
} //namespace cms

cpputest-for-qpc-lib/src/cms_cpputest_qf_ctrl.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,11 @@ void CreatePoolConfigsFromArg(const MemPoolConfigs& pubSubEventMemPoolConfigs)
189189
}
190190
}
191191

192+
const char * GetVersion()
193+
{
194+
return CPPUTEST_FOR_QPC_LIB_VERSION;
195+
}
196+
192197
} // namespace qf_ctrl
193198
} // namespace test
194199
} // namespace cms

cpputest-for-qpc-lib/tests/cms_cpputest_qf_ctrlTests.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "qpc.h"
2626

2727
#include <chrono>
28+
#include <string>
2829
#include "cms_cpputest_qf_ctrl.hpp"
2930
#include "cmsDummyActiveObject.hpp"
3031
#include "cms_cpputest.hpp"
@@ -146,4 +147,13 @@ TEST(qf_ctrlTests,
146147

147148
CHECK_EQUAL(1, sigOneCount);
148149
CHECK_EQUAL(3, sigTwoCount);
150+
}
151+
152+
TEST(qf_ctrlTests, qf_ctrl_provides_cpputest_for_qpc_lib_version)
153+
{
154+
auto version = qf_ctrl::GetVersion();
155+
CHECK_TRUE(version != nullptr);
156+
157+
std::string version_str(version);
158+
CHECK_FALSE(version_str.empty());
149159
}

0 commit comments

Comments
 (0)