1# Distributed under the OSI-approved BSD 3-Clause License. See accompanying 2# file Copyright.txt or https://cmake.org/licensing for details. 3 4#[=======================================================================[.rst: 5FindXMLRPC 6---------- 7 8Find xmlrpc 9 10Find the native XMLRPC headers and libraries. 11 12:: 13 14 XMLRPC_INCLUDE_DIRS - where to find xmlrpc.h, etc. 15 XMLRPC_LIBRARIES - List of libraries when using xmlrpc. 16 XMLRPC_FOUND - True if xmlrpc found. 17 18XMLRPC modules may be specified as components for this find module. 19Modules may be listed by running "xmlrpc-c-config". Modules include: 20 21:: 22 23 c++ C++ wrapper code 24 libwww-client libwww-based client 25 cgi-server CGI-based server 26 abyss-server ABYSS-based server 27 28Typical usage: 29 30:: 31 32 find_package(XMLRPC REQUIRED libwww-client) 33#]=======================================================================] 34 35# First find the config script from which to obtain other values. 36find_program(XMLRPC_C_CONFIG NAMES xmlrpc-c-config) 37 38# Check whether we found anything. 39if(XMLRPC_C_CONFIG) 40 set(XMLRPC_C_FOUND 1) 41else() 42 set(XMLRPC_C_FOUND 0) 43endif() 44 45# Lookup the include directories needed for the components requested. 46if(XMLRPC_C_FOUND) 47 execute_process( 48 COMMAND ${XMLRPC_C_CONFIG} ${XMLRPC_FIND_COMPONENTS} --cflags 49 OUTPUT_VARIABLE XMLRPC_C_CONFIG_CFLAGS 50 OUTPUT_STRIP_TRAILING_WHITESPACE 51 RESULT_VARIABLE XMLRPC_C_CONFIG_RESULT 52 ) 53 54 # Parse the include flags. 55 if("${XMLRPC_C_CONFIG_RESULT}" STREQUAL "0") 56 # Convert the compile flags to a CMake list. 57 string(REGEX REPLACE " +" ";" 58 XMLRPC_C_CONFIG_CFLAGS "${XMLRPC_C_CONFIG_CFLAGS}") 59 60 # Look for -I options. 61 # FIXME: Use these as hints to a find_path call to find the headers. 62 set(XMLRPC_INCLUDE_DIRS) 63 foreach(flag ${XMLRPC_C_CONFIG_CFLAGS}) 64 if("${flag}" MATCHES "^-I(.+)") 65 file(TO_CMAKE_PATH "${CMAKE_MATCH_1}" DIR) 66 list(APPEND XMLRPC_INCLUDE_DIRS "${DIR}") 67 endif() 68 endforeach() 69 else() 70 message("Error running ${XMLRPC_C_CONFIG}: [${XMLRPC_C_CONFIG_RESULT}]") 71 set(XMLRPC_C_FOUND 0) 72 endif() 73endif() 74 75# Lookup the libraries needed for the components requested. 76if(XMLRPC_C_FOUND) 77 execute_process( 78 COMMAND ${XMLRPC_C_CONFIG} ${XMLRPC_FIND_COMPONENTS} --libs 79 OUTPUT_VARIABLE XMLRPC_C_CONFIG_LIBS 80 OUTPUT_STRIP_TRAILING_WHITESPACE 81 RESULT_VARIABLE XMLRPC_C_CONFIG_RESULT 82 ) 83 84 # Parse the library names and directories. 85 if("${XMLRPC_C_CONFIG_RESULT}" STREQUAL "0") 86 string(REGEX REPLACE " +" ";" 87 XMLRPC_C_CONFIG_LIBS "${XMLRPC_C_CONFIG_LIBS}") 88 89 # Look for -L flags for directories and -l flags for library names. 90 set(XMLRPC_LIBRARY_DIRS) 91 set(XMLRPC_LIBRARY_NAMES) 92 foreach(flag ${XMLRPC_C_CONFIG_LIBS}) 93 if("${flag}" MATCHES "^-L(.+)") 94 file(TO_CMAKE_PATH "${CMAKE_MATCH_1}" DIR) 95 list(APPEND XMLRPC_LIBRARY_DIRS "${DIR}") 96 elseif("${flag}" MATCHES "^-l(.+)") 97 list(APPEND XMLRPC_LIBRARY_NAMES "${CMAKE_MATCH_1}") 98 endif() 99 endforeach() 100 101 # Search for each library needed using the directories given. 102 foreach(name ${XMLRPC_LIBRARY_NAMES}) 103 # Look for this library. 104 find_library(XMLRPC_${name}_LIBRARY 105 NAMES ${name} 106 HINTS ${XMLRPC_LIBRARY_DIRS} 107 ) 108 mark_as_advanced(XMLRPC_${name}_LIBRARY) 109 110 # If any library is not found then the whole package is not found. 111 if(NOT XMLRPC_${name}_LIBRARY) 112 set(XMLRPC_C_FOUND 0) 113 endif() 114 115 # Build an ordered list of all the libraries needed. 116 set(XMLRPC_LIBRARIES ${XMLRPC_LIBRARIES} "${XMLRPC_${name}_LIBRARY}") 117 endforeach() 118 else() 119 message("Error running ${XMLRPC_C_CONFIG}: [${XMLRPC_C_CONFIG_RESULT}]") 120 set(XMLRPC_C_FOUND 0) 121 endif() 122endif() 123 124# Report the results. 125include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) 126FIND_PACKAGE_HANDLE_STANDARD_ARGS( 127 XMLRPC 128 REQUIRED_VARS XMLRPC_C_FOUND XMLRPC_LIBRARIES 129 FAIL_MESSAGE "XMLRPC was not found. Make sure the entries XMLRPC_* are set.") 130