My project consists of three static libraries (A, B, and C) and one executable (D). D depends on B and C, while C depends on A and B. A, B and C large libraries (500k lines of code in total). In the past, the three libraries were compiled as shared objects, but were switched to static because of performance issues and bugs. My CMakeLists.txt
looks like this:
add_library(A)
add_library(B)
add_library(C)
add_executable(D)
target_link_libraries(D PRIVATE libSomeLib.so C B A)
When I modify one source file (.cpp
) from D, the entire executable has to be relinked. Ninja is smart enough to only recompile the modified source file. This edit-compile-run cycle lasts 15 seconds out of which 10 are spent in linking.
I have already implemented precompiled headers which seem to shorten this cycle. I already tried using incremental linking as asked in this question, but I couldn't get it to work in my case.
I am worried that I waste a lot of time while waiting for the linker. I would like to know whether these times are normal and if the architecture of this project is optimal. How would you implement something like this that doesn't take too long to link?