[CMake] CMake Library Issues

Nick Ogden nick at nickogden.net
Wed Feb 4 05:07:05 EST 2009


Thanks for your help.

It seems that the library cannot be compiled as static, when I tried it as 
dynamic it worked without a problem. I assume that this is due to the <> style 
includes as there wouldn't be a search path for a static library since it's 
part of the executable.

Could anyone tell me what the requirements are for static vs dynamic 
compilation?

On Wednesday 04 February 2009 01:34:56 Matthew Woehlke wrote:
> 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.

-- 
Nick Ogden

Email: nick at nickogden.net      PGP: 2598FFE4
Web:   www.nickogden.net
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090204/b2ba8577/attachment-0001.pgp>


More information about the CMake mailing list