Browse Source

Use bfd shared library to compile Libs/Core/ctkBinaryFileDescriptor

On some system (i.e. Fedora core 13), the bfd static library isn't
installed by "default".

Moreover, the using the static library on 64bits stystem leads to the
following error: "requires unsupported dynamic reloc; recompile with -fPIC"
Jean-Christophe Fillion-Robin 14 years ago
parent
commit
b4d4e761db
2 changed files with 10 additions and 4 deletions
  1. 5 1
      Libs/Core/CMake/TestBFD/CMakeLists.txt
  2. 5 3
      Libs/Core/CMake/ctkMacroBFDCheck.cmake

+ 5 - 1
Libs/Core/CMake/TestBFD/CMakeLists.txt

@@ -1,4 +1,8 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
+
 PROJECT(TestBFD)
 
+FIND_LIBRARY(BDF_LIBRARY bfd)
+
 ADD_EXECUTABLE(TestBFD TestBFD.cpp)
-TARGET_LINK_LIBRARIES(TestBFD bfd iberty)
+TARGET_LINK_LIBRARIES(TestBFD ${BDF_LIBRARY})

+ 5 - 3
Libs/Core/CMake/ctkMacroBFDCheck.cmake

@@ -10,7 +10,9 @@ IF(NOT WIN32)
   INCLUDE(CheckIncludeFile)
   CHECK_INCLUDE_FILE(bfd.h HAVE_BFD_HEADER)
 
-  IF(HAVE_BFD_HEADER)
+  FIND_LIBRARY(BDF_LIBRARY bfd)
+
+  IF(HAVE_BFD_HEADER AND BDF_LIBRARY)
     # make sure we can build with libbfd
     #MESSAGE(STATUS "Checking libbfd")
     TRY_COMPILE(HAVE_BFD
@@ -24,8 +26,8 @@ IF(NOT WIN32)
     #MESSAGE(${OUTPUT})
 
     IF(HAVE_BFD)
-      SET(BFD_LIBRARIES bfd iberty)
-      MESSAGE(STATUS "CTKCore: libbfd is available")
+      SET(BFD_LIBRARIES ${BDF_LIBRARY})
+      MESSAGE(STATUS "CTKCore: libbfd is available [${BDF_LIBRARY}]")
     ELSE()
       MESSAGE(STATUS "CTKCore: libbfd is *NOT* available")
     ENDIF()