<div class="gmail_quote">On Thu, Feb 19, 2009 at 8:18 PM, Andrea Tagliasacchi <span dir="ltr">&lt;<a href="mailto:ata2@cs.sfu.ca">ata2@cs.sfu.ca</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;">
Hello everybody,<br><br>I have given up on Makefiles, implicit rules and unreadability just annoyed me.<br>Also the ability of generating cross platform compile files is very appealing.<br><br>As far as I compile my independent code (no external libraries)<br>

everything goes fine. However, one of my applications is a simple<br>OpenGL based visualizer and I am having problems finding the correct<br>set of setting of the CMakeLists.txt.<br><br>Right now I hacked a <b>temporary solution</b> that compiles that file <br>

in an architecture dependent way:<br><br><span style="color: rgb(51, 102, 255);">find_package(GLUT)</span><br style="color: rgb(51, 102, 255);"><span style="color: rgb(51, 102, 255);">find_package(OpenGL)</span><br style="color: rgb(51, 102, 255);">

<span style="color: rgb(51, 102, 255);">IF(APPLE)</span><br style="color: rgb(51, 102, 255);"><span style="color: rgb(51, 102, 255);">&nbsp;&nbsp;&nbsp; SET(CMAKE_CXX_LINK_FLAGS &quot;-framework OpenGL -framework GLUT&quot;)</span><br style="color: rgb(51, 102, 255);">

<span style="color: rgb(51, 102, 255);">&nbsp;&nbsp;&nbsp; ADD_EXECUTABLE(mesh_view mesh_view.cpp)</span><br style="color: rgb(51, 102, 255);"><span style="color: rgb(51, 102, 255);">ENDIF(APPLE)</span><br><br>Browsing around I was able to construct the following but I am still getting <br>

linking errors as reported below:<br><br><span style="color: rgb(51, 102, 255);">find_package(GLUT)</span><br style="color: rgb(51, 102, 255);"><span style="color: rgb(51, 102, 255);">find_package(OpenGL)</span><br style="color: rgb(51, 102, 255);">

<span style="color: rgb(51, 102, 255);">if (OPENGL_FOUND)</span><br style="color: rgb(51, 102, 255);"><span style="color: rgb(51, 102, 255);">&nbsp;&nbsp; MESSAGE(&quot;OpenGL Correctly Found&quot;)</span><br style="color: rgb(51, 102, 255);">

<span style="color: rgb(51, 102, 255);">&nbsp;&nbsp; include_directories(${OPENGL_INCLUDE_DIR})</span><br style="color: rgb(51, 102, 255);"><span style="color: rgb(51, 102, 255);">else (OPENGL_FOUND)</span><br style="color: rgb(51, 102, 255);">

<span style="color: rgb(51, 102, 255);">&nbsp;&nbsp; MESSAGE(&quot;OpenGL environment missing&quot;)</span><br style="color: rgb(51, 102, 255);"><span style="color: rgb(51, 102, 255);">endif (OPENGL_FOUND)</span><br style="color: rgb(51, 102, 255);">

<br>Example of linking errors:<br><span style="color: rgb(51, 102, 255);">Linking CXX executable mesh_view</span><br style="color: rgb(51, 102, 255);"><span style="color: rgb(51, 102, 255);">Undefined symbols:</span><br style="color: rgb(51, 102, 255);">

<span style="color: rgb(51, 102, 255);">&nbsp; &quot;_glViewport&quot;, referenced from:</span><br style="color: rgb(51, 102, 255);"><span style="color: rgb(51, 102, 255);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; reshapeCallback(int, int)in mesh_view.cpp.o</span><br style="color: rgb(51, 102, 255);">

<span style="color: rgb(51, 102, 255);">&nbsp; &quot;_glMaterialfv&quot;, referenced from:</span><br style="color: rgb(51, 102, 255);"><span style="color: rgb(51, 102, 255);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; displayCallback()&nbsp;&nbsp;&nbsp;&nbsp; in mesh_view.cpp.o</span><br style="color: rgb(51, 102, 255);">

<span style="color: rgb(51, 102, 255);">&nbsp; &quot;_glLoadIdentity&quot;, referenced from:</span><br style="color: rgb(51, 102, 255);"><span style="color: rgb(51, 102, 255);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; init_opengl()&nbsp;&nbsp;&nbsp;&nbsp; in mesh_view.cpp.o</span><br style="color: rgb(51, 102, 255);">

<span style="color: rgb(51, 102, 255);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; motionCallback(int, int)in mesh_view.cpp.o</span><br style="color: rgb(51, 102, 255);"><span style="color: rgb(51, 102, 255);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; displayCallback()&nbsp;&nbsp;&nbsp;&nbsp; in mesh_view.cpp.o</span><br>

<br>I also checked the CMake files of OpenSceneGraph<br>but I can find only include directory specifications, no linking.<br><br>Browsing around I also found the following but even if I add them nothing changes:<br><span style="color: rgb(51, 102, 255);">INCLUDE(${CMAKE_ROOT}/Modules/FindOpenGL.cmake)</span><br style="color: rgb(51, 102, 255);">

<span style="color: rgb(51, 102, 255);">SET(CMAKE_REQUIRED_LIBRARIES ${GLUT_LIBRARY} ${GL_LIBRARY})</span><br><span style="color: rgb(51, 102, 255);">LINK_DIRECTORIES(${OPENGL_LIBRARIES})</span>&nbsp;</blockquote><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>Any suggestion?</blockquote><div><br>Try TARGET_LINK_LIBRARIES(mesh_view ${OPENGL_LIBRARIES}) <br><br>If it fails to link you can use &quot;make VERBOSE=1&quot; to look at the compiler/linker flags.<br></div></div><br>
-- <br>Philip Lowman<br>