[CMake] Creating a library from subdirectories
Mueller-Roemer, Johannes Sebastian
Johannes.Sebastian.Mueller-Roemer at igd.fraunhofer.de
Wed Nov 26 07:52:36 EST 2014
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-roemer at igd.fraunhofer.de | www.igd.fraunhofer.de
From: Mueller-Roemer, Johannes Sebastian
Sent: Wednesday, November 26, 2014 13:50
To: 'Chris Johnson'; cmake at 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-roemer at igd.fraunhofer.de<mailto:johannes.mueller-roemer at igd.fraunhofer.de> | www.igd.fraunhofer.de<http://www.igd.fraunhofer.de>
From: CMake [mailto:cmake-bounces at cmake.org] On Behalf Of Chris Johnson
Sent: Wednesday, November 26, 2014 01:36
To: cmake at cmake.org<mailto:cmake at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20141126/1af7f625/attachment.html>
More information about the CMake
mailing list