title: Cmake settings to add external c++ classes to a project
body: <p>probably a bit of a noob question so bear with me.</p>
  <p>What do I want to do?
  I have a c++ class called main.cpp and with that I want to add the external classes of <a href="http://www.music.mcgill.ca/%7Egary/rtmidi/" rel="nofollow noreferrer">RtMidi</a>. I can just move the RtMidi classes into the same folder as my main.cpp and include them from there, but it feels a lot cleaner if I can keep them in a sepperate folder.</p>
  <p>The RtMidi folder comes with its own Cmake file, and my assumption is that I can build that folder first to create a library that I then can link to. Is this correct? I'm new to c++ and not 100% sure if this is the way you want to add external classes.</p>
  <p>When trying to build my project RtMidi is built, but I'm getting a warning that the main.cpp file can't find the include.</p>
  <p>I'm building this on a mac with Visual Studio Code and clang as the compiler if that's any help</p>
  <p>main.cpp</p>
  <pre><code>#include &quot;RtMidi.h&quot;
  int main() 
  {
      try 
      {
          RtMidiIn midiin;
      } 
      catch (RtMidiError &amp;error) 
      {
          error.printMessage();
      }
      return 0;
  }
  </code></pre>
  <p>CMakeLists.txt</p>
  <pre><code>cmake_minimum_required(VERSION 3.0.0)
  project(Music)
  
  set(CMAKE_CXX_STANDARD 11)
  set(CMAKE_CXX_STANDARD_REQUIRED ON)
  
  include_directories (Project)
  add_subdirectory (lib/rtmidi-4.0.0)
  
  file(GLOB_RECURSE SOURCES RELATIVE ${CMAKE_SOURCE_DIR} &quot;src/*.cpp&quot;)
  add_executable(Music ${SOURCES})
  
  target_link_libraries(Music RtMidi)
  </code></pre>
  <p>Build output</p>
  <pre><code>[main] Building folder: Music 
  [main] Configuring folder: Music 
  [proc] Executing command: /usr/local/bin/cmake --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/clang -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/clang++ -H/Users/username/Code/Music -B/Users/username/Code/Music/build -G &quot;Unix Makefiles&quot;
  [cmake] Not searching for unused variables given on the command line.
  [cmake] -- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) 
  [cmake] CMake Deprecation Warning at lib/rtmidi-4.0.0/CMakeLists.txt:154 (cmake_policy):
  [cmake]   The OLD behavior for policy CMP0042 will be removed from a future version
  [cmake]   of CMake.
  [cmake] 
  [cmake]   The cmake-policies(7) manual explains that the OLD behaviors of all
  [cmake]   policies are deprecated and that a policy should be set to OLD only under
  [cmake]   specific short-term circumstances.  Projects should be ported to the NEW
  [cmake]   behavior and not rely on setting a policy to OLD.
  [cmake] 
  [cmake] 
  [cmake] -- Compiling with support for: coremidi
  [cmake] -- Configuring done
  [cmake] -- Generating done
  [cmake] -- Build files have been written to: /Users/username/Code/Music/build
  [build] Starting build
  [proc] Executing command: /usr/local/bin/cmake --build /Users/username/Code/Music/build --config Debug --target all -- -j 10
  [build] Scanning dependencies of target Music
  [build] [ 15%] Built target rtmidi
  [build] [ 20%] Building CXX object CMakeFiles/Music.dir/src/main.cpp.o
  [build] [ 40%] Built target sysextest
  [build] [ 40%] Built target qmidiin
  [build] [ 50%] Built target apinames
  [build] [ 60%] Built target midiout
  [build] [ 80%] Built target cmidiin
  [build] [ 80%] Built target midiprobe
  [build] [ 90%] Built target midiclock
  [build] /Users/username/Code/Music/src/main.cpp:5:10: fatal error: 'rtmidi.h' file not found
  [build] #include &quot;rtmidi.h&quot;
  [build]          ^~~~~~~~~~
  [build] 1 error generated.
  [build] make[2]: *** [CMakeFiles/Music.dir/src/main.cpp.o] Error 1
  [build] make[1]: *** [CMakeFiles/Music.dir/all] Error 2
  [build] make: *** [all] Error 2
  [build] Build finished with exit code 2
  </code></pre>
  <p>Thankful for any help, and if this is the wrong way to do things, please point me in the correct direction to do this</p>