[CMake] CMAKE 2.8.9, OS X 10.8 and OpenGL

Benjamin Eikel cmake at eikel.org
Wed Aug 15 17:45:41 EDT 2012


Hello Jason,

Am Mittwoch, 15. August 2012 um 23:29:16 schrieb Jason T. Slack-Moehrle:
> Hello All,
> 
> I am new to CMAKE and attempting to build an OpenGL app on OS X 10.8.
> (I will be using other platforms as well)
> 
> My CMakeLists.txt:
> 
> cmake_minimum_required (VERSION 2.8.9)
> 
> SET(CMAKE_C_COMPILER "clang")
> SET(CMAKE_CXX_COMPILER "clang++")
> SET(CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++")
> 
> IF(APPLE)
>    INCLUDE_DIRECTORIES ( /System/Library/Frameworks )
>    FIND_LIBRARY(COCOA_LIBRARY Cocoa)
>    FIND_LIBRARY(GLUT_LIBRARY GLUT )
>    FIND_LIBRARY(OpenGL_LIBRARY OpenGL )
>    MARK_AS_ADVANCED (COCOA_LIBRARY
>                      GLUT_LIBRARY
>                      OpenGL_LIBRARY)
>    SET(EXTRA_LIBS ${COCOA_LIBRARY} ${GLUT_LIBRARY} ${OpenGL_LIBRARY})
> ENDIF (APPLE)
> #target_link_libraries(Test ${EXTRA_LIBS})

for OpenGL, better use the shipped find module (see "cmake --help-module 
FindOpenGL"):

find_package(OpenGL REQUIRED)
include_directories(${OPENGL_INCLUDE_DIR})
[...]
target_link_libraries(Test ${OPENGL_LIBRARIES})

Furthermore, I suggest using an out-of-source build. I cannot answer your 
other question. On my Linux system I do not get these error messages.

Kind regards
Benjamin

> 
> project(Test)
> add_executable(Test main.cpp)
> 
> My sample code:
> 
> #include <iostream>
> #include <thread>
> 
> #include <stdlib.h>
> 
> #include <GLUT/glut.h>
> #include <OpenGL/glext.h>
> #include <OpenGL/gl.h>
> #include <OpenGL/glu.h>
> 
> void display(void)
> {
>     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
> 
>     glutSwapBuffers();
> }
> 
> void reshape(int width, int height)
> {
>     glViewport(0, 0, width, height);
> }
> 
> void idle(void)
> {
>     glutPostRedisplay();
> }
> 
> int main(int argc, char** argv)
> {
>     glutInit(&argc, argv);
> 
>     glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
>     glutInitWindowSize(640, 480);
> 
>     glutCreateWindow("GLUT Program");
> 
>     glutDisplayFunc(display);
>     glutReshapeFunc(reshape);
>     glutIdleFunc(idle);
> 
>     glutMainLoop();
>     return EXIT_SUCCESS;
> }
> 
> and I am getting the following:
> 
> $ cmake .
> CMake Error: Error required internal CMake variable not set, cmake may
> be not be built correctly.
> Missing variable is:
> CMAKE_FIND_LIBRARY_PREFIXES
> CMake Error: Error required internal CMake variable not set, cmake may
> be not be built correctly.
> Missing variable is:
> CMAKE_FIND_LIBRARY_SUFFIXES
> CMake Error: Error required internal CMake variable not set, cmake may
> be not be built correctly.
> Missing variable is:
> CMAKE_FIND_LIBRARY_PREFIXES
> CMake Error: Error required internal CMake variable not set, cmake may
> be not be built correctly.
> Missing variable is:
> CMAKE_FIND_LIBRARY_SUFFIXES
> CMake Error: Error required internal CMake variable not set, cmake may
> be not be built correctly.
> Missing variable is:
> CMAKE_FIND_LIBRARY_PREFIXES
> CMake Error: Error required internal CMake variable not set, cmake may
> be not be built correctly.
> Missing variable is:
> CMAKE_FIND_LIBRARY_SUFFIXES
> -- Configuring incomplete, errors occurred!
> 
> Can anyone help me see my error?
> --
> 
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake


More information about the CMake mailing list