title: How to setup CMake to build code which contains path-includes like #include <libdir/lib>?
body: <p>I am trying to migrate an old C/C++ sunstudio project to visual studio 2019. I need to build targets on a remote linux machine, so I cannot use the visual studio solution to build. After some unsuccessful attempts to use the old sunstudio makefiles, I have decided to use <strong>cmake</strong> to build the project.</p>
  
  <p>The problem is that the code references includes with relative paths, like this:</p>
  
  <pre><code>(tkamain.cxx):
  #include &lt;ukernel/inc/U.h&gt;
  #include &lt;monitor/inc/monitor.h&gt;
  </code></pre>
  
  <p>I don't want to touch the code, so how can I setup CMake to build this project properly with these specific include statements?</p>
  
  <p>The project structure looks like this.</p>
  
  <pre><code>tka
  |-mod
  ||-monitor
  ||'-inc
  ||-feedutils
  ||'-inc
  |'-ukernel
  | '-inc
  |-inc
  ||-foo.hxx
  |'-bar.hxx
  |-src
  ||-foo.cxx
  ||-bar.cxx
  ||-tkamain.cxx
  |'-CMakeLists.txt (CMakeB)
  '-CMakeLists.txt (CMakeA)
  </code></pre>
  
  <p>The CMakeLists.txt are newly created by me and are probably not correctly set up yet.</p>
  
  <p>The CMakeA file contains this:</p>
  
  <pre><code>project(tka)
  add_subdirectory(src)
  </code></pre>
  
  <p>The CMakeB file contains this:</p>
  
  <pre><code>include_directories(${PROJECT_SOURCE_DIR}/inc)
  include_directories(${PROJECT_SOURCE_DIR}/mod)
  add_executable(tkamain tkamain.cxx)
  </code></pre>
  
  <p>The commands in CMakeB seem not to be sufficient for my purposes, what am I missing? Or do I need more CMakeLists.txt files? </p>
  
  <p>The errors I am getting look like this:</p>
  
  <pre><code>[ 50%] Building CXX object src/CMakeFiles/tkamain.dir/tkamain.cxx.o
  /drive/new/home/mwe/.vs/tka/eb2f2a43-555a-3934-8996-0095b1bcc780/src/src/tkamain.cxx:11:27: error: ukernel/inc/U.h: No such file or directory
  /drive/new/home/mwe/.vs/tka/eb2f2a43-555a-3934-8996-0095b1bcc780/src/src/tkamain.cxx:14:33: error: monitor/inc/monitor.h: No such file or directory
  </code></pre>
  
  <p>I have tried to give more specific include paths, like this, but that didn't help either:</p>
  
  <pre><code>include_directories(${PROJECT_SOURCE_DIR}/mod/ukernel/inc)
  include_directories(${PROJECT_SOURCE_DIR}/mod/monitor/inc)
  </code></pre>
  
  <p>When I run make VERBOSE=1, I get the following:</p>
  
  <pre><code>/usr/local/bin/cmake -S/drive/new/home/mwe/.vs/tka/eb2f2a43-555a-3934-8996-0095b1bcc780/src -B/drive/new/home/mwe/.vs/tka/eb2f2a43-555a-3934-8996-0095b1bcc780/out/build/Linux-Debug-test --check-build-system CMakeFiles/Makefile.cmake 0
  /usr/local/bin/cmake -E cmake_progress_start /drive/new/home/mwe/.vs/tka/eb2f2a43-555a-3934-8996-0095b1bcc780/out/build/Linux-Debug-test/CMakeFiles /drive/new/home/mwe/.vs/tka/eb2f2a43-555a-3934-8996-0095b1bcc780/out/build/Linux-Debug-test/CMakeFiles/progress.marks
  make -f CMakeFiles/Makefile2 all
  make[1]: Entering directory `/drive/new/home/mwe/.vs/tka/eb2f2a43-555a-3934-8996-0095b1bcc780/out/build/Linux-Debug-test'
  make -f src/CMakeFiles/tkamain.dir/build.make src/CMakeFiles/tkamain.dir/depend
  make[2]: Entering directory `/drive/new/home/mwe/.vs/tka/eb2f2a43-555a-3934-8996-0095b1bcc780/out/build/Linux-Debug-test'
  cd /drive/new/home/mwe/.vs/tka/eb2f2a43-555a-3934-8996-0095b1bcc780/out/build/Linux-Debug-test &amp;&amp; /usr/local/bin/cmake -E cmake_depends "Unix Makefiles" /drive/new/home/mwe/.vs/tka/eb2f2a43-555a-3934-8996-0095b1bcc780/src /drive/new/home/mwe/.vs/tka/eb2f2a43-555a-3934-8996-0095b1bcc780/src/src /drive/new/home/mwe/.vs/tka/eb2f2a43-555a-3934-8996-0095b1bcc780/out/build/Linux-Debug-test /drive/new/home/mwe/.vs/tka/eb2f2a43-555a-3934-8996-0095b1bcc780/out/build/Linux-Debug-test/src /drive/new/home/mwe/.vs/tka/eb2f2a43-555a-3934-8996-0095b1bcc780/out/build/Linux-Debug-test/src/CMakeFiles/tkamain.dir/DependInfo.cmake --color=
  make[2]: Leaving directory `/drive/new/home/mwe/.vs/tka/eb2f2a43-555a-3934-8996-0095b1bcc780/out/build/Linux-Debug-test'
  make -f src/CMakeFiles/tkamain.dir/build.make src/CMakeFiles/tkamain.dir/build
  make[2]: Entering directory `/drive/new/home/mwe/.vs/tka/eb2f2a43-555a-3934-8996-0095b1bcc780/out/build/Linux-Debug-test'
  [ 50%] Building CXX object src/CMakeFiles/tkamain.dir/tkamain.cxx.o
  cd /drive/new/home/mwe/.vs/tka/eb2f2a43-555a-3934-8996-0095b1bcc780/out/build/Linux-Debug-test/src &amp;&amp; /usr/bin/c++   -I/inc  -g   -o CMakeFiles/tkamain.dir/tkamain.cxx.o -c /drive/new/home/mwe/.vs/tka/eb2f2a43-555a-3934-8996-0095b1bcc780/src/src/tkamain.cxx
  /drive/new/home/mwe/.vs/tka/eb2f2a43-555a-3934-8996-0095b1bcc780/src/src/tkamain.cxx:11:27: error: ukernel/inc/U.h: No such file or directory
  /drive/new/home/mwe/.vs/tka/eb2f2a43-555a-3934-8996-0095b1bcc780/src/src/tkamain.cxx:12:30: error: ukernel/inc/Ulib.h: No such file or directory
  /drive/new/home/mwe/.vs/tka/eb2f2a43-555a-3934-8996-0095b1bcc780/src/src/tkamain.cxx:13:31: error: ukernel/inc/UExit.h: No such file or directory
  /drive/new/home/mwe/.vs/tka/eb2f2a43-555a-3934-8996-0095b1bcc780/src/src/tkamain.cxx:14:33: error: monitor/inc/monitor.h: No such file or directory
  /drive/new/home/mwe/.vs/tka/eb2f2a43-555a-3934-8996-0095b1bcc780/src/src/tkamain.cxx:31:26: error: tkacontrol.hxx: No such file or directory
  /drive/new/home/mwe/.vs/tka/eb2f2a43-555a-3934-8996-0095b1bcc780/src/src/tkamain.cxx:24: error: expected ',' or ';' before 'U_OS'
  /drive/new/home/mwe/.vs/tka/eb2f2a43-555a-3934-8996-0095b1bcc780/src/src/tkamain.cxx: In function 'int main(int, char**)':
  /drive/new/home/mwe/.vs/tka/eb2f2a43-555a-3934-8996-0095b1bcc780/src/src/tkamain.cxx:37: error: 'UkInit' was not declared in this scope
  /drive/new/home/mwe/.vs/tka/eb2f2a43-555a-3934-8996-0095b1bcc780/src/src/tkamain.cxx:39: error: 'TkaControl' was not declared in this scope
  /drive/new/home/mwe/.vs/tka/eb2f2a43-555a-3934-8996-0095b1bcc780/src/src/tkamain.cxx:39: error: 'tkaControl' was not declared in this scope
  /drive/new/home/mwe/.vs/tka/eb2f2a43-555a-3934-8996-0095b1bcc780/src/src/tkamain.cxx:39: error: expected type-specifier before 'TkaControl'
  /drive/new/home/mwe/.vs/tka/eb2f2a43-555a-3934-8996-0095b1bcc780/src/src/tkamain.cxx:39: error: expected ';' before 'TkaControl'
  /drive/new/home/mwe/.vs/tka/eb2f2a43-555a-3934-8996-0095b1bcc780/src/src/tkamain.cxx:41: error: 'UExitHandler' was not declared in this scope
  /drive/new/home/mwe/.vs/tka/eb2f2a43-555a-3934-8996-0095b1bcc780/src/src/tkamain.cxx:41: error: expected ';' before 'exithandler'
  /drive/new/home/mwe/.vs/tka/eb2f2a43-555a-3934-8996-0095b1bcc780/src/src/tkamain.cxx:43: error: 'Monitor2Startup' was not declared in this scope
  /drive/new/home/mwe/.vs/tka/eb2f2a43-555a-3934-8996-0095b1bcc780/src/src/tkamain.cxx:45: error: 'evalarg_error' was not declared in this scope
  /drive/new/home/mwe/.vs/tka/eb2f2a43-555a-3934-8996-0095b1bcc780/src/src/tkamain.cxx:46: error: 'UEXIT_STOP' was not declared in this scope
  /drive/new/home/mwe/.vs/tka/eb2f2a43-555a-3934-8996-0095b1bcc780/src/src/tkamain.cxx:46: error: 'UExitMsg' was not declared in this scope
  /drive/new/home/mwe/.vs/tka/eb2f2a43-555a-3934-8996-0095b1bcc780/src/src/tkamain.cxx:49: error: 'UkMain' was not declared in this scope
  /drive/new/home/mwe/.vs/tka/eb2f2a43-555a-3934-8996-0095b1bcc780/src/src/tkamain.cxx:50: error: 'Monitor2Exit' was not declared in this scope
  /drive/new/home/mwe/.vs/tka/eb2f2a43-555a-3934-8996-0095b1bcc780/src/src/tkamain.cxx:59: error: 'UEXIT_STOP' was not declared in this scope
  /drive/new/home/mwe/.vs/tka/eb2f2a43-555a-3934-8996-0095b1bcc780/src/src/tkamain.cxx:59: error: 'UExitMsg' was not declared in this scope
  make[2]: *** [src/CMakeFiles/tkamain.dir/tkamain.cxx.o] Error 1
  make[2]: Leaving directory `/drive/new/home/mwe/.vs/tka/eb2f2a43-555a-3934-8996-0095b1bcc780/out/build/Linux-Debug-test'
  make[1]: *** [src/CMakeFiles/tkamain.dir/all] Error 2
  make[1]: Leaving directory `/drive/new/home/mwe/.vs/tka/eb2f2a43-555a-3934-8996-0095b1bcc780/out/build/Linux-Debug-test'
  make: *** [all] Error 2
  </code></pre>