title: How to Link to mosquitto lib in cmake?
body: <p>I have installed <code>mosquitto lib</code> in my Rpi using this <a href="https://www.disk91.com/2013/technology/hardware/mqtt-on-raspeberry-pi/" rel="nofollow noreferrer">tutorial</a>.
  <code>/usr/local/bin</code> has <code>mosquitto_pub and mosquitto_sub</code> and the mosquitto server deamon is in <code>/usr/local/sbin</code>.</p>
  <p>Then trying to link the library in my cmake file as follow.</p>
  <pre class="lang-cmake prettyprint-override"><code>cmake_minimum_required(VERSION 2.6)
   
  PROJECT(MosquittoTest)
  # The version number.
  set (VERSION_MAJOR 1)
  set (VERSION_MINOR 0)
  
  include_directories(&quot;${PROJECT_BINARY_DIR}&quot;)
  
  # Linked libariries
  #For MQTT
  #location of raspicam's cmake file is /usr/src/raspicam-0.1.3/build
  link_directories(/usr/local/sbin)
  target_link_libraries (MosquittoTest  mosquitto)
  
  ADD_EXECUTABLE(MosquittoTest MosquittoTest.cpp)
  
  # add the install targets
  install (TARGETS MosquittoTest DESTINATION bin)
  install (FILES MosquittoInterface.h DESTINATION include)
  </code></pre>
  <p>Then I have error as Can't specify link library for target MosquittoTest.</p>
  <p>Somebody has link the mosquitto lib in gcc make as</p>
  <pre class="lang-make prettyprint-override"><code>CC = gcc
  CFLAGS = -I
  DEPS = mosquitto.h
  
  LIBS = -llibmosquitto
  
  %.o: %.c $(DEPS)
      $(CC) -c -o $@ $&lt; $(CFLAGS)
  
  make: test.c
      $(CC) -m32 -Wall -o $@ $^ $(CFLAGS) $(LIBS)
  
  .PHONY: clean
  </code></pre>
  <p>What could be wrong with my cmake file?</p>