#
#########################################################################
-# Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
-#
-# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
FIND_LIBRARY(CPPUNIT_LIBRARIES cppunit_dll)
ENDIF(CMAKE_BUILD_TYPE STREQUAL Debug)
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)
+
+ # RNV: Some new Linux distributions don't contain cppunit-config executable,
+ # so use pkg-config to detect cppunit first.
+ FIND_PACKAGE(PkgConfig QUIET)
+
+ IF(PKG_CONFIG_FOUND)
+ PKG_SEARCH_MODULE(CPPUNIT_TOOL cppunit)
+ IF(CPPUNIT_TOOL_FOUND)
+ SET(CPPUNIT_LDFLAGS ${CPPUNIT_TOOL_LIBRARIES})
+ ENDIF()
+ ENDIF()
+
+ IF(NOT CPPUNIT_TOOL_FOUND)
+ MESSAGE("CPPUNIT is not found via pgk-config, try to find cppunit-config executable ...")
+ 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)
+ ENDIF()
+
STRING(STRIP ${CPPUNIT_LDFLAGS} CPPUNIT_LDFLAGS)
STRING(REPLACE " " ";" LDFLAGS_LIST ${CPPUNIT_LDFLAGS})
FOREACH(LDFLAG ${LDFLAGS_LIST})
STRING(REGEX REPLACE "^-l" "" LIB ${LIB})
LIST(APPEND LIBS ${LIB})
ELSE()
- MESSAGE(FATAL_ERROR "Unrecognized token \"${LDFLAG}\" in the output of cppunit-config --libs")
+ IF(CPPUNIT_CONFIG_BIN)
+ MESSAGE(FATAL_ERROR "Unrecognized token \"${LDFLAG}\" in the output of cppunit-config --libs")
+ ELSE()
+ LIST(APPEND LIBS ${LDFLAG})
+ ENDIF()
ENDIF()
ENDFOREACH(LDFLAG ${LDFLAGS_LIST})
FOREACH(LIB ${LIBS})
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(CppUnit REQUIRED_VARS CPPUNIT_INCLUDE_DIRS CPPUNIT_LIBRARIES)
-
-