xref: /freebsd/contrib/libcbor/CMakeModules/FindCMocka.cmake (revision 5d3e7166f6a0187fa3f8831b16a06bd9955c21ff)
110ff414cSEd Maste# - Try to find CMocka
210ff414cSEd Maste# Once done this will define
310ff414cSEd Maste#
410ff414cSEd Maste#  CMOCKA_ROOT_DIR - Set this variable to the root installation of CMocka
510ff414cSEd Maste#
610ff414cSEd Maste# Read-Only variables:
710ff414cSEd Maste#  CMOCKA_FOUND - system has CMocka
810ff414cSEd Maste#  CMOCKA_INCLUDE_DIR - the CMocka include directory
910ff414cSEd Maste#  CMOCKA_LIBRARIES - Link these to use CMocka
1010ff414cSEd Maste#  CMOCKA_DEFINITIONS - Compiler switches required for using CMocka
1110ff414cSEd Maste#
1210ff414cSEd Maste#=============================================================================
1310ff414cSEd Maste#  Copyright (c) 2011-2012 Andreas Schneider <asn@cryptomilk.org>
1410ff414cSEd Maste#
1510ff414cSEd Maste#  Distributed under the OSI-approved BSD License (the "License");
1610ff414cSEd Maste#  see accompanying file Copyright.txt for details.
1710ff414cSEd Maste#
1810ff414cSEd Maste#  This software is distributed WITHOUT ANY WARRANTY; without even the
1910ff414cSEd Maste#  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
2010ff414cSEd Maste#  See the License for more information.
2110ff414cSEd Maste#=============================================================================
2210ff414cSEd Maste#
2310ff414cSEd Maste
24*5d3e7166SEd Mastefind_package(PkgConfig QUIET)
25*5d3e7166SEd Masteif(PKG_CONFIG_FOUND)
26*5d3e7166SEd Maste    pkg_check_modules(PC_CMOCKA QUIET cmocka)
27*5d3e7166SEd Maste    set(CMOCKA_DEFINITIONS ${PC_CMOCKA_CFLAGS_OTHER})
28*5d3e7166SEd Masteendif()
29*5d3e7166SEd Maste
3010ff414cSEd Mastefind_path(CMOCKA_INCLUDE_DIR
31*5d3e7166SEd Maste    HINTS ${PC_CMOCKA_INCLUDEDIR} ${PC_CMOCKA_INCLUDE_DIRS}
3210ff414cSEd Maste    NAMES
3310ff414cSEd Maste        cmocka.h
3410ff414cSEd Maste    PATHS
3510ff414cSEd Maste        ${CMOCKA_ROOT_DIR}/include
3610ff414cSEd Maste)
3710ff414cSEd Maste
3810ff414cSEd Mastefind_library(CMOCKA_LIBRARY
39*5d3e7166SEd Maste    HINTS ${PC_CMOCKA_LIBDIR} ${PC_CMOCKA_LIBRARY_DIRS}
4010ff414cSEd Maste    NAMES
4110ff414cSEd Maste        cmocka cmocka_shared
4210ff414cSEd Maste    PATHS
4310ff414cSEd Maste        ${CMOCKA_ROOT_DIR}/include
4410ff414cSEd Maste)
4510ff414cSEd Maste
4610ff414cSEd Masteif (CMOCKA_LIBRARY)
4710ff414cSEd Maste  set(CMOCKA_LIBRARIES
4810ff414cSEd Maste      ${CMOCKA_LIBRARIES}
4910ff414cSEd Maste      ${CMOCKA_LIBRARY}
5010ff414cSEd Maste  )
5110ff414cSEd Masteendif (CMOCKA_LIBRARY)
5210ff414cSEd Maste
5310ff414cSEd Masteinclude(FindPackageHandleStandardArgs)
5410ff414cSEd Mastefind_package_handle_standard_args(CMocka DEFAULT_MSG CMOCKA_LIBRARIES CMOCKA_INCLUDE_DIR)
5510ff414cSEd Maste
5610ff414cSEd Maste# show the CMOCKA_INCLUDE_DIR and CMOCKA_LIBRARIES variables only in the advanced view
5710ff414cSEd Mastemark_as_advanced(CMOCKA_INCLUDE_DIR CMOCKA_LIBRARIES)
58