title: Add wiringPi lib to cmake on RaspberryPi
body: <p>for my project in c++ I wanted to create a cmake file to compile and link everything together.<br>
  This is my dir structure so far:</p>
  
  <pre><code>"quadro/minimu9-ahrs" alias home
  |-build
  |-include
  |-src
  </code></pre>
  
  <p>in my home dir I have this 'CMakeLists.txt' file:</p>
  
  <pre><code>cmake_minimum_required (VERSION 2.6)
  project(minimu)
  
  set(HEADER_FILES $("include/*.h")
  include_directories(include)
  file(GLOB SOURCES "src/*.cpp")
  
  add_executable(minimu ${SOURCES})
  add_definitions(-std=c++0x -lwiringPi -lpthread)
  
  #install(TARGETS minimu DESTINATION /usr/lib)
  </code></pre>
  
  <p>in my 'src' dir I got all the .cpp files, and in 'include' all my headers. When I'm comiling, I go into my build dir, delete everything existing in there (from previous builds) and type</p>
  
  <pre><code>cmake ..
  make
  </code></pre>
  
  <p>my problem in now, that my main.cpp in src uses '#include wiringPi.h', but when I make the project it gives me the following error:</p>
  
  <pre><code>pi@raspberrypi ~/quadro/minimu9-ahrs/build $ make
  Scanning dependencies of target minimu
  [ 20%] Building CXX object CMakeFiles/minimu.dir/src/L3G.cpp.o
  [ 40%] Building CXX object CMakeFiles/minimu.dir/src/LSM303.cpp.o
  [ 60%] Building CXX object CMakeFiles/minimu.dir/src/main.cpp.o
  [ 80%] Building CXX object CMakeFiles/minimu.dir/src/I2CBus.cpp.o
  [100%] Building CXX object CMakeFiles/minimu.dir/src/MinIMU9.cpp.o
  Linking CXX executable minimu
  CMakeFiles/minimu.dir/src/main.cpp.o: In function `frequency_thread(void*)':
  main.cpp:(.text+0x1c): undefined reference to `digitalWrite'
  main.cpp:(.text+0x38): undefined reference to `digitalWrite'
  CMakeFiles/minimu.dir/src/main.cpp.o: In function `signalHandler(int)':
  main.cpp:(.text+0xd4): undefined reference to `digitalWrite'
  main.cpp:(.text+0xe8): undefined reference to `digitalWrite'
  CMakeFiles/minimu.dir/src/main.cpp.o: In function `main':
  main.cpp:(.text+0x14c): undefined reference to `wiringPiSetup'
  main.cpp:(.text+0x184): undefined reference to `pinMode'
  main.cpp:(.text+0x1e8): undefined reference to `pthread_create'
  main.cpp:(.text+0x29c): undefined reference to `pthread_join'
  collect2: ld returned 1 exit status
  CMakeFiles/minimu.dir/build.make:185: recipe for target 'minimu' failed
  make[2]: *** [minimu] Error 1
  CMakeFiles/Makefile2:60: recipe for target 'CMakeFiles/minimu.dir/all' failed
  make[1]: *** [CMakeFiles/minimu.dir/all] Error 2
  Makefile:72: recipe for target 'all' failed
  make: *** [all] Error 2
  </code></pre>
  
  <p>so how do I tell the compiler in cmake where to find and how to use the wiringPi lib? And is there an easier way, instead of deleting everything in my build folder before cmaking? Like it compiles all the 'static' files one time, and only adds the changing file (=main.cpp) everytime again.</p>
  
  <p>Further I want to execute my program everywhere like</p>
  
  <pre><code>sudo minimu
  </code></pre>
  
  <p>instead of going into the 'build' dir and type</p>
  
  <pre><code>sudo ./minimu
  </code></pre>
  
  <p>Thanks if you can help me guys!<br>
  And sorry if my english isn't that good :)<br>
  Have a nice day.</p>