1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
# Find CppUnit includes and library
#
# This module defines
# CppUnit_INCLUDE_DIRS
# CppUnit_LIBRARIES, the libraries to link against to use CppUnit.
# CppUnit_LIBRARY_DIRS, the location of the libraries
# CppUnit_FOUND, If false, do not try to use CppUnit
#
# Copyright © 2007, Matt Williams
#
# Redistribution and use is allowed according to the terms of the BSD license.
IF(WIN32) #Windows
SET(CppUnit_INCLUDE_SEARCH_DIRS
${CppUnit_LIBRARY_SEARCH_DIRS}
${CMAKE_INCLUDE_PATH}
/usr/include/
/usr/local/
/opt/include/
)
SET(CppUnit_LIBRARY_SEARCH_DIRS
${CppUnit_LIBRARY_SEARCH_DIRS}
${CMAKE_LIBRARY_PATH}
/usr/lib
/usr/local/lib
/opt/lib
)
FIND_PATH(CppUnit_INCLUDE_DIRS cppunit/Test.h ${CppUnit_INCLUDE_SEARCH_DIRS})
IF(MSVC)
# prefer the cppunit dll with Visual Studio
FIND_LIBRARY(CppUnit_LIBRARIES cppunit_dll PATHS ${CppUnit_LIBRARY_SEARCH_DIRS})
ELSE(MSVC)
FIND_LIBRARY(CppUnit_LIBRARIES cppunit PATHS ${CppUnit_LIBRARY_SEARCH_DIRS})
ENDIF(MSVC)
ELSE(WIN32) #Unix
CMAKE_MINIMUM_REQUIRED(VERSION 2.4.7 FATAL_ERROR)
FIND_PACKAGE(PkgConfig)
PKG_SEARCH_MODULE(CppUnit cppunit)
SET(CppUnit_INCLUDE_DIRS ${CppUnit_INCLUDE_DIRS})
SET(CppUnit_LIBRARY_DIRS ${CppUnit_LIBDIR})
SET(CppUnit_LIBRARIES ${CppUnit_LIBRARIES} CACHE STRING "")
ENDIF(WIN32)
#Do some preparation
SEPARATE_ARGUMENTS(CppUnit_INCLUDE_DIRS)
SEPARATE_ARGUMENTS(CppUnit_LIBRARIES)
SET(CppUnit_INCLUDE_DIRS ${CppUnit_INCLUDE_DIRS})
SET(CppUnit_LIBRARIES ${CppUnit_LIBRARIES})
SET(CppUnit_LIBRARY_DIRS ${CppUnit_LIBRARY_DIRS})
MARK_AS_ADVANCED(CppUnit_INCLUDE_DIRS CppUnit_LIBRARIES CppUnit_LIBRARY_DIRS)
IF(CppUnit_INCLUDE_DIRS AND CppUnit_LIBRARIES)
SET(CppUnit_FOUND TRUE)
ENDIF(CppUnit_INCLUDE_DIRS AND CppUnit_LIBRARIES)
IF(NOT CppUnit_FOUND)
IF(CppUnit_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find CppUnit")
ENDIF(CppUnit_FIND_REQUIRED)
ENDIF(NOT CppUnit_FOUND)
|