cmake-example-library icon indicating copy to clipboard operation
cmake-example-library copied to clipboard

What if multiple libraries within one project?

Open WilliamCodeBox opened this issue 5 years ago • 1 comments

Good job on this CMake based c++ template project. I have been developing a C++ project which contains multiple libraries, and I intend to use this template repo.

My project layout now looks like following:

|── include
│   ├── lib1_headers
│   ├── lib2_headers
│   ├── lib3_headers
└── source
    ├── lib1_srcs
    ├── lib2_srcs
    ├── lib3_srcs

What is the proper way to use this repo and set up my project? Hope your help...

WilliamCodeBox avatar Aug 19 '20 00:08 WilliamCodeBox

Yes, this example is one library per one project at the moment. I was thinking to extend it to multiple libraries.

The code that configure the library is here: https://github.com/pablospe/cmake-example-library/blob/master/cmake/LibraryConfig.cmake

Basically this code should be a function, and be called per library. Not sure about the alias part. Also I believe the FOO_DEBUG should be move SetEnv.cmake perhaps. Perhaps you could give a try to generate this code as function in PR.

Could you comment more about your project structure? How do you want to use it externally? Something like "Foo::lib1"? I am trying to understand why you need multiple libraries. You could also check in the object libraries and expose one to the external. More about object libraries: https://gitlab.kitware.com/cmake/community/-/wikis/doc/tutorials/Object-Library

pablospe avatar Aug 19 '20 09:08 pablospe