-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi all,
I have a project that consists of a library and an application that are developed as two separated projects (different repos, separate cmake setups, etc.). Let's call them "lib" and "app". The app exports itself to ~/.cmake/ and creates a appTargets.cmake, the app simply does find_package(lib). For several reasons, we must be able to build the app dynamically and statically. Our current approach is based on a flag "STATICLIB_SWITCH" that exists in the lib and in the app. Based on it's value, we build the library as .a or .so and link the app statically or dynamically. However, there are a few drawbacks: The value of the switch has to be consistent for the lib and the app and we didn't quite manage to correctly search for all libs: The linker command line is cluttered with lots of -rdynamic etc, which also occasionally breaks down and is very hard to debug when it does. So I spent some time on this and it seems that this is meant to be done differently. My new setup looks like this: The lib has two targets, for a shared object and for a static object, that are always built and exported. The app includes whatever it needs. This would remove the switch from the lib, which would be very nice. However, it seems that the app always includes the "shared target", no matter what I do. Also, I have not been able to provide the target with the list of libraries necessary: I simply collect all libraries in a variable that are found by other find_package calls, but find_package will only find either the shared or the static versions... So basically my question is: How is this supposed to be done? (I somehow get the feeling, that both attempts are wrong :-) ) How can I use a library in another application and switch (fairly) easily between static and dynamic linking? Thanks for any hints on this! Gereon -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBAgAGBQJUGE65AAoJEIQ2nMX673HfLL0H/RcCrNRKdLVQaaIfJnICKCiw 5RaE6t8PXxCjD+XPBgQOmdDVOKXAy/f/t7gV1T6yRDvvbgbUyQnTpRoWUL0Qjlos J+qob54Lcm90DTglNkpnImbfdBRv3XPDS34AGA20kgkmSDVsTdhg1fjDf5Cb10f7 UlGySIQqiIWSuygiq5uawswxqQuh6VuL98/vY+vxCkjNbLnWzuvCAT5x692qaFH3 M7JI4P/SWii637z/7sMh9e+mHue6MBynrcff2PUhDNCyIiG9MiQbZfzsvcQoKYSO jDZLTvSvmy8FUPXPH+15Z8MyfjqjksErLX4UbOBFeEQ5FJwtA+G9TRYHzlDS9vc= =AfDK -----END PGP SIGNATURE----- -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake-developers