[CMake] Extending a target??

Doug Reiland dreiland at gmail.com
Wed Jun 2 13:57:10 EDT 2010


It all goes back to how a current Makefile for a library is setup.
I need a shared and static version of library.

The library includes some objects built my sub-directories. In those
sub-directories, there are unique compile flags, generated files, ...

In the past, those sub-directories would generate a .o and both the
shared and static library include it (link, archive).

This all still works ok in cmake for shared library because you can
just get the sub-directory to generate a share libray and have main
library link it in.

For static library, ... it is a pain.

Doug

On Wed, Jun 2, 2010 at 12:44 PM, Michael Wild <themiwi at gmail.com> wrote:
>
> On 2. Jun, 2010, at 17:51 , Doug Reiland wrote:
>
>> Yeah, I know I can do that.
>> I want to add foo3.c after the add_library() has been done.
>> The example is simple, but it describes what I hope to do.
>>
>>
>> On Wed, Jun 2, 2010 at 11:41 AM, Michael Wild <themiwi at gmail.com> wrote:
>>>
>>> On 2. Jun, 2010, at 16:34 , Doug Reiland wrote:
>>>
>>>> Is there anything to "add to" a target after it is declared?
>>>>
>>>> For example,
>>>>
>>>> add_library(foo STATIC foo1.c foo2.c)
>>>>
>>>> ....
>>>>
>>>> add_some_more(foo foo3.c)
>>>> or
>>>> add_some_more(foo foo3.o)
>>>>
>>>> If not, feasibility on how it could be implemented?
>>>>
>>>> Thanks,
>>>> Doug
>>>
>>> set(SRCS foo1.c foo2.c)
>>> if(SOME_CONDITION)
>>> list(APPEND SRCS foo3.c)
>>> endif()
>>> add_library(foo STATIC ${SRCS})
>>>
>>>
>>> Hope this helps
>>>
>>> Michael
>>>
>
> No, AFAIK there is no way to do so. Perhaps if you explained a bit more why you think you need such a feature we could help you a bit more.
>
> Michael


More information about the CMake mailing list