Building static and shared lib variants I'm working on a C++ library. It's working great on Windows and Linux, and I bought a mac to start a port to MacOS X. Been playing with Xcode to get my feet wet. I don't think I can adopt the paradigm I want to but am hoping I'm wrong.
Philosophy:
A library can be built as static or shared. For any given application, it's up to the developer to decide which flavor makes the most sense, particularly so when the library is something new that may not yet merit shared library status, so to speak.
Based on this philosophy, take the windows project setup for example. The library doesn't have the classic Debug/Release confiiguration pair, but rather four configurations: DLLDebug, DLLRelease, LibDebug, LibRelease. The core library project has two targets: the library, and the unit test application. If the DLLDebug configuration is selected, building the unit test application has a dependency on and links against the debug shared library. On the other hand, if the LibRelease configuration is selected, the unit test app depends on and links against the release static library. There are two more permutations of course.
Is such an approach feasible? Playing with the configurations in XCode, it looks like I can create the four configurations, but the dependencies can't be isolated on a per-configuration basis.
Dependencies are just the start of it. The executable must link against a static or shared library, and it looks like for a given target, regardless of configuration, there's no way to set "Link Binary With Libraries" on a per-configuration basis. It looks like I can add MyLib.dylib or MyLib.a, but that would apply to the app for all configurations, with the Debug/Release distinction being automatic.
Next, there's the target itself. Ideally, I'd want a MyLib target, and whether the actual target is Debug/MyLib.dylib, Debug/MyLib.a, Release/MyLib.dylib or Release/MyLib.a would depend on what configuration is selected. Right now it looks like the only way to do this is to have a dynamic lib target and a separate shared lib terget (two separate targets). Not a huge deal, except that the list of source files for the two targets (Compiled Sources folder) would end up being identical but have to be maintained in parallel manually. It would be nice to have a single target with four configurations rather than two targets and two configurations.
Lastly, there's the build output folder. If I build an app and a library, they show up in build/Debug or build/Release. Not a big deal on the surface: Debug/MyLib.dylib and Debug/MyLib.a can coexist in the same folder. But the dynamic and shared flavors of application can't coexist in Debug and likewise for Release. It would be nice if the output folder could diverge into DynDebug, DynRelease, LibDebug, and LibRelease, with both application and library targets appearing in the correct folder. And the link-time dependency for the application would go along with the configuration.
Is there a way to set up an XCode project to generate outputs as I've described?
Thanks,
Brian |