From: barate Date: Fri, 8 Nov 2013 09:53:01 +0000 (+0000) Subject: Fix CPPUNIT detection when its library directory contains -l (like -L/usr/lib/x86_64... X-Git-Tag: BR_hydro_v_0_3_1~21 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=fd3597902ce86a08b7374902d5165fa3d3b1eed2;p=modules%2Fkernel.git Fix CPPUNIT detection when its library directory contains -l (like -L/usr/lib/x86_64-linux-gnu in Ubuntu 13.10) --- diff --git a/salome_adm/cmake_files/FindCppUnit.cmake b/salome_adm/cmake_files/FindCppUnit.cmake index b34e80a35..7ab228727 100644 --- a/salome_adm/cmake_files/FindCppUnit.cmake +++ b/salome_adm/cmake_files/FindCppUnit.cmake @@ -60,20 +60,28 @@ ELSE(WIN32) MESSAGE(FATAL_ERROR "Error in CPPUNIT detection ! cppunit-config executable not found !") ENDIF(NOT CPPUNIT_CONFIG_BIN) EXECUTE_PROCESS(COMMAND ${CPPUNIT_CONFIG_BIN} --libs OUTPUT_VARIABLE CPPUNIT_LDFLAGS) - STRING( REGEX MATCHALL "-L([^\" ]+|\"[^\"]+\")" CPPUNIT_TMP4 "${CPPUNIT_LDFLAGS}" ) - IF(CPPUNIT_TMP4) - STRING( REGEX REPLACE "^-L" "" CPPUNIT_LIBRARY_DIRS ${CPPUNIT_TMP4}) - LIST(APPEND CMAKE_LIBRARY_PATH ${CPPUNIT_LIBRARY_DIRS}) - ENDIF(CPPUNIT_TMP4) - STRING( REGEX MATCHALL "-l([^\", \n]+)" CPPUNIT_TMP5 "${CPPUNIT_LDFLAGS}" ) - FOREACH(LIB ${CPPUNIT_TMP5}) - STRING(REGEX REPLACE "^-l" "" LIB2 ${LIB}) - FIND_LIBRARY(CPPUNIT_SUBLIB_${LIB2} ${LIB2}) - IF(NOT CPPUNIT_SUBLIB_${LIB2}) - MESSAGE(FATAL_ERROR "Error in CPPUNIT detection ! Fail to locate the needed library ${LIB2} !") - ENDIF(NOT CPPUNIT_SUBLIB_${LIB2}) - LIST(APPEND CPPUNIT_LIBRARIES ${CPPUNIT_SUBLIB_${LIB2}}) - ENDFOREACH(LIB ${CPPUNIT_TMP5}) + STRING(STRIP ${CPPUNIT_LDFLAGS} CPPUNIT_LDFLAGS) + STRING(REPLACE " " ";" LDFLAGS_LIST ${CPPUNIT_LDFLAGS}) + FOREACH(LDFLAG ${LDFLAGS_LIST}) + STRING(REGEX MATCH "^-L.*" LIBDIR "${LDFLAG}") + STRING(REGEX MATCH "^-l.*" LIB "${LDFLAG}") + IF(LIBDIR) + STRING(REGEX REPLACE "^-L" "" LIBDIR ${LIBDIR}) + LIST(APPEND CMAKE_LIBRARY_PATH ${LIBDIR}) + ELSEIF(LIB) + STRING(REGEX REPLACE "^-l" "" LIB ${LIB}) + LIST(APPEND LIBS ${LIB}) + ELSE() + MESSAGE(FATAL_ERROR "Unrecognized token \"${LDFLAG}\" in the output of cppunit-config --libs") + ENDIF() + ENDFOREACH(LDFLAG ${LDFLAGS_LIST}) + FOREACH(LIB ${LIBS}) + FIND_LIBRARY(CPPUNIT_SUBLIB_${LIB} ${LIB}) + IF(NOT CPPUNIT_SUBLIB_${LIB}) + MESSAGE(FATAL_ERROR "Error in CPPUNIT detection! Fail to locate the needed library ${LIB}!") + ENDIF(NOT CPPUNIT_SUBLIB_${LIB}) + LIST(APPEND CPPUNIT_LIBRARIES ${CPPUNIT_SUBLIB_${LIB}}) + ENDFOREACH(LIB ${LIBS}) # MESSAGE("**** ${CPPUNIT_LIBRARIES}") ENDIF(WIN32)