Commit 8c83f5a1db8a94ec8eb9a848fbd504c5da0ea778

Authored by Nodeduino
Committed by Moritz Wirger
1 parent 425f609f

Update README.md

- divide Build and install into smaller parts
- add Advanced usage that describes the best way to use this library with CMake
Showing 1 changed file with 26 additions and 0 deletions
README.md
... ... @@ -93,6 +93,7 @@ which for now can be found in the regarding sourcecode file or create the docume
93 93 with the provided Doxyfile yourself.
94 94  
95 95 ## Build and install
  96 +### Basic installation
96 97 If you want to build the library you can use cmake (at least version 2.8.3). First create a build folder and then execute cmake.
97 98 ```bash
98 99 mkdir build
... ... @@ -114,6 +115,31 @@ To remove it
114 115 ```bash
115 116 make uninstall
116 117 ```
  118 +
  119 +### Advanced usage
  120 +If you have a project that already uses CMake you probably want to add the hueplusplus library directly in your cmake file.
  121 +For that the best way is to use find_package().
  122 +When cmake finds the hueplusplus library you can then link against either the shared or static version of the library.
  123 +```cmake
  124 +find_package(hueplusplus)
  125 +
  126 +target_link_libraries(<executable> hueplusplusstatic)
  127 +```
  128 +But this will only work if the hueplusplus library is already installed.
  129 +To get around this problem there is a pretty awesome way.
  130 +If you have the hueplusplus repository included in your project repository (as a submodule) or know where the folder lives you can do the following:
  131 +```cmake
  132 +find_package(hueplusplus)
  133 +if(NOT hueplusplus_FOUND)
  134 + message(STATUS "-- hueplusplus not found, building it")
  135 + add_subdirectory("${CMAKE_SOURCE_DIR}/<path to directory>/hueplusplus" "${CMAKE_BINARY_DIR}/hueplusplus")
  136 +endif()
  137 +
  138 +target_link_libraries(<executable> hueplusplusstatic)
  139 +```
  140 +This will check if the hueplusplus library was found by find_package() and if not it will use the specified path to the library source and compile it during the build process.
  141 +
  142 +### Running tests
117 143 If you additionally want to run the tests you will currently need to checkout the development branch and use cmake with the option -Dhueplusplus_TESTS=ON. Testing is done with Google gtest and gmock. Note that you wont need to install gtest/gmock yourself, because cmake will automatically download them and include them during the build. Since I added a custom target you will only need to call "make unittest" and the tests are compiled and executed.
118 144 ```bash
119 145 mkdir build
... ...