1# - Try to find cunit 2# Once done this will define 3# CUNIT_FOUND - System has cunit 4# CUNIT_INCLUDE_DIRS - The cunit include directories 5# CUNIT_LIBRARIES - The libraries needed to use cunit 6 7find_package(PkgConfig QUIET) 8pkg_check_modules(PC_CUNIT QUIET cunit) 9 10find_path(CUNIT_INCLUDE_DIR 11 NAMES CUnit/CUnit.h 12 HINTS ${PC_CUNIT_INCLUDE_DIRS} 13) 14find_library(CUNIT_LIBRARY 15 NAMES cunit 16 HINTS ${PC_CUNIT_LIBRARY_DIRS} 17) 18 19if(CUNIT_INCLUDE_DIR) 20 set(_version_regex "^#define[ \t]+CU_VERSION[ \t]+\"([^\"]+)\".*") 21 file(STRINGS "${CUNIT_INCLUDE_DIR}/CUnit/CUnit.h" 22 CUNIT_VERSION REGEX "${_version_regex}") 23 string(REGEX REPLACE "${_version_regex}" "\\1" 24 CUNIT_VERSION "${CUNIT_VERSION}") 25 unset(_version_regex) 26endif() 27 28include(FindPackageHandleStandardArgs) 29# handle the QUIETLY and REQUIRED arguments and set CUNIT_FOUND to TRUE 30# if all listed variables are TRUE and the requested version matches. 31find_package_handle_standard_args(CUnit REQUIRED_VARS 32 CUNIT_LIBRARY CUNIT_INCLUDE_DIR 33 VERSION_VAR CUNIT_VERSION) 34 35if(CUNIT_FOUND) 36 set(CUNIT_LIBRARIES ${CUNIT_LIBRARY}) 37 set(CUNIT_INCLUDE_DIRS ${CUNIT_INCLUDE_DIR}) 38endif() 39 40mark_as_advanced(CUNIT_INCLUDE_DIR CUNIT_LIBRARY) 41