Skip to content

Commit 9556cff

Browse files
print version info
1 parent b725047 commit 9556cff

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.13.4 FATAL_ERROR)
44
# ======================================================================================================================
55

66
# project
7-
project(write_shm LANGUAGES CXX VERSION 0.0.1)
7+
project(write_shm LANGUAGES CXX VERSION 0.1.0)
88

99
# settings
1010
set(Target "write_shm") # Executable name (without file extension!)
@@ -55,6 +55,10 @@ set_target_properties(${Target} PROPERTIES
5555
CXX_EXTENSIONS ${COMPILER_EXTENSIONS}
5656
)
5757

58+
# project version and name
59+
target_compile_definitions(${Target} PUBLIC "PROJECT_VERSION=\"${CMAKE_PROJECT_VERSION}\"")
60+
target_compile_definitions(${Target} PUBLIC "PROJECT_NAME=\"${CMAKE_PROJECT_NAME}\"")
61+
5862
# options that are valid for gcc and clang
5963
function(commonopts)
6064
# more debugging information

src/SHM.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class SHM {
88
std::string name;
99
int fd = -1;
1010
std::size_t size = 0;
11-
void * addr = nullptr;
11+
void *addr = nullptr;
1212

1313
public:
1414
explicit SHM(std::string name);

src/main.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ int main(int argc, char **argv) {
2424
"output everything that is written to the shared memory to stdout",
2525
cxxopts::value<bool>()->default_value("false"));
2626
options.add_options()("h,help", "print usage");
27+
options.add_options()("version", "print version information");
2728

2829
// parse arguments
2930
cxxopts::ParseResult args;
@@ -68,6 +69,11 @@ int main(int argc, char **argv) {
6869
exit(EX_OK);
6970
}
7071

72+
// print version
73+
if (args.count("version")) {
74+
std::cout << PROJECT_NAME << ' ' << PROJECT_VERSION << std::endl;
75+
exit(EX_OK);
76+
}
7177

7278
// open shm
7379
std::unique_ptr<SHM> shm;

0 commit comments

Comments
 (0)