Freeglut-3.0.0 is build with cmake (MinGW makefiles) and mingw and then successfully installed with mingw32-make install
to C:/Program Files (x86)/freeglut
.
My CMakeLists.txt
is:
cmake_minimum_required(VERSION 3.7)
project(math_tests)
set(TESTS_SOURCES tests.cpp gl_core_3_3.c)
set(CMAKE_CXX_STANDARD 11)
# GLUT
find_package(GLUT REQUIRED)
include_directories(${GLUT_INCLUDE_DIR})
if(NOT GLUT_FOUND)
message(ERROR "GLUT not found!")
endif(NOT GLUT_FOUND)
# OpenGL
find_package(OpenGL REQUIRED)
include_directories(${OpenGL_INCLUDE_DIRS})
link_directories(${OpenGL_LIBRARY_DIRS})
add_definitions(${OpenGL_DEFINITIONS})
if(NOT OPENGL_FOUND)
message(ERROR "OPENGL not found!")
endif(NOT OPENGL_FOUND)
add_executable(tests ${TESTS_SOURCES})
target_link_libraries(tests math ${GLUT_LIBRARIES} ${OPENGL_LIBRARIES})
Now CMake prints error: Could NOT find GLUT (missing: GLUT_glut_LIBRARY).
I can't figure out what I am doing wrong.
Your CMakeLists.txt file statement
find_package(GLUT REQUIRED)
is going to execute this code from FindGLUT.cmake
find_library( GLUT_glut_LIBRARY NAMES glut glut32 freeglut
PATHS
${OPENGL_LIBRARY_DIR}
${GLUT_ROOT_PATH}/Release
)
and find_library
is in your scenario unable to find any of glut glut32 freeglut
libraries, because it doesn't know where they are (which for you are under C:/Program Files (x86)/freeglut
).
In your case you could set ${OPENGL_LIBRARY_DIR}
to the right directory, that is the one containing the freeglut.dll file, for e.g.:
set(OPENGL_LIBRARY_DIR "C:/Program Files (x86)/freeglut/lib")
given the file is under C:/Program Files (x86)/freeglut/lib
directory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With