[CMake] How to build just one library from a source directory hierarchy

Gagnon, Joseph - 0553 - MITLL Joseph.Gagnon at ll.mit.edu
Tue Jun 30 14:35:36 EDT 2015


I have a small C++ project for which the source code is distributed in a
small directory hierarchy.  I have a "master" CMakeLists.txt file at the
project root as well as one for each source subdirectory. How would I
configure the CMakeLists.txt files so that the build produces a single
library file that comprises the entire hierarchy?  I am using CMake 3.2.2
that came bundled with JetBrains CLion 1.0.4.  The software is being
developed on CentOS 6.6.

 

I have tried to find out how this might be done by looking at various links
on the CMake wiki and in the cmake documentation, but haven't had any luck
getting something to work.  The files I have currently build a library file
at each directory, which is not what I want.

 

I saw an option to the add_library() command where you could define the
library as an "object" library.  This sounds like what I would need, but
when I added the OBJECT token to the call, CMake complained:

 

Error:Target llxcc has dependency information when it shouldn't.

Your cache is probably stale. Please remove the entry

  llxcc_LIB_DEPENDS

from the cache.

 

I'm not sure what this means.  I looked in the cache view and found the
entry referred to, but it had no value.

 

Any suggestions on how to do this would be appreciated.

 

Thanks,

Joseph Gagnon

 

Engineer II

Group 53 - Secure Resilient Systems and Technology

MIT Lincoln Laboratory

Lexington, MA

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150630/129d8d60/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 5625 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150630/129d8d60/attachment.bin>


More information about the CMake mailing list