From: ageay Date: Mon, 8 Jul 2013 09:38:04 +0000 (+0000) Subject: Improve CPPUNIT detection to avoid -ldl problem on link. X-Git-Tag: B4KillOfAutomake~20 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=76b3b8794ea1c42753dabddc6d8ee9418850676b;p=modules%2Fkernel.git Improve CPPUNIT detection to avoid -ldl problem on link. --- diff --git a/salome_adm/cmake_files/FindCppUnit.cmake b/salome_adm/cmake_files/FindCppUnit.cmake index 4460b9d0d..b34e80a35 100644 --- a/salome_adm/cmake_files/FindCppUnit.cmake +++ b/salome_adm/cmake_files/FindCppUnit.cmake @@ -37,26 +37,51 @@ IF(NOT CppUnit_FIND_QUIETLY) MESSAGE(STATUS "Looking for CppUnit ...") ENDIF() -# Headers +# Headers +SET(CPPUNIT_ROOT_DIR $ENV{CPPUNIT_ROOT_DIR} CACHE PATH "Path to the CPPUNIT.") +IF(CPPUNIT_ROOT_DIR) + LIST(APPEND CMAKE_INCLUDE_PATH "${CPPUNIT_ROOT_DIR}/include") + LIST(APPEND CMAKE_PROGRAM_PATH "${CPPUNIT_ROOT_DIR}/bin") +ENDIF(CPPUNIT_ROOT_DIR) + SET(CPPUNIT_INCLUDE_TO_FIND cppunit/extensions/HelperMacros.h) FIND_PATH(CPPUNIT_INCLUDE_DIRS ${CPPUNIT_INCLUDE_TO_FIND}) # Libraries -IF(WINDOWS) +IF(WIN32) IF(CMAKE_BUILD_TYPE STREQUAL Debug) FIND_LIBRARY(CPPUNIT_LIBRARIES cppunitd_dll) ELSE(CMAKE_BUILD_TYPE STREQUAL Debug) FIND_LIBRARY(CPPUNIT_LIBRARIES cppunit_dll) ENDIF(CMAKE_BUILD_TYPE STREQUAL Debug) -ELSE(WINDOWS) - FIND_LIBRARY(CPPUNIT_LIBRARIES cppunit) -ENDIF(WINDOWS) +ELSE(WIN32) + FIND_PROGRAM(CPPUNIT_CONFIG_BIN cppunit-config) + IF(NOT CPPUNIT_CONFIG_BIN) + 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}) +# MESSAGE("**** ${CPPUNIT_LIBRARIES}") +ENDIF(WIN32) # Global variables SET(CPPUNIT_DEFINITIONS) -IF(WINDOWS) +IF(WIN32) SET(CPPUNIT_DEFINITIONS -DCPPUNIT_DLL) -ENDIF(WINDOWS) +ENDIF(WIN32) INCLUDE(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(CppUnit REQUIRED_VARS CPPUNIT_INCLUDE_DIRS CPPUNIT_LIBRARIES)