CMake Creating a library of sub-components
-
I’m trying to create a huge library and have decided to modularize that project by developing it component by component so that I can easily test and develop each component separately.
But in the end all these components need to be compiled into one single library.
So my root CMakeLists.txt has a couple ofadd_subdirectory()
calls.
Each sub-component is compiled as a STATIC lib.My challenge now is how do I make the root CMakeLists.txt compile everything into one single lib.
How do I call
add_library()
in such a case? -
I’m trying to create a huge library and have decided to modularize that project by developing it component by component so that I can easily test and develop each component separately.
But in the end all these components need to be compiled into one single library.
So my root CMakeLists.txt has a couple ofadd_subdirectory()
calls.
Each sub-component is compiled as a STATIC lib.My challenge now is how do I make the root CMakeLists.txt compile everything into one single lib.
How do I call
add_library()
in such a case?@tapsbrighton said in CMake Creating a library of sub-components:
How do I call add_library() in such a case?
You put add_library() in each subdirectory.
In the main folder you link all these static libs to your big lib using target_link_libraries after calling add_library for the big library. Don't forget to include the subfolders.