11#
22# cmocka support
33#
4- # If found the following will be defined:
5- # CMOCKA_FOUND - System has cmocka
6- # CMOCKA_INCLUDE_DIRS/CMOCKA_INCLUDES - Include directories for cmocka
7- # CMOCKA_LIBRARIES/CMOCKA_LIBS - Libraries needed for cmocka
8- # CMOCKA_DEFINITIONS - Compiler switches required for cmocka
4+ # The following variables can be set to add additional find support:
5+ # - CMOCKA_ROOT_DIR, specified an explicit root path to test
96#
7+ # If found the following will be defined:
8+ # - CMOCKA_FOUND - System has cmocka
9+ # - CMOCKA_INCLUDE_DIRS/CMOCKA_INCLUDES - Include directories for cmocka
10+ # - CMOCKA_LIBRARIES/CMOCKA_LIBS - Libraries needed for cmocka
11+ # - CMOCKA_DEFINITIONS - Compiler switches required for cmocka
1012#
11- # Copyright (C) 2015 Wind River Systems, Inc. All Rights Reserved.
13+ # Copyright (C) 2015-2017 Wind River Systems, Inc. All Rights Reserved.
1214#
1315# The right to copy, distribute or otherwise make use of this software may
1416# be licensed only pursuant to the terms of an applicable Wind River license
@@ -20,17 +22,33 @@ include( FindPackageHandleStandardArgs )
2022
2123set ( _PROGRAMFILES "ProgramFiles" )
2224set ( _PROGRAMFILES_X86 "ProgramFiles(x86)" )
25+
26+ # Try and find paths
27+ set ( LIB_SUFFIX "" )
28+ get_property ( LIB64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS )
29+ if ( LIB64 )
30+ set ( LIB_SUFFIX 64 )
31+ endif ()
32+
33+ # Allow the ability to specify a global dependency root directory
34+ if ( NOT CMOCKA_ROOT_DIR )
35+ set ( CMOCKA_ROOT_DIR ${DEPENDS_ROOT_DIR} )
36+ endif ()
37+
2338find_path ( CMOCKA_INCLUDE_DIR
2439 NAMES cmocka.h
2540 DOC "cmocka include directory"
26- PATHS "$ENV{${_PROGRAMFILES} }/cmocka/include"
41+ PATHS "${CMOCKA_ROOT_DIR} /include"
42+ "$ENV{${_PROGRAMFILES} }/cmocka/include"
2743 "$ENV{${_PROGRAMFILES_X86} }/cmocka/include"
2844)
2945
3046find_library ( CMOCKA_LIBRARY
3147 NAMES cmocka
3248 DOC "Required cmocka libraries"
33- PATHS "$ENV{${_PROGRAMFILES} }/cmocka/lib"
49+ PATHS "${CMOCKA_ROOT_DIR} /lib${LIB_SUFFIX} "
50+ "${CMOCKA_ROOT_DIR} /lib"
51+ "$ENV{${_PROGRAMFILES} }/cmocka/lib"
3452 "$ENV{${_PROGRAMFILES_X86} }/cmocka/lib"
3553)
3654
@@ -40,6 +58,9 @@ set( CMOCKA_INCLUDE_DIRS ${CMOCKA_INCLUDE_DIR} )
4058set ( CMOCKA_INCLUDES ${CMOCKA_INCLUDE_DIRS} )
4159set ( CMOCKA_DEFINITIONS "" )
4260
43- find_package_handle_standard_args ( cmocka DEFAULT_MSG CMOCKA_LIBRARY CMOCKA_INCLUDE_DIR )
61+ find_package_handle_standard_args ( Cmocka
62+ FOUND_VAR CMOCKA_FOUND
63+ REQUIRED_VARS CMOCKA_INCLUDE_DIR CMOCKA_LIBRARY
64+ FAIL_MESSAGE DEFAULT_MSG )
4465mark_as_advanced ( CMOCKA_INCLUDE_DIR CMOCKA_LIBRARY )
4566
0 commit comments