<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 4, 2017 at 6:22 PM, Randy Heiland <span dir="ltr"><<a href="mailto:randy.heiland@gmail.com" target="_blank">randy.heiland@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Thanks for the reply. In my case, I didn't even want the CMakeLists in the top-level dir. I didn't want to contaminate my top-level dir with anything related to CMake. This would avoid, for example, an accidental overwrite of an existing Makefile if one was to do a 'cmake .' in the the top dir.<div><br></div></div></blockquote><div><div>:) they could still 'cmake cmake' in the top dir :) </div></div><div><br></div><div>you could add something like <br><br>if( ${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR} ) <br>  message( FATAL_ERROR "dont' run cmake in this directory" ) # or something<br>endif() <br><br>but you don't need to add the .. in the project() just in the sources added to add_library() or add_executable()<br><br>I'd probably SET( SOURCE_ROOT ${CMAKE_SOURCE_DIR}/.. ) if it was in a location where you were... and then add sources as... <br>add_executable ( mySimpleProgram ${SOURCE_ROOT}/main.c )<br><br><br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div></div><div>It's quite possible I'm over-thinking this; I was just curious if it's even possible. Seems like it should be. </div></div></blockquote><div><br></div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><span class="gmail-HOEnZb"><font color="#888888"><div><br></div><div>-Randy</div></font></span></div><div class="gmail-HOEnZb"><div class="gmail-h5"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 4, 2017 at 4:30 PM, J. Caleb Wherry <span dir="ltr"><<a href="mailto:calebwherry@gmail.com" target="_blank">calebwherry@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">There is no reason why this shouldn't work, I do something similar where everything except my top-level CMakeLists is shoved into a subdirectory (away from the src code location).<div><br></div><div>You don't have to muck with the project macro at all, not sure what you are trying to accomplish with that? That just sets the name of the project.</div><div><br></div><div>All you have to be aware of is all the paths are now with respect to both the CMakeLists and where ever you put your binary dir. So doing something like the below allows you to reference things in your source tree (depending on how far you away form the root, obviously):</div><div><br></div><div>get_filename_component(SourceR<wbr>oot "${CMAKE_CURRENT_SOURCE_DIR}/.<wbr>./../" ABSOLUTE)<br></div><div><br></div><div>The normal structure of the CMake file doesn't change, nothing special has to be done with the project macro. Unless you have a more specific error, that's about all the advice I have.</div><div><br></div><div>-Caleb</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="gmail-m_-7715968948744035326h5">On Wed, Oct 4, 2017 at 3:16 PM, Randy Heiland <span dir="ltr"><<a href="mailto:randy.heiland@gmail.com" target="_blank">randy.heiland@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div class="gmail-m_-7715968948744035326h5"><div dir="ltr">Hello,<div><br></div><div>Simple question... can I/how can I keep my top-level cmake-related stuff in a subdirectory of my main project directory? E.g.:</div><div><br></div><div>/myproj</div><div>  /cmake</div><div>    CMakeLists.txt</div><div><br></div><div>and then in the /cmake, I create a /build from which I attempt:  cmake ..</div><div>







<p class="gmail-m_-7715968948744035326m_1715029472801525403m_1823411125408047178gmail-p1"><span class="gmail-m_-7715968948744035326m_1715029472801525403m_1823411125408047178gmail-s1">I tried something as simple as this in my </span>CMakeLists.txt, but it didn't seem to work:</p>project (../myproj)<br><br><br>The primary reason I'd like to do this is to hide/make optional the cmake build approach (and keep in place an existing/traditional Makefile in the parent directory). Play along...</div><div><br></div><div>thanks, Randy</div></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="gmail-m_-7715968948744035326HOEnZb"><font color="#888888"><br></font></span></blockquote></div><span class="gmail-m_-7715968948744035326HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div class="gmail-m_-7715968948744035326m_1715029472801525403gmail_signature"><div>J. Caleb Wherry</div><i>Scientific Software Engineer</i><div><br><a href="http://www.calebwherry.com" target="_blank"></a><div><a href="http://www.calebwherry.com" target="_blank">http://www.calebwherry.com</a><br><span><span title="Call with Google Voice"><span title="Call with Google Voice"><a href="tel:(615)%20708-5651" value="+16157085651" target="_blank">+1 (615) 708-5651</a></span></span></span><div><a href="mailto:calebwherry@gmail.com" target="_blank">calebwherry@gmail.com</a></div></div></div></div>
</font></span></div>
</blockquote></div><br></div>
</div></div><br>--<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/<wbr>CMake_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/<wbr>support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/<wbr>consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/<wbr>training.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/<wbr>opensource/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/<wbr>mailman/listinfo/cmake</a><br></blockquote></div><br></div></div>