include not found, how to fix with cmake?

2.2k views Asked by At

there my CMakeLists.txt :

cmake_minimum_required( VERSION 2.8 )

set (CMAKE_VERBOSE_MAKEFILE ON)

project( a.out )
find_package(OpenGL)
find_package(PkgConfig REQUIRED)
pkg_search_module(GLFW REQUIRED glfw3)
pkg_search_module(CEGUI-GL REQUIRED  CEGUI-0-OPENGL)
pkg_search_module(CEGUI REQUIRED  CEGUI-0)


macro( config_project PROJNAME LIBNAME )
include_directories( ${${LIBNAME}_INCLUDE_DIR} )
target_link_libraries( ${PROJNAME} ${${LIBNAME}_LIBRARIES} )
endmacro()

add_definitions(-std=c++11)
add_executable(a.out src/ConsoleWindow.cc src/camera.cc src/main.cc)
config_project(a.out OPENGL)
config_project(a.out GLFW)
config_project(a.out CEGUI-GL)
config_project(a.out CEGUI)

so, there is PkgConfig for CEGUI-0-OPENGL and CEGUI-0. In CEGUI-0.pc there is:

prefix=/usr
exec_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/include/cegui-0
moduledir=${prefix}/lib/cegui-0.8
datafiles=${prefix}/share/cegui-0

Name: CEGUI-0
Description: The free GUI library for games and multi-media development.
Version: 0.8.2
Libs: -L${libdir} -lCEGUIBase-0
Cflags: -I${includedir} -I${includedir}/cegui

when I run cmake . everything is fine, but in one of my .cc I have :

#include <CEGUI/CEGUI.h>

and when I compil the file I got an error like no such file found... but locate return :

/usr/include/cegui-0/CEGUI/CEGUI.h

what I'm doing wrong ?

2

There are 2 answers

0
The Unholy Metal Machine On BEST ANSWER

some months later...

I think I solved this problem, I changed the line

include_directories( ${${LIBNAME}_INCLUDE_DIR} )

by

include_directories( ${${LIBNAME}_INCLUDEDIR} )

after noticing how includedir is typed in CEGUI-0.pc ...

includedir=${prefix}/include/cegui-0

I don't get the "no file found error" for #include <CEGUI/CEGUI.h> anymore. I will try to do a hell-o world with CEGUI in my program next days. If you have any comment plz do.

0
Danduk82 On

I had the same problem, and did not find a clean solution. I solved like this:

include_directories(${CEGUI_INCLUDE_DIR}/../)

which is probably not the best solution, but enough for me...