perhaps include_directories(..)
That's how I do it.
You can also print the

${SERVER_SOURCE_DIR}

variable.
MESSAGE("SERVER_SOURCE_DIR is ${SERVER_SOURCE_DIR}")
Let me know if this works.

Nick Ogden wrote:
> Hi there,
>
> I have a problem with using CMake to compile a library that I'm trying to use 
> in an application that I'm writing.
>
> I have the following directory structure:
>
> src/
>   |---- CMakeLists.txt (1)
>   |---- app/
>   |       |---- CMakeLists.txt (2)
>   |       |---- (app source and headers)
>   |---- libmba/
>   |       |---- CMakeLists.txt (3)
>   |       |---- mba
>   |       |        |---- (libmba headers)
>   |       |---- (libmba source)
>
> The problem occurs when compiling the library. Make states that it cannot 
> find 
> a header file for the library, which is definitely in the 'mba' directory. 
> The 
> problem seems to be that the library uses '#include <mba/XXXX>' style 
> statements in the header files and as such expects the search path to start 
> in 
> the 'libmba' directory. Since some header files include other header files, 
> make 
> then seems to look for the directory 'src/libmba/mba/mba' which of course 
> does 
> not exist. Is there any way of preventing this behavior so that the search 
> will always start in the 'libmba' directory?
>
> The error as reported by make and the relevant CMakeLists.txt file is as 
> follows.
>
> Error:
>
> Scanning dependencies of target mba
> [  3%] Building C object libmba/CMakeFiles/mba.dir/allocator.c.o
> In file included from /.../src/libmba/allocator.c:29:
> /.../src/libmba/mba/suba.h:24:27: error: mba/allocator.h: No such file or 
> directory
> make[2]: *** [libmba/CMakeFiles/mba.dir/allocator.c.o] Error 1
> make[1]: *** [libmba/CMakeFiles/mba.dir/all] Error 2
> make: *** [all] Error 2
> --------------------------------------------------------------------------------------------------------------
>
> CMakeLists.txt (3):
>
> set(mba_SRC   allocator.c
>                       bitset.c
>                       cfg.c
>                       csv.c
>                       daemon.c
>                       dbug.c
>                       diff.c
>                       eval.c
>                       hashmap.c
>                       hexdump.c
>                       linkedlist.c
>                       misc.c
>                       msgno.c
>                       path.c
>                       pool.c
>                       shellout.c
>                       stack.c
>                       suba.c
>                       svcond.c
>                       svsem.c
>                       text.c
>                       time.c
>                       varray.c)
>                       
> include_directories(${SERVER_SOURCE_DIR}/libmba)
>
> add_library(mba STATIC ${mba_SRC})
> --------------------------------------------------------------------------------------------------------------
>
> Any help would be greatly appreciated.
>
> Kind Regards
>   
> ------------------------------------------------------------------------
>
> _______________________________________________
> CMake mailing list
> CMake@cmake.org
> http://www.cmake.org/mailman/listinfo/cmake

_______________________________________________
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to