Anaphory
Anaphory

Reputation: 6400

cmake finds package, but does not add to include path

I am trying to compile (on FreeBSD, if that matters) a program that uses cmake. The CMakeLists.txt contains the lines

find_package(GLUT REQUIRED)

include_directories(${CMAKE_CURRENT_BINARY_DIR} ${OPENGL32_INCLUDE_DIRS} ${GLUT_INCLUDE_DIRS})

and cmake does not report any errors, but when I run make afterwards, I get

[…]
/usr/bin/c++  -fopenmp -I/path/build -o CMakeFiles/scriptbots.dir/GLView.cpp.o -c /path/GLView.cpp
[…]
In file included from /path/GLView.cpp:2:
/path/GLView.cpp:10:21: error: GL/glut.h: No such file or directory
[…]

GL/glut.h exists in /usr/local/include, which is not given as -I argument to /usr/bin/c++.

Compiling works when I explicitly add -I/usr/local/include to CMakeFiles/scriptbots.dir/flags.make. What do I need to change to make the project compile without manually changing the flags file?

Upvotes: 1

Views: 516

Answers (1)

As per its documentation, FindGLUT sets variable GLUT_INCLUDE_DIR, not GLUT_INCLUDE_DIRS. Change this in your CMakeList and it should work.

Upvotes: 2

Related Questions