Hi all,

I have a CMake library project which contains multiple child CMake projects, 
each of which produces a single static library.

I want the output of the parent project to be a single static library, 
containing all of the child libraries.  I have spent a while researching, and 
found a number of suggestions and implementations of cmake functions/macros to 
do the merging online such as the ones from 
https://www.mail-archive.com/cmake@cmake.org/msg28670/libutils.cmake, 
https://github.com/EddieRingle/erbium/blob/master/scripts/cmake/modules/MergeStaticLibs.cmake,
 https://github.com/FreeRDP/FreeRDP/blob/master/cmake/MergeStaticLibs.cmake.

After setting CMP0026 to OLD, I was able to successfully generate a Visual 
Studio Project using CMake and the last Modelon implementation.  This project 
however, does not contain the references to the other projects in the solution 
to maintain the build order.  If I try and build the project for the main 
combined library, it immediately complains that the libraries it's trying to 
combine don't exist.  If I manually modify the project to add the reference to 
the others and then build, Visual Studio correctly builds the dependencies and 
then combines them.

I tried a number of approaches in the CMake files to try and force a dependency 
for the combined library on the others, but I don't seem to be able to get the 
dependency correctly carrying through to visual studio.  I tried 
add_dependencies(${combined} ${libs}), I tried add_custom_command(${combined} 
DEPENDS ${libs}), I tried changing the declaration of the library from 
add_library(${combined} STATIC ${dummy_file}) to be add_custom_target() instead 
but no joy.

I see a lot of mentions online of Object Libraries, but the child CMake 
projects are also used in other projects so I can't easily go in and modify 
them without also impacting others.

I understand that, normally, linking static libraries is an unusual thing to do 
and so that's likely why CMake is ignoring my attempts, but can anyone suggest 
a way to achieve what it is I'm attempting?

Thanks,
Rich
-- 

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

Reply via email to