[CMake] Compiling OpenGL application with CMake
Andrea Tagliasacchi
ata2 at cs.sfu.ca
Thu Feb 19 20:18:38 EST 2009
Hello everybody,
I have given up on Makefiles, implicit rules and unreadability just annoyed
me.
Also the ability of generating cross platform compile files is very
appealing.
As far as I compile my independent code (no external libraries)
everything goes fine. However, one of my applications is a simple
OpenGL based visualizer and I am having problems finding the correct
set of setting of the CMakeLists.txt.
Right now I hacked a *temporary solution* that compiles that file
in an architecture dependent way:
find_package(GLUT)
find_package(OpenGL)
IF(APPLE)
SET(CMAKE_CXX_LINK_FLAGS "-framework OpenGL -framework GLUT")
ADD_EXECUTABLE(mesh_view mesh_view.cpp)
ENDIF(APPLE)
Browsing around I was able to construct the following but I am still getting
linking errors as reported below:
find_package(GLUT)
find_package(OpenGL)
if (OPENGL_FOUND)
MESSAGE("OpenGL Correctly Found")
include_directories(${OPENGL_INCLUDE_DIR})
else (OPENGL_FOUND)
MESSAGE("OpenGL environment missing")
endif (OPENGL_FOUND)
Example of linking errors:
Linking CXX executable mesh_view
Undefined symbols:
"_glViewport", referenced from:
reshapeCallback(int, int)in mesh_view.cpp.o
"_glMaterialfv", referenced from:
displayCallback() in mesh_view.cpp.o
"_glLoadIdentity", referenced from:
init_opengl() in mesh_view.cpp.o
motionCallback(int, int)in mesh_view.cpp.o
displayCallback() in mesh_view.cpp.o
I also checked the CMake files of OpenSceneGraph
but I can find only include directory specifications, no linking.
Browsing around I also found the following but even if I add them nothing
changes:
INCLUDE(${CMAKE_ROOT}/Modules/FindOpenGL.cmake)
SET(CMAKE_REQUIRED_LIBRARIES ${GLUT_LIBRARY} ${GL_LIBRARY})
LINK_DIRECTORIES(${OPENGL_LIBRARIES})
Any suggestion?
Really appreciated.
--
Andrea Tagliasacchi
Ph.D. Candidate
School of Computer Science
Simon Fraser University
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090219/b8697096/attachment-0001.htm>
More information about the CMake
mailing list