X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=salome_adm%2Fcmake_files%2FFindCppUnit.cmake;h=b34e80a3598e088b8be02634830ba0c4ab2bfef2;hb=eb9e197d297d979c2fb53a78494d6fca40f5b4a3;hp=f5d39a0c794ebc2ee90713aed9b3b515ef5eb27f;hpb=307b3b7500069c726a81cd9fa2abd3e26c440f35;p=modules%2Fkernel.git diff --git a/salome_adm/cmake_files/FindCppUnit.cmake b/salome_adm/cmake_files/FindCppUnit.cmake index f5d39a0c7..b34e80a35 100644 --- a/salome_adm/cmake_files/FindCppUnit.cmake +++ b/salome_adm/cmake_files/FindCppUnit.cmake @@ -1,6 +1,6 @@ # - Find CppUnit # Sets the following variables: -# CPPUNIT_INCLUDE_DIR - path to the CppUnit include directory +# CPPUNIT_INCLUDE_DIRS - path to the CppUnit include directory # CPPUNIT_LIBRARIES - path to the CppUnit libraries to be linked against # CPPUNIT_DEFINITIONS - specific CppUnit definitions to be added # @@ -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)