[CMake] Build multiple lib

Andrea Galeazzi galeazzi at korg.it
Wed Sep 22 12:19:07 EDT 2010


Citando Michael Wild <themiwi at gmail.com>:

>
> On 22. Sep, 2010, at 12:48 , Andrea Galeazzi wrote:
>
>> Hi everybody,
>> I've got a static lib project in vc6 as follow
>> lib1
>> lib2
>> ......
>> libN
>> MainLib
>>
>> The MainLib doesn't actually have any source but it depends form   
>> all the other projects (lib1,.....,libN) so it builds a static lib   
>> which contains all the ones.
>> Now my problems is how to write a CMakeLists in order to reproduce   
>> both the same build and the same structure of solution in VS 2010   
>> as the original one.
>> Does anybody have any ideas?
>> Cheers
>
> Do you ever *need* lib1..libN except for assembling MainLib? If not,  
>  just drop them, they're useless.
>
> Michael
>
> --
> There is always a well-known solution to every human problem --   
> neat, plausible, and wrong.
> H. L. Mencken
>
>

That's true but how can I then generate a vcprj for each lib? Now my  
filesystem is:
MainLib
     CMakeLists.txt
     +lib1
        CMakeLists.txt
        source1_1
        source1_2
        ........
     +lib2
        CMakeLists.txt
        source2_1
        source2_2
        ........
      ..........
      +libN
        CMakeLists.txt
        sourceN_1
        sourceN_2
        ........

CMakeLists.txt in MainLib has:
add_library(MainLib STATIC )
add_subdirectory(lib1)
...........
target_link_libraries (MainLib lib1)

it produces a right vs solution but it dosen't produce the MainLib.lib



More information about the CMake mailing list