From be0cf4a0e1abc2e444e79caed52b237aa815cab6 Mon Sep 17 00:00:00 2001 From: kervala Date: Thu, 9 Sep 2010 14:20:18 +0200 Subject: [PATCH] Changed: #915 NeL fails to build with --as-needed --- code/CMakeLists.txt | 7 ++++--- code/CMakeModules/nel.cmake | 5 +---- code/nel/src/misc/CMakeLists.txt | 17 ++++++++++++++++- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index 0a94992ff..140c56436 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -96,9 +96,10 @@ FIND_PACKAGE(LibXml2 REQUIRED) FIND_PACKAGE(PNG REQUIRED) FIND_PACKAGE(Jpeg) -IF(WITH_STATIC) - SET(LIBXML2_DEFINITIONS ${LIBXML2_DEFINITIONS} -DLIBXML_STATIC) -ENDIF(WITH_STATIC) +IF(WITH_STATIC) + # libxml2 could need winsock2 library + SET(LIBXML2_DEFINITIONS ${LIBXML2_DEFINITIONS} ${WINSOCK2_LIB} -DLIBXML_STATIC) +ENDIF(WITH_STATIC) NL_SETUP_BUILD() diff --git a/code/CMakeModules/nel.cmake b/code/CMakeModules/nel.cmake index 346067a57..a3e320e7a 100644 --- a/code/CMakeModules/nel.cmake +++ b/code/CMakeModules/nel.cmake @@ -274,10 +274,7 @@ MACRO(NL_SETUP_BUILD) IF(WITH_COVERAGE) SET(PLATFORM_CFLAGS "-fprofile-arcs -ftest-coverage ${PLATFORM_CFLAGS}") ENDIF(WITH_COVERAGE) - SET(PLATFORM_LINKFLAGS "${CMAKE_THREAD_LIBS_INIT} -lc -lm -lstdc++") - IF(NOT APPLE) - SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -lrt") - ENDIF(NOT APPLE) + SET(PLATFORM_LINKFLAGS "-Wl,--no-undefined -Wl,--as-needed") SET(NL_DEBUG_CFLAGS "-DNL_DEBUG -g") SET(NL_RELEASE_CFLAGS "-DNL_RELEASE -O6 -g") SET(NL_NONE_CFLAGS "-DNL_RELEASE -g -finline-functions -O2 ") diff --git a/code/nel/src/misc/CMakeLists.txt b/code/nel/src/misc/CMakeLists.txt index 341c6ef8f..e70ad7868 100644 --- a/code/nel/src/misc/CMakeLists.txt +++ b/code/nel/src/misc/CMakeLists.txt @@ -16,14 +16,29 @@ IF(JPEG_FOUND) TARGET_LINK_LIBRARIES(nelmisc ${JPEG_LIBRARY}) ENDIF(JPEG_FOUND) +IF(WITH_STATIC OR WIN32) + TARGET_LINK_LIBRARIES(nelmisc ${PNG_LIBRARIES}) +ELSE(WITH_STATIC OR WIN32) + # Link only with libpng shared library + TARGET_LINK_LIBRARIES(nelmisc ${PNG_LIBRARY}) +ENDIF(WITH_STATIC OR WIN32) + # For DirectInput (di_event_emitter) IF(WIN32) INCLUDE_DIRECTORIES(${DXSDK_INCLUDE_DIR}) + TARGET_LINK_LIBRARIES(nelmisc ${DXSDK_DINPUT_LIBRARY} ${DXSDK_GUID_LIBRARY}) ENDIF(WIN32) +IF(UNIX) + SET(LIBC_LIBRARY -lc) + IF(NOT APPLE) + SET(LIBRT_LIBRARY -lrt) + ENDIF(NOT APPLE) +ENDIF(UNIX) + INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR} ${PNG_INCLUDE_DIR} config_file) -TARGET_LINK_LIBRARIES(nelmisc ${LIBXML2_LIBRARIES} ${PNG_LIBRARIES} ${WINSOCK2_LIB}) +TARGET_LINK_LIBRARIES(nelmisc ${CMAKE_THREAD_LIBS_INIT} ${LIBC_LIBRARY} ${LIBRT_LIBRARY} ${LIBXML2_LIBRARIES}) SET_TARGET_PROPERTIES(nelmisc PROPERTIES LINK_INTERFACE_LIBRARIES "") NL_DEFAULT_PROPS(nelmisc "NeL, Library: NeL Misc")