[CMake] Inconsistent lib dependancie/name for libnames with dots

Bastian Moldenhauer bastianmoldenhauer at web.de
Sat Oct 23 10:45:16 EDT 2010


Hi,


>On 23.10.10 14:01:04, Bastian Moldenhauer wrote:
>> I think I found a bug in cmake, but since I am a bloody beginner with 
>> cmake don't hit me when I am wrong.
 
>Either you're wrong or your posted sample is :)

Wups, ok. The sample is broken. Sometimes double checking is not enough :-)

>> If  I add a library using add_library(.) and the name of the lib 
>> contains a dot cmake will produce some wrong dependencies or use a 
>> wrong lib output name.
>> 
>> How to reproduce:
>> 
>> 1.       Create a folder "b"
>> 
>> 2.       Put a file "b.c" in "b"
>> 
>> 3.       Create a cmakelist with this content in "b"
>> 
>> FILE(GLOB src "*.c")
>> 
>> ADD_LIBRARY(b ${src})

>Note that this line above creates a target called 'b' which will build a
library called "b.lib".

I undersand that. Just use this line instead:
ADD_LIBRARY(b.b ${src})

>> 4.       Create a folder "e"
>> 
>> 5.       Put a file "e.c" in "e"
>> 
>> 6.       Create a cmakelist with this content in "e"
>> 
>> FILE(GLOB src "*.c")
>> 
>> ADD_EXECUTABLE(e ${src})
>> 
>> TARGET_LINK_LIBRARIES(e b.b)

>This tries to link the target e against a target named 'b.b'. But this
target doesn't exist. Hence cmake assumes this is the name of a library
provided outside of the project and append ".lib" to it.

>> 7.       In the parentfolder of "e" and "b" place a cmaklist with this
>> content
>> 
>> cmake_minimum_required(VERSION 2.8)
>> 
>> project(Prj)
>> 
>l add_subdirectory(b)
>> 
>> add_subdirectory(e)
>> 
>>  
>> 
>> Result:
>> 
>> If you do the above and let cmake create the project files (vs2010 and
>> vs2008 in my case) cmake will create a solution that want work. The 
>> reason is pretty simple. The executable will be dependent on a lib 
>> called b.b.lib which is correct. But the lib will never be created 
>> because project b.b will create a lib which is named "b.lib".

>If you want to create a library called 'b.b' you should pass that as target
name to add_library. At least on unix this creates a correct dependency.

>Andreas

Thanks and regards,
Basti



More information about the CMake mailing list