CMake: build app and dependent library
(Forgive me if this is a duplicate, but I’m not seeing answers for the case where the library is my own work in progress, rather than an established package.)
I wrote a C++ library. I wrote several apps that depend upon that library. The library and some of those apps may one day be published to the open source world. The library is still under development.
Here’s the directory structure I would like to use:
Programs
/ |
Lib AppA AppB ...
Here’s the logic I want to use: if I build in directory AppA, it builds Lib if out of date, and then builds AppA (but does nothing about AppB). Similarly if I’m in AppB.
I don’t want to view Programs as a project to be built in its own right, but only as an overarching collection.
I have read instructions on how to do this if the library code is mixed up in AppA or is in a subdirectory of it, but I don’t want that. So what is the best way to structure the various CMakeLists.txt files for my situation? Is it wise to use add_subdirectory if it’s not actually a subdirectory, but a sibling? (I haven’t yet decided if the library will be static or shared, and I’m curious if it actually makes a difference for these purposes.)
3