Sorry overread the last point in your mail. I don’t believe there is a way to avoid this directly. What you seem to want is what Xcode calls a prelinked library (http://cocoadev.com/SingleObjectPrelink) . CMake does not have such an option as far as I know
-- Johannes S. Mueller-Roemer, MSc Wiss. Mitarbeiter - Interactive Engineering Technologies (IET) Fraunhofer-Institut für Graphische Datenverarbeitung IGD Fraunhoferstr. 5 | 64283 Darmstadt | Germany Tel +49 6151 155-606 | Fax +49 6151 155-139 johannes.mueller-roe...@igd.fraunhofer.de | www.igd.fraunhofer.de From: Mueller-Roemer, Johannes Sebastian Sent: Wednesday, November 26, 2014 13:50 To: 'Chris Johnson'; cmake@cmake.org Subject: RE: [CMake] Creating a library from subdirectories In the example on that site an OBJECT library is created (the output consists of multiple .obj files), you used STATIC libraries instead (which each output a single .lib) -- Johannes S. Mueller-Roemer, MSc Wiss. Mitarbeiter - Interactive Engineering Technologies (IET) Fraunhofer-Institut für Graphische Datenverarbeitung IGD Fraunhoferstr. 5 | 64283 Darmstadt | Germany Tel +49 6151 155-606 | Fax +49 6151 155-139 johannes.mueller-roe...@igd.fraunhofer.de<mailto:johannes.mueller-roe...@igd.fraunhofer.de> | www.igd.fraunhofer.de<http://www.igd.fraunhofer.de> From: CMake [mailto:cmake-boun...@cmake.org] On Behalf Of Chris Johnson Sent: Wednesday, November 26, 2014 01:36 To: cmake@cmake.org<mailto:cmake@cmake.org> Subject: [CMake] Creating a library from subdirectories This CMake wiki page (http://www.cmake.org/Wiki/CMake/Tutorials/Object_Library) claims one can create a library from subdirectories containing libraries, which is exactly what I want to do. However, it doesn't seem to work. Here's my SSCCE (http://sscce.org) "toy" example file structure: . |-- CMakeLists.txt |-- component1/ | |-- CMakeLists.txt | `-- c1.c |-- component2/ | |-- CMakeLists.txt | `-- c2.c `-- dummy.c ## Here's the top level CMakeLists.txt, per example from Wiki: cmake_minimum_required(VERSION 2.8.4) project(lib) add_subdirectory(component1) add_subdirectory(component2) add_library(lib dummy.c) target_link_libraries(lib component1 component2) ## The subdirectory CMakeLists.txt files contain effectively just: add_library(component1 STATIC c1.c) ## and add_library(component2 STATIC c2.c) ## The resulting library file liblib.a contains only the dummy placeholder, but none of the subdirectory content: lib$ ar tv liblib.a rw-r--r-- 502/20 696 Nov 25 18:23 2014 dummy.c.o ## Is there some way to make this work? * Ideally, I would not even need the dummy.c placeholder, but I can live with that. * I do not want to list all of the source files in the top level CMakeLists.txt file. * I do not want to use the add_library(component1 OBJECT ${component1_sources}) and add_library(toplevel $<TARGET_OBJECTS:component1> ... ) syntax if it can be avoided. The reasons for my limitations is that to the greatest extent possible, I am generating CMakeLists.txt files via automation which needs to use a sort of a least-common-denominator approach to building those files. ..chris
-- 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