[CMake] include dependecy problem
Michael Wild
themiwi at gmail.com
Mon May 18 05:48:14 EDT 2009
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
More information about the CMake
mailing list