[CMake] CMake Library Issues

Matthew Woehlke mw_triad at users.sourceforge.net
Tue Feb 3 20:34:56 EST 2009


Nick Ogden wrote:
> Hi there,

I see you found the right list ;-).

(And I will admit I was lazy and didn't read it before on kde-devel, 
which is why I'm just now answering your actual question.)

> 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?
> [snip]
> include_directories(${SERVER_SOURCE_DIR}/libmba)
> add_library(mba STATIC ${mba_SRC})

Hmm... offhand it seems like that should work. You might try running 
'make VERBOSE=1' to see what is being passed to the linker, and also 
check that ${SERVER_SOURCE_DIR} is defined as you expect it to be 
(either add a message(STATUS), or check CMakeCache.txt in your build 
directory). My WAG would be that ${SERVER_SOURCE_DIR} is empty.

If that doesn't help, posting a reduced test case that shows the same 
problem would be useful.

-- 
Matthew
Please do not quote my e-mail address unobfuscated in message bodies.
-- 
Anyone who is capable of getting themselves made President should on no 
account be allowed to do the job. -- The Hitchhiker's Guide to the 
Galaxy (Douglas Adams)



More information about the CMake mailing list