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)
#
MACRO(SALOME_GENERATE_TESTS_ENVIRONMENT output)
SET(_env)
+ SET(_WIN_LD_LIBRARY OFF)
FOREACH(_item ${_${PROJECT_NAME}_EXTRA_ENV})
+ IF(${_item} STREQUAL "LD_LIBRARY_PATH")
+ SET(_WIN_LD_LIBRARY ON)
+ ENDIF()
+ SET(_env_${_item})
FOREACH(_val ${_${PROJECT_NAME}_EXTRA_ENV_${_item}})
IF(WIN32)
- SET(_env "${_val};${_env}")
+ SET(_env_${_item} "${_val};${_env_${_item}}")
ELSE()
- SET(_env "${_val}:${_env}")
+ SET(_env_${_item} "${_val}:${_env_${_item}}")
ENDIF()
ENDFOREACH()
- SET(_env " ${_item}=${_env}")
- ENDFOREACH()
+ ENDFOREACH()
+
+ IF(_WIN_LD_LIBRARY AND WIN32)
+ SET(_env_PATH "${_env_PATH} ${_env_LD_LIBRARY_PATH}")
+ ENDIF()
+
+ FOREACH(_item ${_${PROJECT_NAME}_EXTRA_ENV})
+ IF(NOT(WIN32 AND ${_item} STREQUAL "LD_LIBRARY_PATH"))
+ SET(_env "${_item}=${_env_${_item}} ${_env}")
+ ENDIF()
+ ENDFOREACH()
SET(${output} ${_env})
-ENDMACRO(SALOME_GENERATE_TESTS_ENVIRONMENT)
+ENDMACRO(SALOME_GENERATE_TESTS_ENVIRONMENT)
#########################################################################
# SALOME_APPEND_LIST_OF_LIST()