[CMake] CMake Library Issues

Michael Jackson mike.jackson at bluequartz.net
Wed Feb 4 07:19:11 EST 2009


I don't think the style of include paths has anything to do with  
whether or not the library will compile as a static or dynamic library.

What is the output of:
MESSAGE("SERVER_SOURCE_DIR is ${SERVER_SOURCE_DIR}")

Please post that to the list.

_________________________________________________________
Mike Jackson                  mike.jackson at bluequartz.net
BlueQuartz Software                    www.bluequartz.net
Principal Software Engineer                  Dayton, Ohio



On Feb 4, 2009, at 5:07 AM, Nick Ogden wrote:

> 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
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake



More information about the CMake mailing list