Browse Source

cmake install rules; fixed cli tags and devices actions

develop
Robin Thoni 7 years ago
parent
commit
47e931adc2
5 changed files with 20 additions and 8 deletions
  1. 1
    1
      CMakeLists.txt
  2. 3
    0
      cli/CMakeLists.txt
  3. 10
    6
      cli/Interface/MainClass.cpp
  4. 3
    1
      cli/Interface/MainClass.h
  5. 3
    0
      src/CMakeLists.txt

+ 1
- 1
CMakeLists.txt View File

@@ -26,4 +26,4 @@ add_subdirectory(cli)
26 26
 if (GTEST_FOUND)
27 27
     enable_testing()
28 28
     add_subdirectory(tests)
29
-endif (GTEST_FOUND)
29
+endif (GTEST_FOUND)

+ 3
- 0
cli/CMakeLists.txt View File

@@ -14,3 +14,6 @@ set(SOURCE_FILES
14 14
 set(LIBS ${LIBS} ${PROJECT_NAME})
15 15
 add_executable(${PROJECT_NAME}-cli ${SOURCE_FILES})
16 16
 target_link_libraries(${PROJECT_NAME}-cli ${LIBS})
17
+
18
+install(TARGETS ${PROJECT_NAME}-cli
19
+        RUNTIME DESTINATION bin)

+ 10
- 6
cli/Interface/MainClass.cpp View File

@@ -145,6 +145,12 @@ int MainClass::main()
145 145
         }
146 146
         action = Write;
147 147
     }
148
+    else if (optionDevices.isSet()) {
149
+        action = Devices;
150
+    }
151
+    else if (optionTags.isSet()) {
152
+        action = Tags;
153
+    }
148 154
     else {
149 155
         std::cerr << "Must select an action (map|read|write|devices|tags)" << std::endl;
150 156
         return EX_USAGE;
@@ -168,7 +174,7 @@ int MainClass::main()
168 174
         {
169 175
             auto devices = devicesResult.getData();
170 176
 
171
-            if (optionDevices.isSet())
177
+            if (action == Devices)
172 178
             {
173 179
                 for (auto device : devices) {
174 180
                     cout() << device->getConnStr() << std::endl;
@@ -192,17 +198,15 @@ int MainClass::main()
192 198
 
193 199
                         FreeFareDeviceBusiness freeFareDevice(device);
194 200
                         auto tagsResult = freeFareDevice.getTags();
195
-                        if (!tagsResult)
196
-                        {
201
+                        if (!tagsResult) {
197 202
                             tagsResult.print();
198 203
                             res = EX_LIB_NFC_ERROR;
199 204
                         }
200 205
 
201 206
                         auto tags = tagsResult.getData();
202 207
 
203
-                        if (optionTags.isSet()) {
204
-                            for (auto tag : tags)
205
-                            {
208
+                        if (action == Tags) {
209
+                            for (auto tag : tags) {
206 210
                                 cout() << "UID=" << tag->getUid() << " \tType=" << tag->getType() << std::endl;
207 211
                             }
208 212
                         }

+ 3
- 1
cli/Interface/MainClass.h View File

@@ -14,7 +14,9 @@ public:
14 14
     enum Actions {
15 15
         Read,
16 16
         Write,
17
-        Map
17
+        Map,
18
+        Devices,
19
+        Tags
18 20
     };
19 21
 
20 22
     MainClass(int argc, char* argv[]);

+ 3
- 0
src/CMakeLists.txt View File

@@ -15,3 +15,6 @@ set(SOURCE_FILES
15 15
 
16 16
 add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES})
17 17
 target_link_libraries(${PROJECT_NAME} ${LIBS})
18
+
19
+install(TARGETS ${PROJECT_NAME}
20
+        LIBRARY DESTINATION lib)

Loading…
Cancel
Save