1 | # FIND_PACKAGE_HANDLE_STANDARD_ARGS(NAME (DEFAULT_MSG|"Custom failure message") VAR1 ... )
|
---|
2 | #
|
---|
3 | # This macro is intended to be used in FindXXX.cmake modules files.
|
---|
4 | # It handles the REQUIRED and QUIET argument to FIND_PACKAGE() and
|
---|
5 | # it also sets the <UPPERCASED_NAME>_FOUND variable.
|
---|
6 | # The package is found if all variables listed are TRUE.
|
---|
7 | # Example:
|
---|
8 | #
|
---|
9 | # FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXml2 DEFAULT_MSG LIBXML2_LIBRARIES LIBXML2_INCLUDE_DIR)
|
---|
10 | #
|
---|
11 | # LibXml2 is considered to be found, if both LIBXML2_LIBRARIES and
|
---|
12 | # LIBXML2_INCLUDE_DIR are valid. Then also LIBXML2_FOUND is set to TRUE.
|
---|
13 | # If it is not found and REQUIRED was used, it fails with FATAL_ERROR,
|
---|
14 | # independent whether QUIET was used or not.
|
---|
15 | #
|
---|
16 | # If it is found, the location is reported using the VAR1 argument, so
|
---|
17 | # here a message "Found LibXml2: /usr/lib/libxml2.so" will be printed out.
|
---|
18 | # If the second argument is DEFAULT_MSG, the message in the failure case will
|
---|
19 | # be "Could NOT find LibXml2", if you don't like this message you can specify
|
---|
20 | # your own custom failure message there.
|
---|
21 |
|
---|
22 | MACRO(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FAIL_MSG _VAR1 )
|
---|
23 |
|
---|
24 | IF("${_FAIL_MSG}" STREQUAL "DEFAULT_MSG")
|
---|
25 | IF (${_NAME}_FIND_REQUIRED)
|
---|
26 | SET(_FAIL_MESSAGE "Could not find REQUIRED package ${_NAME}")
|
---|
27 | ELSE (${_NAME}_FIND_REQUIRED)
|
---|
28 | SET(_FAIL_MESSAGE "Could not find OPTIONAL package ${_NAME}")
|
---|
29 | ENDIF (${_NAME}_FIND_REQUIRED)
|
---|
30 | ELSE("${_FAIL_MSG}" STREQUAL "DEFAULT_MSG")
|
---|
31 | SET(_FAIL_MESSAGE "${_FAIL_MSG}")
|
---|
32 | ENDIF("${_FAIL_MSG}" STREQUAL "DEFAULT_MSG")
|
---|
33 |
|
---|
34 | STRING(TOUPPER ${_NAME} _NAME_UPPER)
|
---|
35 |
|
---|
36 | SET(${_NAME_UPPER}_FOUND TRUE)
|
---|
37 | IF(NOT ${_VAR1})
|
---|
38 | SET(${_NAME_UPPER}_FOUND FALSE)
|
---|
39 | ENDIF(NOT ${_VAR1})
|
---|
40 |
|
---|
41 | FOREACH(_CURRENT_VAR ${ARGN})
|
---|
42 | IF(NOT ${_CURRENT_VAR})
|
---|
43 | SET(${_NAME_UPPER}_FOUND FALSE)
|
---|
44 | ENDIF(NOT ${_CURRENT_VAR})
|
---|
45 | ENDFOREACH(_CURRENT_VAR)
|
---|
46 |
|
---|
47 | IF (${_NAME_UPPER}_FOUND)
|
---|
48 | IF (NOT ${_NAME}_FIND_QUIETLY)
|
---|
49 | MESSAGE(STATUS "Found ${_NAME}: ${${_VAR1}}")
|
---|
50 | ENDIF (NOT ${_NAME}_FIND_QUIETLY)
|
---|
51 | ELSE (${_NAME_UPPER}_FOUND)
|
---|
52 | IF (${_NAME}_FIND_REQUIRED)
|
---|
53 | MESSAGE(FATAL_ERROR "${_FAIL_MESSAGE}")
|
---|
54 | ELSE (${_NAME}_FIND_REQUIRED)
|
---|
55 | IF (NOT ${_NAME}_FIND_QUIETLY)
|
---|
56 | MESSAGE(STATUS "${_FAIL_MESSAGE}")
|
---|
57 | ENDIF (NOT ${_NAME}_FIND_QUIETLY)
|
---|
58 | ENDIF (${_NAME}_FIND_REQUIRED)
|
---|
59 | ENDIF (${_NAME_UPPER}_FOUND)
|
---|
60 | ENDMACRO(FIND_PACKAGE_HANDLE_STANDARD_ARGS)
|
---|