Quantcast

single static library from many subdirectories

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

single static library from many subdirectories

Reuben Kraft
Hello,

I was reading this page about how to make a single library from many subdirectories using object files: 

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


--

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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: single static library from many subdirectories

Robert Maynard
Instead of having a per directory CMakeLists.txt you can do something
like the following.

add_library(eema STATIC sub-dir-a/file1.cpp  sub-dir-b/file2.cpp)

On Tue, Apr 11, 2017 at 11:43 AM, Reuben Kraft <[hidden email]> wrote:

> 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
>
>
> --
>
> 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
--

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
Loading...