FindCPPUNIT.cmake 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. ################################################################################
  2. # Copyright (C) 2011 HPCC Systems.
  3. #
  4. # All rights reserved. This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU Affero General Public License as
  6. # published by the Free Software Foundation, either version 3 of the
  7. # License, or (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU Affero General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU Affero General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. ################################################################################
  17. # - Try to find the CppUnit unit testing library
  18. # Once done this will define
  19. #
  20. # CPPUNIT_FOUND - system has the CppUnit library
  21. # CPPUNIT_INCLUDE_DIR - the CppUnit include directory
  22. # CPPUNIT_LIBRARIES - The libraries needed to use CppUnit
  23. IF (NOT CPPUNIT_FOUND)
  24. IF (WIN32)
  25. SET (cppunit_dll "cppunit_dll")
  26. ELSE()
  27. SET (cppunit_dll "cppunit")
  28. ENDIF()
  29. IF (NOT ${EXTERNALS_DIRECTORY} STREQUAL "")
  30. IF (UNIX)
  31. IF (${ARCH64BIT} EQUAL 1)
  32. SET (osdir "linux64_gcc4.1.1")
  33. ELSE()
  34. SET (osdir "linux32_gcc4.1.1")
  35. ENDIF()
  36. ELSEIF(WIN32)
  37. IF (${ARCH64BIT} EQUAL 1)
  38. SET (osdir "win64")
  39. ELSE()
  40. SET (osdir "win32")
  41. ENDIF()
  42. ELSE()
  43. SET (osdir "unknown")
  44. ENDIF()
  45. IF (NOT ("${osdir}" STREQUAL "unknown"))
  46. FIND_PATH (CPPUNIT_INCLUDE_DIR NAMES cppunit/TestFixture.h PATHS "${EXTERNALS_DIRECTORY}/cppunit/include" NO_DEFAULT_PATH)
  47. FIND_LIBRARY (CPPUNIT_LIBRARIES NAMES ${cppunit_dll} PATHS "${EXTERNALS_DIRECTORY}/cppunit/lib/${osdir}" NO_DEFAULT_PATH)
  48. ENDIF()
  49. ENDIF()
  50. # if we didn't find in externals, look in system include path
  51. if (USE_NATIVE_LIBRARIES)
  52. FIND_PATH (CPPUNIT_INCLUDE_DIR NAMES cppunit/TestFixture.h)
  53. FIND_LIBRARY (CPPUNIT_LIBRARIES NAMES ${cppunit_dll})
  54. endif()
  55. include(FindPackageHandleStandardArgs)
  56. find_package_handle_standard_args(CppUnit DEFAULT_MSG
  57. CPPUNIT_LIBRARIES
  58. CPPUNIT_INCLUDE_DIR
  59. )
  60. IF (CPPUNIT_FOUND AND WIN32)
  61. STRING(REPLACE "cppunit_dll" "cppunitd_dll" CPPUNIT_DEBUG_LIBRARIES "${CPPUNIT_LIBRARIES}")
  62. set (CPPUNIT_LIBRARIES optimized ${CPPUNIT_LIBRARIES} debug ${CPPUNIT_DEBUG_LIBRARIES})
  63. ENDIF()
  64. MARK_AS_ADVANCED(CPPUNIT_INCLUDE_DIR CPPUNIT_LIBRARIES)
  65. ENDIF()