[CMake] Double linking / linking static libraries

Dennis Schridde devurandom at gmx.net
Wed Aug 4 04:51:47 EDT 2010


I searched some more and found a trigger for this
behaviour:

------
PROJECT(test)
cmake_minimum_required(VERSION
2.6)

find_package(Qt4
REQUIRED)
include(${QT_USE_FILE})

set(Boost_ADDITIONAL_VERSIONS 1.38 1.39
1.40 1.41 1.42)
find_package(Boost REQUIRED COMPONENTS
thread)

find_package(GLU REQUIRED)

find_package(JPEG
REQUIRED)

ADD_EXECUTABLE(test test.cpp)
TARGET_LINK_LIBRARIES(test
${QT_LIBRARIES} ${GLU_LIBRARY} ${Boost_LIBRARIES}
${JPEG_LIBRARIES})
------

Removing either include(QTUSEFILE) or find(GLU)
will make the double-linking go away. If both are present, jpeg and
boost-thread will be double-linked:

---- without find(GLU)
----
/usr/bin/c++     -fPIC CMakeFiles/test.dir/test.cpp.o  -o test
-rdynamic -lQtGui -lpng -lSM -lICE -lXi -lXrender -lXrandr -lXcursor
-lXinerama -lXfixes -lfreetype -lfontconfig -lXext -lX11 -lm -lQtCore -lz
-lgthread-2.0 -lglib-2.0 -lrt -lpthread -ldl -lboost_thread-mt -ljpeg 
----
with find(GLU) ---
/usr/bin/c++     -fPIC CMakeFiles/test.dir/test.cpp.o  -o
test -rdynamic -lQtGui -lpng -lSM -lICE -lXi -lXrender -lXrandr -lXcursor
-lXinerama -lXfixes -lfreetype -lfontconfig -lXext -lX11 -lm -lQtCore -lz
-lgthread-2.0 -lglib-2.0 -lrt -lpthread -ldl -lGLU -lGL -lSM -lICE -lX11
-lXext -lboost_thread-mt -ljpeg -lXi -lXrender -lXrandr -lXcursor -lXinerama
-lXfixes -lfreetype -lfontconfig -lm -lQtCore -lz -lgthread-2.0 -lglib-2.0
-lrt -lpthread -ldl -lGLU -lGL -lboost_thread-mt -ljpeg 
---- ----

I am
using Fedora release 12 and cmake version 2.6-patch 4.
The issue is not
reproducible on Gentoo/Linux and cmake version 2.8.1.

Is cmake-2.6 still
being maintained? Otherwise I will suggest an update to our admins. (Is
cmake-2.8 available for Fedora 12?)

--Dennis
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100804/37116e70/attachment.pgp>


More information about the CMake mailing list