[CMake] Duplicate shared libraries for transitive dependencies
Sergey
slekhano at gmail.com
Tue Jul 23 09:51:31 EDT 2013
Hi,
I have a problem with transitive dependencies --- shared libraries are
repeated at the linking.
For this small project two libraries A and B are repeated at the linking of
main:
*libD.so libB.so libA.so libB.so libA.so*
At the real project I have hundreds of repeated libraries.
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11.2 FATAL_ERROR)
PROJECT(TRANSLINK CXX)
FILE(WRITE ${CMAKE_BINARY_DIR}/a.cpp "extern void b(); void a(){b();}\n")
ADD_LIBRARY(A SHARED a.cpp)
FILE(WRITE ${CMAKE_BINARY_DIR}/b.cpp "extern void a(); void b(){a();}\n")
ADD_LIBRARY(B SHARED b.cpp)
FILE(WRITE ${CMAKE_BINARY_DIR}/c.cpp "extern void b(); void c(){b();}\n")
ADD_LIBRARY(C SHARED c.cpp)
TARGET_LINK_LIBRARIES(C LINK_PRIVATE B A)
FILE(WRITE ${CMAKE_BINARY_DIR}/d.cpp "extern void c(); void d(){c();}\n")
ADD_LIBRARY(D SHARED d.cpp)
TARGET_LINK_LIBRARIES(D LINK_PRIVATE C)
FILE(WRITE ${CMAKE_BINARY_DIR}/main.cpp "extern void d(); extern void a();
extern void b(); int main(){d();a();b();}\n")
ADD_EXECUTABLE(main main.cpp)
TARGET_LINK_LIBRARIES(main LINK_PRIVATE D B A)
Ninja build log:
[1/10] /usr/bin/c++ -DA_EXPORTS -fPIC -MMD -MT CMakeFiles/A.dir/a.cpp.o
-MF "CMakeFiles/A.dir/a.cpp.o.d" -o CMakeFiles/A.dir/a.cpp.o -c a.cpp
[2/10] /usr/bin/c++ -DB_EXPORTS -fPIC -MMD -MT CMakeFiles/B.dir/b.cpp.o
-MF "CMakeFiles/B.dir/b.cpp.o.d" -o CMakeFiles/B.dir/b.cpp.o -c b.cpp
[3/10] : && /usr/bin/c++ -fPIC -shared -Wl,-soname,libA.so -o libA.so
CMakeFiles/A.dir/a.cpp.o && :
[4/10] : && /usr/bin/c++ -fPIC -shared -Wl,-soname,libB.so -o libB.so
CMakeFiles/B.dir/b.cpp.o && :
[5/10] /usr/bin/c++ -DC_EXPORTS -fPIC -MMD -MT CMakeFiles/C.dir/c.cpp.o
-MF "CMakeFiles/C.dir/c.cpp.o.d" -o CMakeFiles/C.dir/c.cpp.o -c c.cpp
[6/10] : && /usr/bin/c++ -fPIC -shared -Wl,-soname,libC.so -o libC.so
CMakeFiles/C.dir/c.cpp.o libB.so libA.so
-Wl,-rpath,/home/sergey/Tests/cmake/build && :
[7/10] /usr/bin/c++ -DD_EXPORTS -fPIC -MMD -MT CMakeFiles/D.dir/d.cpp.o
-MF "CMakeFiles/D.dir/d.cpp.o.d" -o CMakeFiles/D.dir/d.cpp.o -c d.cpp
[8/10] : && /usr/bin/c++ -fPIC -shared -Wl,-soname,libD.so -o libD.so
CMakeFiles/D.dir/d.cpp.o libC.so -Wl,-rpath,/home/sergey/Tests/cmake/build
-Wl,-rpath-link,/home/sergey/Tests/cmake/build && :
[9/10] /usr/bin/c++ -MMD -MT CMakeFiles/main.dir/main.cpp.o -MF
"CMakeFiles/main.dir/main.cpp.o.d" -o CMakeFiles/main.dir/main.cpp.o -c
main.cpp
[10/10] : && /usr/bin/c++ CMakeFiles/main.dir/main.cpp.o -o main
-rdynamic *libD.so libB.so libA.so libB.so libA.so*
-Wl,-rpath,/home/sergey/Tests/cmake/build
-Wl,-rpath-link,/home/sergey/Tests/cmake/build && :
Is it a bug or a feature? Is there any way to avoid repetition of libraries?
Best regards,
Sergey
--
View this message in context: http://cmake.3232098.n2.nabble.com/Duplicate-shared-libraries-for-transitive-dependencies-tp7585038.html
Sent from the CMake mailing list archive at Nabble.com.
More information about the CMake
mailing list