[Bug 701] New: cppunit needs to link against libdl (at least on some distros)

https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=701

Summary: cppunit needs to link against libdl (at least on some
distros)
Product: KDL
Version: kdl-trunk
Platform: All
OS/Version: GNU/Linux
Status: NEW
Severity: normal
Priority: P3
Component: Build system
AssignedTo: orocos-dev [..] ...
ReportedBy: mquigley [..] ...
CC: orocos-dev [..] ...
Estimated Hours: 0.0

Created an attachment (id=491)
--> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=491)
causes the build system to link against libdl if running tests

I saw there was some email traffic about this a few months back, but the issue
is still here in my case: I am using Arch Linux, and in order to build KDL with
the tests enabled, I needed to make the one-line tweak copied below, which just
adds a link line for libdl. Otherwise the build fails here:

Linking CXX executable framestest
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.1/../../../../lib/libcppunit.so:
undefined reference to `dlsym'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.1/../../../../lib/libcppunit.so:
undefined reference to `dlopen'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.1/../../../../lib/libcppunit.so:
undefined reference to `dlclose'

Arch Linux is using gcc 4.4; perhaps that has something to do with it, but
anyway the one-liner below allows the build to complete successfully on my
system. I have also attached a patch file.

--- CMakeLists.txt (revision 30215)
+++ CMakeLists.txt (working copy)
@@ -83,6 +83,7 @@
# export CMAKE_INCLUDE_PATH=/opt/local/include
# export CMAKE_LIBRARY_PATH=/opt/local/lib
FIND_LIBRARY(CPPUNIT cppunit)
+ SET(CPPUNIT ${CPPUNIT} "dl")
FIND_PATH(CPPUNIT_HEADERS cppunit/TestRunner.h)
IF ( CPPUNIT AND CPPUNIT_HEADERS)
MESSAGE("-- Looking for Cppunit - found")