What if multiple libraries within one project?
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...
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