There is also one more technique to consider here.<br><br>There is a self-referential variable available in every CMakeLists.txt or every included file called CMAKE_CURRENT_LIST_FILE.<br><br>You could do this inside your &quot;common.cmake&quot; file:<br>
<div>  get_filename_component( dir &quot;${CMAKE_CURRENT_LIST_FILE}&quot; PATH )</div><div>  include( ${dir}/BoostUtils.cmake )</div>
<div><br>That way, &#39;dir&#39; always refers to the path to &#39;common.cmake&#39; and you are passing a full path to include for BoostUtils.cmake which unambiguously identifies it without regard for the current working directory... The assumption you are making by doing this is that &#39;common.cmake&#39; and &#39;BoostUtils.cmake&#39; are always coupled together in the same directory. If that assumption is true, this technique should work...<br>
<br><br>HTH,<br>David<br><br></div><br><div class="gmail_quote">On Thu, May 28, 2009 at 1:05 PM, Michael Jackson <span dir="ltr">&lt;<a href="mailto:mike.jackson@bluequartz.net">mike.jackson@bluequartz.net</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">There is a pattern that I use that is similar to what you are wanting so I&#39;ll just throw it out there for your consideration:<br>

<br>
project (Foo)<br>
<br>
#CMake will now Define Foo_SOURCE_DIR which<br>
# is the same as the current directory. It is<br>
# also put into the cache.<br>
<br>
include (${Foo_SOURCE_DIR}/cmake/common.cmake)<br>
<br>
# CMake also defines PROJECT_NAME which takes on the last<br>
# invocation of the &quot;project()&quot; command. So you could rewrite<br>
# the above as:<br>
<br>
include (${${PROJECT_NAME}_SOURCE_DIR}/cmake/common.cmake)<br>
<br>
Then inside of common.cmake you can use the following:<br>
<br>
include (${Foo_SOURCE_DIR}/cmake/BoostUtils.cmake)<br>
<br>
which will generally work but will _still_ fail if you decide<br>
to try and reuse the code in other projects. So what I decided<br>
was to use &quot;Convention Over Configuration&quot; in all my projects.<br>
<br>
I _always_ have a &quot;Resources&quot; directory in my project. Inside of that<br>
directory is _always_ a CMake directory. So in the top level CMakeLists.txt<br>
file of my project I set the following:<br>
<br>
set (PROJECT_RESOURCES_DIR ${${PROJECT_NAME}_SOURCE_DIR}/Resources)<br>
set (PROJECT_CMAKE_DIR ${${PROJECT_NAME}_SOURCE_DIR}/Resources/CMake)<br>
<br>
That way if I have cmake code that needs to reference those directories I always have<br>
cmake variables that can point to the proper directory and I _always_ refer to<br>
files in those directories by their full name:<br>
<br>
include (${PROJECT_RESOURCES_DIR}/MyReallyCoolCMakeMacros.cmake)<br>
<br>
<br>
Just some thoughts.<br>
_________________________________________________________<br>
Mike Jackson                  <a href="mailto:mike.jackson@bluequartz.net" target="_blank">mike.jackson@bluequartz.net</a><br>
BlueQuartz Software                    <a href="http://www.bluequartz.net" target="_blank">www.bluequartz.net</a><br>
Principal Software Engineer                  Dayton, Ohio<div><div></div><div class="h5"><br>
<br>
<br>
<br>
On May 28, 2009, at 12:17 PM, Robert Dailey wrote:<br>
<br>
</div></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div class="h5">
On Thu, May 28, 2009 at 11:06 AM, Tyler Roscoe &lt;<a href="mailto:tyler@cryptio.net" target="_blank">tyler@cryptio.net</a>&gt; wrote:<br>
On Thu, May 28, 2009 at 10:42:03AM -0500, Robert Dailey wrote:<br>
&gt; The most annoying thing about this solution, though, is that every single<br>
&gt; CMakeLists.txt that includes this module needs to make sure it has<br>
&gt; CMAKE_MODULE_PATH setup properly. It&#39;s just a bit redundant and<br>
&gt; tedious.<br>
<br>
You&#39;re kind of a hater, aren&#39;t you Robert?<br>
<br>
I never said I hated anything, I just said it was just a little bit obnoxious (redundant/tedious).<br>
<br>
Can you just set CMAKE_MODULE_PATH in your ../cmake/common.cmake? If all<br>
your Lists include that then you only need to set it once.<br>
<br>
Yep I thought about this too, but it is still not the perfect solution I had in mind :) Not having to set it at all is the ideal path, but we can&#39;t all get our way :)<br>
<br>
Thanks for your help.<br></div></div><div class="im">
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
</div></blockquote><div><div></div><div class="h5">
<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
</div></div></blockquote></div><br>