I have an embedded C application with static libraries, where both the application and lib1
use lib2
. (lib2
is not part of lib1
’s interface.)
If my CMakeLists.txt includes something like this:
add_executable(app app.c)
add_library(lib1 STATIC lib1.c)
add_library(lib2 STATIC lib2.c)
target_link_libraries(app PRIVATE lib1)
target_link_libraries(app PRIVATE lib2)
target_link_libraries(lib1 PRIVATE lib2)
Will the build process necessarily deduplicate all linked code? In other words, is there any chance of duplicate code in the final compiled executable, if e.g. both app
and lib1
call the same function from lib2
?