[CMake] CMAKE 2.8.9, OS X 10.8 and OpenGL
Benjamin Eikel
cmake at eikel.org
Wed Aug 15 18:02:05 EDT 2012
Hello,
for me, the following file works
--- BEGIN CMakeLists.txt
cmake_minimum_required (VERSION 2.8.9)
project(Test)
SET(CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++")
find_package(OpenGL REQUIRED)
include_directories(${OPENGL_INCLUDE_DIR})
find_package(GLUT REQUIRED)
include_directories(${GLUT_INCLUDE_DIR})
add_executable(Test main.cpp)
target_link_libraries(Test ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES})
--- END CMakeLists.txt
when changing the includes to
#include <cstdlib>
#include <GL/glut.h>
#include <GL/glext.h>
#include <GL/gl.h>
#include <GL/glu.h>
On OS X, these might be correct the way you specified them.
Kind regards
Benjamin
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})
>
> 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