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