Thank you Mike and Eric,<div><br></div><div>Mike,</div><div><br></div><div>This is the level of detail that I was hoping for in regards to CMake.</div><div><br></div><div>In order to get it to compile I had copy/pasted a getline substitute.</div>
<div>Now I'll go back and try to configure CMake correctly so that it works on both OS X and Linux.</div><div><br></div><div><br></div><div>Eric,</div><div><br></div><div>The second link you gave is very helpful.</div>
<div><br></div><div>AJ ONeal<br><br><div class="gmail_quote">On Mon, Apr 25, 2011 at 7:49 AM, Michael Jackson <span dir="ltr"><<a href="mailto:mike.jackson@bluequartz.net">mike.jackson@bluequartz.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">For the CMake side of things you can actually check for the function during the initial cmake checks:<br>
<br>
INCLUDE (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake)<br>
CHECK_FUNCTION_EXISTS(getline HAS_GETLINE)<br>
<br>
This will perform the check and put the result into the variable "HAS_GETLINE". The easiest (but least maintainable way) is to then do:<br>
<br>
if (HAS_GETLINE)<br>
ADD_DEFINITION(-DHAS_GETLINE)<br>
endif()<br>
<br>
Then in your source code you do:<br>
<br>
#ifdef HAS_GETLINE<br>
<br>
#else<br>
<br>
#endif<br>
<br>
When you get comfortable with that then what you _really_ do is to create a header template file for CMake to fill in. So create a file <a href="http://ProjectConfig.h.in" target="_blank">ProjectConfig.h.in</a> and put this into it.<br>
<br>
#cmakedefine HAS_GETLINE @HAS_GETLINE@<br>
<br>
Then in your CMakeLists.txt file you would do this:<br>
<br>
configure_file ( <a href="http://ProjectConfig.h.in" target="_blank">ProjectConfig.h.in</a> ${PROJECT_BINARY_DIR}/ProjectConfig.h @only immediate)<br>
<br>
Then in your source file simply include the generated header file:<br>
<br>
#include "ProjectConfig.h"<br>
<br>
All of this addresses how to detect the fact that OS X does not have getline. You are responsible for finding a substitution. Maybe this will help:<br>
<br>
<a href="http://doubletalkin.blogspot.com/2008/08/fgetln-replacement-for-getline-in-bsd.html" target="_blank">http://doubletalkin.blogspot.com/2008/08/fgetln-replacement-for-getline-in-bsd.html</a><br>
<br>
<br>
___________________________________________________________<br>
Mike Jackson <a href="http://www.bluequartz.net" target="_blank">www.bluequartz.net</a><br>
Principal Software Engineer <a href="mailto:mike.jackson@bluequartz.net">mike.jackson@bluequartz.net</a><br>
BlueQuartz Software Dayton, Ohio<br>
<div><div></div><div class="h5"><br>
On Apr 24, 2011, at 8:20 PM, AJ ONeal wrote:<br>
<br>
> What's the preferred solution to the OS X getline problem (meaning that it doesn't exist in OS X's libc) when using CMake?<br>
> ("Don't use getline" isn't an option)<br>
><br>
><br>
> I'd like to have an explanation of the solution and see an example which employs it.<br>
><br>
><br>
> This is my first time I've tried to compile my Linux code on OS X, so I don't know anything about how to specify the "do this with os xyz and do this with os abc" options.<br>
><br>
> AJ ONeal<br>
</div></div>> _______________________________________________<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>
<br>
</blockquote></div><br></div>