title: CMake: library not found
body: <p>As you can see form here (<a href="https://stackoverflow.com/questions/26105411/cmake-how-to-specify-the-compiler-and-to-compile-different-main-functions/26105829?noredirect=1#comment40912816_26105829">How to Specify the Compiler and To Compile Different Main Functions</a>) I am new to CMake and I still have problem. The previous question helped me to understand CMake, but I still have problems. First of all, even if I wrote the following lines in my CMakeLists.txt</p>
  
  <pre><code>set(CMAKE_CXX_COMPILER /opt/local/bin/g++)
  set(CMAKE_CXX_FLAGS "-Wall -std=c++11")
  </code></pre>
  
  <p>the compiler used seems to be Clang and not g++. In addition when compiling (I get rid of all code errors) I obtain this message:</p>
  
  <pre><code>[ 33%] Built target Output
  [ 66%] Built target Vector
  Scanning dependencies of target Output_test
  [100%] Building CXX object tests/CMakeFiles/Output_test.dir/output_test.cpp.o
  Linking CXX executable Output_test
  ld: library not found for -lIO
  collect2: error: ld returned 1 exit status
  make[2]: *** [tests/Output_test] Error 1
  make[1]: *** [tests/CMakeFiles/Output_test.dir/all] Error 2
  make: *** [all] Error 2
  </code></pre>
  
  <p>Do you know what I am doing wrong?</p>
  
  <p>Edit:
  In the root folder</p>
  
  <pre><code>cmake_minimum_required (VERSION 2.8.11)
  project (MC)
  
  set(CMAKE_CXX_COMPILER /opt/local/bin/g++)
  set(CMAKE_CXX_FLAGS "-Wall -std=c++11")
  
  # Class definitions
  add_subdirectory(IO)
  add_subdirectory(math)
  
  # Tests
  add_subdirectory(tests)
  </code></pre>
  
  <p>In the IO folder:</p>
  
  <pre><code>add_library(Output Output.cpp)
  </code></pre>