Commit 641cdb6430314b97293b8c1a51faaedcd617bae7

Authored by Peter M. Groen
2 parents 8d8360df 44481cf5

Merge branch 'fix/pgroen/disable-test-builds' into 'master'

fix/pgroen/disable test builds

In accordance to a request from a user, examples and tests are disabled from building by default.

See merge request !24
Showing 2 changed files with 20 additions and 8 deletions
CMakeLists.txt
@@ -8,12 +8,17 @@ include(projectheader) @@ -8,12 +8,17 @@ include(projectheader)
8 project_header(osdev_mqtt) 8 project_header(osdev_mqtt)
9 9
10 add_subdirectory(src) 10 add_subdirectory(src)
11 -add_subdirectory(examples/connect)  
12 -add_subdirectory(examples/pub)  
13 -add_subdirectory(examples/sub)  
14 -add_subdirectory(examples/subunsub)  
15 11
16 -add_subdirectory(test) 12 +if(ENABLE_EXAMPLES)
  13 + add_subdirectory(examples/connect)
  14 + add_subdirectory(examples/pub)
  15 + add_subdirectory(examples/sub)
  16 + add_subdirectory(examples/subunsub)
  17 +endif()
  18 +
  19 +if(ENABLE_TESTS)
  20 + add_subdirectory(test)
  21 +endif()
17 22
18 include(packaging) 23 include(packaging)
19 package_component() 24 package_component()
README.md
@@ -30,9 +30,15 @@ Just check your package manager for the correct package-name. @@ -30,9 +30,15 @@ Just check your package manager for the correct package-name.
30 $ cmake ../ 30 $ cmake ../
31 $ gmake ( or make, depending on your platform ) 31 $ gmake ( or make, depending on your platform )
32 ``` 32 ```
33 -And you're all set. In build/bin there are two examples, test_mqtt_pu and test_mqtt_sub. Have a broker running,  
34 -like mosquitto or flashmq capable of accepting anonymous connections. Start the "sub" part and couple of moments  
35 -later the "pub" part. If all went well, you should see two screens in sync running. 33 +
  34 +## Building the examples and tests
  35 +### Tests
  36 +Normally only the library is being build. By adding `-DENABLE_TESTING` to the cmake step, the unittests are being build also. Make sure a broker is running on localhost and type `test/mqtt_test` to run the tests.
  37 +
  38 +### Examples
  39 +By adding the flag `-DENABLE_EXAMPLES` to the cmake step, the examples are being build together with the library.
  40 +
  41 +In build/bin there are two examples, test_mqtt_pu and test_mqtt_sub. Have a broker running, like mosquitto or flashmq capable of accepting anonymous connections. Start the "sub" part and couple of moments later the "pub" part. If all went well, you should see two screens in sync running.
36 42
37 ``` 43 ```
38 Open terminal 1 44 Open terminal 1
@@ -41,6 +47,7 @@ later the "pub" part. If all went well, you should see two screens in sync runni @@ -41,6 +47,7 @@ later the "pub" part. If all went well, you should see two screens in sync runni
41 Open terminal 2 47 Open terminal 2
42 $ bin/test_mqtt_pub 48 $ bin/test_mqtt_pub
43 ``` 49 ```
  50 +
44 Screen 2 is sending, Screen 1 is receiving. 51 Screen 2 is sending, Screen 1 is receiving.
45 52
46 # Using the library. 53 # Using the library.