From b19e31a1be5793fafe338aa29e52648f745371f6 Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Tue, 6 Sep 2011 19:07:55 +0000 Subject: [PATCH] cmake: fix some linking issue with gold linker (AFAIK only fedora use it for the moment) git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4913 96395faa-99c1-11dd-bbfe-3dabce05a288 --- 3rdparty/SDL-1.3.0-5387/CMakeLists.txt | 8 +++----- cmake/FindLibc.cmake | 21 +++++++++++++++++++++ cmake/SearchForStuff.cmake | 1 + common/src/Utilities/CMakeLists.txt | 4 ++++ 4 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 cmake/FindLibc.cmake diff --git a/3rdparty/SDL-1.3.0-5387/CMakeLists.txt b/3rdparty/SDL-1.3.0-5387/CMakeLists.txt index d5399f2c66..657b238f6c 100644 --- a/3rdparty/SDL-1.3.0-5387/CMakeLists.txt +++ b/3rdparty/SDL-1.3.0-5387/CMakeLists.txt @@ -388,16 +388,11 @@ set(SDL_sources #include_directories( ${SDL_ROOT}/include /usr/include/kde/artsc /usr/include/directfb) - # Hiden option. It is only a temporary workaround of issue 1003. The purpose is to LD_PRELOAD # the library so it avoid any conflict with previous SDL1.2 symbol if (DEFINED SHARED_SDL) add_library(${Output} SHARED ${SDL_sources} ) - # Seem to be needed when pre-loading on Fedora - target_link_libraries(${Output} dl) - target_link_libraries(${Output} m) - # Install the library with others plugins if(PACKAGE_MODE) install(TARGETS ${Output} DESTINATION ${PLUGIN_DIR}) @@ -410,6 +405,9 @@ else (DEFINED SHARED_SDL) add_library(${Output} STATIC ${SDL_sources} ) endif (DEFINED SHARED_SDL) +# Gold (new linux linker) does not get automatically dependency of dependency so you must add +# them manually. +target_link_libraries(${Output} ${LIBC_LIBRARIES}) # User flags options if(NOT USER_CMAKE_LD_FLAGS STREQUAL "") diff --git a/cmake/FindLibc.cmake b/cmake/FindLibc.cmake new file mode 100644 index 0000000000..848528bea1 --- /dev/null +++ b/cmake/FindLibc.cmake @@ -0,0 +1,21 @@ +# Once done, this will define +# +# LIBC_FOUND - system has libc +# LIBC_LIBRARIES - link these to use libc + +if(LIBC_LIBRARIES) + set(LIBC_FIND_QUIETLY TRUE) +endif(LIBC_LIBRARIES) + +find_library(librt NAMES rt) +find_library(libdl NAMES dl) +find_library(libm NAMES m) +set(LIBC_LIBRARIES ${librt} ${libdl} ${libm}) + +# handle the QUIETLY and REQUIRED arguments and set LIBC_FOUND to TRUE if +# all listed variables are TRUE +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Libc DEFAULT_MSG LIBC_LIBRARIES) + +mark_as_advanced(LIBC_LIBRARIES) + diff --git a/cmake/SearchForStuff.cmake b/cmake/SearchForStuff.cmake index b180c9b0c3..54da3755bb 100644 --- a/cmake/SearchForStuff.cmake +++ b/cmake/SearchForStuff.cmake @@ -55,6 +55,7 @@ endif(NOT FORCE_INTERNAL_ZLIB) ## Use pcsx2 package to find module include(FindCg) include(FindGlew) +include(FindLibc) include(FindPortAudio) if(NOT FORCE_INTERNAL_SOUNDTOUCH) include(FindSoundTouch) diff --git a/common/src/Utilities/CMakeLists.txt b/common/src/Utilities/CMakeLists.txt index d7d711a170..4ab69398a5 100644 --- a/common/src/Utilities/CMakeLists.txt +++ b/common/src/Utilities/CMakeLists.txt @@ -179,6 +179,10 @@ add_library(${Output} STATIC ${UtilitiesSources} ${UtilitiesHeaders} ${Utilities # link target with wx target_link_libraries(${Output} ${wxWidgets_LIBRARIES}) +# Gold (new linux linker) does not get automatically dependency of dependency so you must add +# them manually. +target_link_libraries(${Output} ${LIBC_LIBRARIES}) + # User flags options if(NOT USER_CMAKE_LD_FLAGS STREQUAL "") target_link_libraries(${Output} "${USER_CMAKE_LD_FLAGS}")