[CMake] how to build library for this..
ankit jain
ankitguddu at gmail.com
Fri Jan 30 04:34:15 EST 2009
Thanks for all the help its working.
Regards-
ankit jain
2009/1/30 Philip Lowman <philip at yhbt.com>
> On Thu, Jan 29, 2009 at 11:38 PM, ankit jain <ankitguddu at gmail.com>wrote:
>
>>
>>
>> 2009/1/29 Pau Garcia i Quiles <pgquiles at elpauer.org>
>>
>>> On Thu, Jan 29, 2009 at 1:12 PM, ankit jain <ankitguddu at gmail.com>
>>> wrote:
>>> > hi all,
>>> >
>>> > Problem:
>>> >
>>> > libA : A/foo.cc
>>> > libB : B/bar.cc
>>> > and a 3rd library:
>>> > libC : A/foo.cc B/bar.cc
>>> > ?
>>> >
>>> > here i build the libraries for A and B but not able to build lib for C
>>> .
>>> > Guide me to do that. What should be the content of cmakelist file of C
>>> to
>>> > create lib C
>>> >
>>> > here A and B are sub folders of C
>>>
>>> Do you ean you are trying this but it's not working?
>>>
>>> ADD_LIBRARY (libA A/foo.cc )
>>> ADD_LIBRARY (libB B/bar.cc )
>>> ADD_LIBRARY (libC libA libB )
>>>
>>> That fails because CMake does not support convenience libraries:
>>>
>>> http://www.cmake.org/Wiki/CMake_FAQ#Does_CMake_support_.22convenience.22_libraries.3F
>>>
>>> You need to do this:
>>>
>>> ADD_LIBRARY (libA A/foo.cc )
>>> ADD_LIBRARY (libB B/bar.cc )
>>> ADD_LIBRARY (libC A/foo.cc B/bar.cc )
>>>
>>> I. e. list the source files for libC
>>>
>>> Is that what you want to do?
>>>
>>
>> Dont you think so it will be too hectic if there are 10 folders inside
>> folder C and each folder has around 10 C files each. then listing all will
>> be really cumbersome.
>> What should be the alternative for it.
>>
>
> Here's one idea, in A and B set a variable with all of the source files and
> add them to the PARENT_SCOPE.
>
> set(A_SRCS a.cc)
> set(A_SRCS ${A_SRCS} PARENT_SCOPE)
> add_library(A ${A_SRCS})
>
> Then in the higher directory, use a foreach() loop to construct a proper
> relative path to each source file:
>
> foreach(fname ${A_SRCS})
> list(APPEND C_SRCS A/${fname})
> endforeach()
> foreach(fname ${B_SRCS})
> list(APPEND C_SRCS B/${fname})
> endforeach()
> add_library(both ${C_SRCS})
>
> --
> Philip Lowman
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090130/1284503e/attachment.htm>
More information about the CMake
mailing list