2 # Find the native XMLRPC headers and libraries.
3 # XMLRPC_INCLUDE_DIRS - where to find xmlrpc.h, etc.
4 # XMLRPC_LIBRARIES - List of libraries when using xmlrpc.
5 # XMLRPC_FOUND - True if xmlrpc found.
6 # XMLRPC modules may be specified as components for this find module.
7 # Modules may be listed by running "xmlrpc-c-config". Modules include:
9 # libwww-client libwww-based client
10 # cgi-server CGI-based server
11 # abyss-server ABYSS-based server
13 # FIND_PACKAGE(XMLRPC REQUIRED libwww-client)
15 # First find the config script from which to obtain other values.
16 FIND_PROGRAM(XMLRPC_C_CONFIG NAMES xmlrpc-c-config)
18 # Check whether we found anything.
23 ENDIF(XMLRPC_C_CONFIG)
25 # Lookup the include directories needed for the components requested.
27 # Use the newer EXECUTE_PROCESS command if it is available.
28 IF(COMMAND EXECUTE_PROCESS)
30 COMMAND ${XMLRPC_C_CONFIG} ${XMLRPC_FIND_COMPONENTS} --cflags
31 OUTPUT_VARIABLE XMLRPC_C_CONFIG_CFLAGS
32 OUTPUT_STRIP_TRAILING_WHITESPACE
33 RESULT_VARIABLE XMLRPC_C_CONFIG_RESULT
35 ELSE(COMMAND EXECUTE_PROCESS)
36 EXEC_PROGRAM(${XMLRPC_C_CONFIG} ARGS "${XMLRPC_FIND_COMPONENTS} --cflags"
37 OUTPUT_VARIABLE XMLRPC_C_CONFIG_CFLAGS
38 RETURN_VALUE XMLRPC_C_CONFIG_RESULT
40 ENDIF(COMMAND EXECUTE_PROCESS)
42 # Parse the include flags.
43 IF("${XMLRPC_C_CONFIG_RESULT}" MATCHES "^0$")
44 # Convert the compile flags to a CMake list.
45 STRING(REGEX REPLACE " +" ";"
46 XMLRPC_C_CONFIG_CFLAGS "${XMLRPC_C_CONFIG_CFLAGS}")
48 # Look for -I options.
49 SET(XMLRPC_INCLUDE_DIRS)
50 FOREACH(flag ${XMLRPC_C_CONFIG_CFLAGS})
51 IF("${flag}" MATCHES "^-I")
52 STRING(REGEX REPLACE "^-I" "" DIR "${flag}")
53 FILE(TO_CMAKE_PATH "${DIR}" DIR)
54 SET(XMLRPC_INCLUDE_DIRS ${XMLRPC_INCLUDE_DIRS} "${DIR}")
55 ENDIF("${flag}" MATCHES "^-I")
57 ELSE("${XMLRPC_C_CONFIG_RESULT}" MATCHES "^0$")
58 MESSAGE("Error running ${XMLRPC_C_CONFIG}: [${XMLRPC_C_CONFIG_RESULT}]")
60 ENDIF("${XMLRPC_C_CONFIG_RESULT}" MATCHES "^0$")
63 # Lookup the libraries needed for the components requested.
65 # Use the newer EXECUTE_PROCESS command if it is available.
66 IF(COMMAND EXECUTE_PROCESS)
68 COMMAND ${XMLRPC_C_CONFIG} ${XMLRPC_FIND_COMPONENTS} --libs
69 OUTPUT_VARIABLE XMLRPC_C_CONFIG_LIBS
70 OUTPUT_STRIP_TRAILING_WHITESPACE
71 RESULT_VARIABLE XMLRPC_C_CONFIG_RESULT
73 ELSE(COMMAND EXECUTE_PROCESS)
74 EXEC_PROGRAM(${XMLRPC_C_CONFIG} ARGS "${XMLRPC_FIND_COMPONENTS} --libs"
75 OUTPUT_VARIABLE XMLRPC_C_CONFIG_LIBS
76 RETURN_VALUE XMLRPC_C_CONFIG_RESULT
78 ENDIF(COMMAND EXECUTE_PROCESS)
80 # Parse the library names and directories.
81 IF("${XMLRPC_C_CONFIG_RESULT}" MATCHES "^0$")
82 STRING(REGEX REPLACE " +" ";"
83 XMLRPC_C_CONFIG_LIBS "${XMLRPC_C_CONFIG_LIBS}")
85 # Look for -L flags for directories and -l flags for library names.
86 SET(XMLRPC_LIBRARY_DIRS)
87 SET(XMLRPC_LIBRARY_NAMES)
88 FOREACH(flag ${XMLRPC_C_CONFIG_LIBS})
89 IF("${flag}" MATCHES "^-L")
90 STRING(REGEX REPLACE "^-L" "" DIR "${flag}")
91 FILE(TO_CMAKE_PATH "${DIR}" DIR)
92 SET(XMLRPC_LIBRARY_DIRS ${XMLRPC_LIBRARY_DIRS} "${DIR}")
93 ELSEIF("${flag}" MATCHES "^-l")
94 STRING(REGEX REPLACE "^-l" "" NAME "${flag}")
95 SET(XMLRPC_LIBRARY_NAMES ${XMLRPC_LIBRARY_NAMES} "${NAME}")
96 ENDIF("${flag}" MATCHES "^-L")
99 # Search for each library needed using the directories given.
100 FOREACH(name ${XMLRPC_LIBRARY_NAMES})
101 # Look for this library.
102 FIND_LIBRARY(XMLRPC_${name}_LIBRARY
104 HINTS ${XMLRPC_LIBRARY_DIRS}
106 MARK_AS_ADVANCED(XMLRPC_${name}_LIBRARY)
108 # If any library is not found then the whole package is not found.
109 IF(NOT XMLRPC_${name}_LIBRARY)
111 ENDIF(NOT XMLRPC_${name}_LIBRARY)
113 # Build an ordered list of all the libraries needed.
114 SET(XMLRPC_LIBRARIES ${XMLRPC_LIBRARIES} "${XMLRPC_${name}_LIBRARY}")
116 ELSE("${XMLRPC_C_CONFIG_RESULT}" MATCHES "^0$")
117 MESSAGE("Error running ${XMLRPC_C_CONFIG}: [${XMLRPC_C_CONFIG_RESULT}]")
119 ENDIF("${XMLRPC_C_CONFIG_RESULT}" MATCHES "^0$")
122 # Report the results.
124 SET(XMLRPC_DIR_MESSAGE
125 "XMLRPC was not found. Make sure the entries XMLRPC_* are set.")
126 IF(NOT XMLRPC_FIND_QUIETLY)
127 MESSAGE(STATUS "${XMLRPC_DIR_MESSAGE}")
128 ELSE(NOT XMLRPC_FIND_QUIETLY)
129 IF(XMLRPC_FIND_REQUIRED)
130 MESSAGE(FATAL_ERROR "${XMLRPC_DIR_MESSAGE}")
131 ENDIF(XMLRPC_FIND_REQUIRED)
132 ENDIF(NOT XMLRPC_FIND_QUIETLY)
133 ENDIF(NOT XMLRPC_FOUND)