[CMake] include dependecy problem

eial at cs.bgu.ac.il eial at cs.bgu.ac.il
Mon May 18 06:07:23 EDT 2009


On Mon 18 May 12:48 2009 Michael Wild wrote:
> 
> On 18. May, 2009, at 10:42, eial at cs.bgu.ac.il wrote:
> 
> >
> > hello.
> > I'm writing a c++ program under linux and I use cmake 2.6.4 to  
> > manage compilation.
> > in one of the files I need use external include files which resides  
> > in /usr/include/folder_name/, lets call them file1.h and file2.h
> > now if I declare the includes in my file like this:
> > #include <file1.h>
> > #include <file2.h>
> >
> > compilation fails with an error: file1.h: No such file or directory  
> > and error: file2.h: No such file or directory.
> > but when I declare the includes like this:
> > #include <folder_name/file1.h>
> > #include <folder_name/file2.h>
> >
> > compilation goes well. but, if this line exists in file2.h:
> > #include <file1.h>
> >
> > compilation returns this: /usr/include/folder_name/file2.h error:  
> > file1.h: No such file or directory.
> > how can I fix this?
> >
> > thanks
> >
> 
> Hi
> 
> IMHO this is an error in file2.h, which should do
> 
> #include "file1.h"
> 
> or
> 
> #include <folder_name/file1.h>
> 
> However, you can use your first approach together with find_path and  
> include_directories as show below:
> 
> find_path( FOLDER_NAME_PATH file1 PATH_SUFFIXES folder_name )
> 
> if( FOLDER_NAME_PATH )
>    include_directories( ${FOLDER_NAME_PATH} )
> else( FOLDER_NAME_PATH )
>    message( SEND_ERROR " Failed to find file1 or foldername/file1" )
> endif( FOLDER_NAME_PATH )
> 
> 
> Michael
> 

thanks for the input, I can't change the external include file because it won't be portable, that is
how the package comes and that is how it will be in another computer.

apparently, that kinda did the trick, thanks.
btw, what is the variable that holds the computer's main include path? is it CMAKE_INCLUDE_PATH?




More information about the CMake mailing list