<div dir="ltr">Thanks Craig<div><br></div><div>Not sure if I'm doing it right, but I couldn't get that to work.<div><br></div><div>Would you be able to give me an example please?</div><div><br></div><div>Thanks</div><div>Steve<br><div><br></div><div><br></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 16 October 2016 at 17:51, Craig Scott <span dir="ltr"><<a href="mailto:craig.scott@crascit.com" target="_blank">craig.scott@crascit.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I think if you manipulate the target property <a href="https://cmake.org/cmake/help/latest/prop_tgt/INCLUDE_DIRECTORIES.html" target="_blank">INCLUDE_DIRECTORIES</a> directly, you should be able to force a "." in there without having it substituted for an absolute path. By this I mean use set_property() or set_target_properties() rather than target_include_directories() or include_directories(). Note, however, that the documentation for the INCLUDE_DIRECTORIES property explicitly recommends against adding relative paths to the property like this (but in your case it sounds like you really want a relative path, so maybe this is a valid exception to that advice).<div><br><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Mon, Oct 17, 2016 at 9:46 AM, Steve Lorimer <span dir="ltr"><<a href="mailto:steve.lorimer@gmail.com" target="_blank">steve.lorimer@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr">In makefile parlance, I'm trying to add -I. (ie: the current directory) to my include paths<div><br></div><div>I tried the following:</div><div><br></div><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div>include_directories(".")</div></blockquote></div><div><br></div><div>This doesn't work unfortunately, as <a href="https://cmake.org/cmake/help/v3.0/command/include_directories.html" target="_blank">relative paths are interpreted as relative to the current source directory</a></div><div><br></div><div>That is, if this statement is in my top level CMakeLists.txt, located in ~/src/project, the include directive added will be "-I ~/src/project/.", whereas I'm trying to add "-I ."</div><div><br></div><div>The reason for my wanting this is that we have sources for a single library in several subdirs. </div><div><br></div><span style="white-space:pre-wrap">        </span><span style="white-space:pre-wrap">include_directories(${CMAKE_CU<wbr>RRENT_SOURCE_DIR})</span> <div><br><div><span class="m_-6762616412334362077m_4571904100524877973gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>add_library(<br></div><div><div><span class="m_-6762616412334362077m_4571904100524877973gmail-Apple-tab-span" style="white-space:pre-wrap">                      </span>foo</div><div><span class="m_-6762616412334362077m_4571904100524877973gmail-Apple-tab-span" style="white-space:pre-wrap">                    </span>STATIC</div><div><div><span class="m_-6762616412334362077m_4571904100524877973gmail-Apple-tab-span" style="white-space:pre-wrap">                      foo.cpp</span></div></div><div><span class="m_-6762616412334362077m_4571904100524877973gmail-Apple-tab-span" style="white-space:pre-wrap"><div style="white-space:normal"><span class="m_-6762616412334362077m_4571904100524877973gmail-Apple-tab-span" style="white-space:pre-wrap">                       bar/bar.cpp</span></div><div><span class="m_-6762616412334362077m_4571904100524877973gmail-Apple-tab-span">                   </span>)<br></div><div><br></div><div>In bar/bar.cpp, I have a relative include</div><div><br></div><div>       #include "../foo.h"<br></div><div><br></div><div>With the above setup, this will fail to compile as only ~/src/project/foo will be added to the include paths.</div><div><br></div><div>I'm aware that if I explicitly added the path it would work</div><div><br></div><div>     include_directories(${CMAKE_CU<wbr>RRENT_SOURCE_DIR}/bar)<span style="white-space:normal"> </span><br></div><div><span style="white-space:normal"><br></span></div></span></div></div><div>However, if there is a way to get -I. added to my include path, that's what I'm after.</div></div><div><br></div><div>TIA</div><span class="m_-6762616412334362077HOEnZb"><font color="#888888"><div>Steve</div><div><br></div></font></span></div>
<br></div></div>--<br>
<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer" target="_blank">http://www.cmake.org/Wiki/CMak<wbr>e_FAQ</a><br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/su<wbr>pport.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/co<wbr>nsulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/tr<wbr>aining.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensou<wbr>rce/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/cmake" rel="noreferrer" target="_blank">http://public.kitware.com/mail<wbr>man/listinfo/cmake</a><span class="HOEnZb"><font color="#888888"><br></font></span></blockquote></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div class="m_-6762616412334362077gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr">Craig Scott<br><div>Melbourne, Australia</div><div><a href="https://crascit.com" target="_blank">https://crascit.com</a><br></div></div></div></div></div></div></div>
</font></span></div>
</blockquote></div><br></div>