File tree Expand file tree Collapse file tree 3 files changed +12
-2
lines changed Expand file tree Collapse file tree 3 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.13.4 FATAL_ERROR)
4
4
# ======================================================================================================================
5
5
6
6
# project
7
- project (write_shm LANGUAGES CXX VERSION 0.0.1 )
7
+ project (write_shm LANGUAGES CXX VERSION 0.1.0 )
8
8
9
9
# settings
10
10
set (Target "write_shm" ) # Executable name (without file extension!)
@@ -55,6 +55,10 @@ set_target_properties(${Target} PROPERTIES
55
55
CXX_EXTENSIONS ${COMPILER_EXTENSIONS}
56
56
)
57
57
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
+
58
62
# options that are valid for gcc and clang
59
63
function (commonopts )
60
64
# more debugging information
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ class SHM {
8
8
std::string name;
9
9
int fd = -1 ;
10
10
std::size_t size = 0 ;
11
- void * addr = nullptr ;
11
+ void * addr = nullptr ;
12
12
13
13
public:
14
14
explicit SHM (std::string name);
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ int main(int argc, char **argv) {
24
24
" output everything that is written to the shared memory to stdout" ,
25
25
cxxopts::value<bool >()->default_value (" false" ));
26
26
options.add_options ()(" h,help" , " print usage" );
27
+ options.add_options ()(" version" , " print version information" );
27
28
28
29
// parse arguments
29
30
cxxopts::ParseResult args;
@@ -68,6 +69,11 @@ int main(int argc, char **argv) {
68
69
exit (EX_OK);
69
70
}
70
71
72
+ // print version
73
+ if (args.count (" version" )) {
74
+ std::cout << PROJECT_NAME << ' ' << PROJECT_VERSION << std::endl;
75
+ exit (EX_OK);
76
+ }
71
77
72
78
// open shm
73
79
std::unique_ptr<SHM> shm;
You can’t perform that action at this time.
0 commit comments