[CMake] single static library from many subdirectories

Reuben Kraft reuben.kraft at gmail.com
Tue Apr 11 11:43:17 EDT 2017


Hello,

I was reading this page about how to make a single library from many
subdirectories using object files:
https://cmake.org/Wiki/CMake/Tutorials/Object_Library

It is exactly what I want to do but my problem is that I do not have any
source files in my "top directory" they are all in the subdirectories. I
have something like this:

top-dir
--CMakeLists.txt
------sub-dir-a
--------------CMakeLists.txt
--------------file1.cpp
------sub-dir-b
--------------CMakeLists.txt
--------------file2.cpp

However, I get the follow error message when I run cmake:

You have called ADD_LIBRARY for library eema without any source files. This
typically indicates a problem with your CMakeLists.txt file.

Is there a way to do this without haveing any source files in the top
directory?

Thanks,

Reuben
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20170411/5be4db48/attachment.html>


More information about the CMake mailing list