Creating an archive (libcxx.a) when building cxx_shared

When I build cxx_shared I get a libc++.so which is great. I’d like to also get an archive (libc++.a) with the same objects but I don’t see an obvious rule to do this. cxx_static produces an archive but with the statically built objects.

We have this problem on AIX, where shared objects are typical archived, but we have a modified CMake we contains this behaviour. It’d be nice to have this as a general option, but I’m not sure it exists at the moment.

Thanks for letting me know I’m not alone.

Not being an expert in cmake I did something like this:

+
+  set (cxx_shared_objs ${LIBCXX_SOURCES})
+  list(FILTER cxx_shared_objs INCLUDE REGEX ".cpp")
+  list(TRANSFORM cxx_shared_objs APPEND ".o")
+

To get the list to add to the archive and then in a POST_BUILD command I make the archive.