2013-10-15 19:17:36 +04:00
|
|
|
#.rst:
|
|
|
|
# FindXMLRPC
|
|
|
|
# ----------
|
|
|
|
#
|
|
|
|
# Find xmlrpc
|
|
|
|
#
|
2006-10-19 20:58:05 +04:00
|
|
|
# Find the native XMLRPC headers and libraries.
|
2013-10-15 19:17:36 +04:00
|
|
|
#
|
|
|
|
# ::
|
|
|
|
#
|
|
|
|
# XMLRPC_INCLUDE_DIRS - where to find xmlrpc.h, etc.
|
|
|
|
# XMLRPC_LIBRARIES - List of libraries when using xmlrpc.
|
|
|
|
# XMLRPC_FOUND - True if xmlrpc found.
|
|
|
|
#
|
2006-10-19 20:58:05 +04:00
|
|
|
# XMLRPC modules may be specified as components for this find module.
|
|
|
|
# Modules may be listed by running "xmlrpc-c-config". Modules include:
|
2013-10-15 19:17:36 +04:00
|
|
|
#
|
|
|
|
# ::
|
|
|
|
#
|
|
|
|
# c++ C++ wrapper code
|
|
|
|
# libwww-client libwww-based client
|
|
|
|
# cgi-server CGI-based server
|
|
|
|
# abyss-server ABYSS-based server
|
|
|
|
#
|
2006-10-19 20:58:05 +04:00
|
|
|
# Typical usage:
|
2013-10-15 19:17:36 +04:00
|
|
|
#
|
|
|
|
# ::
|
|
|
|
#
|
|
|
|
# find_package(XMLRPC REQUIRED libwww-client)
|
2006-10-19 20:58:05 +04:00
|
|
|
|
2009-09-28 19:45:50 +04:00
|
|
|
#=============================================================================
|
|
|
|
# Copyright 2001-2009 Kitware, Inc.
|
|
|
|
#
|
|
|
|
# Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
# see accompanying file Copyright.txt for details.
|
|
|
|
#
|
|
|
|
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
# See the License for more information.
|
|
|
|
#=============================================================================
|
2010-08-07 04:48:47 +04:00
|
|
|
# (To distribute this file outside of CMake, substitute the full
|
2009-09-28 19:45:50 +04:00
|
|
|
# License text for the above reference.)
|
|
|
|
|
2006-10-19 20:58:05 +04:00
|
|
|
# First find the config script from which to obtain other values.
|
2012-08-13 21:47:32 +04:00
|
|
|
find_program(XMLRPC_C_CONFIG NAMES xmlrpc-c-config)
|
2006-10-19 20:58:05 +04:00
|
|
|
|
|
|
|
# Check whether we found anything.
|
2012-08-13 21:47:32 +04:00
|
|
|
if(XMLRPC_C_CONFIG)
|
|
|
|
set(XMLRPC_FOUND 1)
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
set(XMLRPC_FOUND 0)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2006-10-19 20:58:05 +04:00
|
|
|
|
|
|
|
# Lookup the include directories needed for the components requested.
|
2012-08-13 21:47:32 +04:00
|
|
|
if(XMLRPC_FOUND)
|
2006-10-19 20:58:05 +04:00
|
|
|
# Use the newer EXECUTE_PROCESS command if it is available.
|
2012-08-13 21:47:32 +04:00
|
|
|
if(COMMAND EXECUTE_PROCESS)
|
|
|
|
execute_process(
|
2006-10-19 20:58:05 +04:00
|
|
|
COMMAND ${XMLRPC_C_CONFIG} ${XMLRPC_FIND_COMPONENTS} --cflags
|
|
|
|
OUTPUT_VARIABLE XMLRPC_C_CONFIG_CFLAGS
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
RESULT_VARIABLE XMLRPC_C_CONFIG_RESULT
|
|
|
|
)
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
exec_program(${XMLRPC_C_CONFIG} ARGS "${XMLRPC_FIND_COMPONENTS} --cflags"
|
2006-10-19 20:58:05 +04:00
|
|
|
OUTPUT_VARIABLE XMLRPC_C_CONFIG_CFLAGS
|
|
|
|
RETURN_VALUE XMLRPC_C_CONFIG_RESULT
|
|
|
|
)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2006-10-19 20:58:05 +04:00
|
|
|
|
|
|
|
# Parse the include flags.
|
2013-06-02 23:42:10 +04:00
|
|
|
if("${XMLRPC_C_CONFIG_RESULT}" STREQUAL "0")
|
2006-10-19 20:58:05 +04:00
|
|
|
# Convert the compile flags to a CMake list.
|
2012-08-13 21:47:32 +04:00
|
|
|
string(REGEX REPLACE " +" ";"
|
2006-10-19 20:58:05 +04:00
|
|
|
XMLRPC_C_CONFIG_CFLAGS "${XMLRPC_C_CONFIG_CFLAGS}")
|
|
|
|
|
|
|
|
# Look for -I options.
|
2012-08-13 21:47:32 +04:00
|
|
|
set(XMLRPC_INCLUDE_DIRS)
|
|
|
|
foreach(flag ${XMLRPC_C_CONFIG_CFLAGS})
|
2014-04-06 23:30:00 +04:00
|
|
|
if("${flag}" MATCHES "^-I(.+)")
|
|
|
|
file(TO_CMAKE_PATH "${CMAKE_MATCH_1}" DIR)
|
|
|
|
list(APPEND XMLRPC_INCLUDE_DIRS "${DIR}")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
message("Error running ${XMLRPC_C_CONFIG}: [${XMLRPC_C_CONFIG_RESULT}]")
|
|
|
|
set(XMLRPC_FOUND 0)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
|
|
|
endif()
|
2006-10-19 20:58:05 +04:00
|
|
|
|
|
|
|
# Lookup the libraries needed for the components requested.
|
2012-08-13 21:47:32 +04:00
|
|
|
if(XMLRPC_FOUND)
|
2006-10-19 20:58:05 +04:00
|
|
|
# Use the newer EXECUTE_PROCESS command if it is available.
|
2012-08-13 21:47:32 +04:00
|
|
|
if(COMMAND EXECUTE_PROCESS)
|
|
|
|
execute_process(
|
2006-10-19 20:58:05 +04:00
|
|
|
COMMAND ${XMLRPC_C_CONFIG} ${XMLRPC_FIND_COMPONENTS} --libs
|
|
|
|
OUTPUT_VARIABLE XMLRPC_C_CONFIG_LIBS
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
RESULT_VARIABLE XMLRPC_C_CONFIG_RESULT
|
|
|
|
)
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
exec_program(${XMLRPC_C_CONFIG} ARGS "${XMLRPC_FIND_COMPONENTS} --libs"
|
2006-10-19 20:58:05 +04:00
|
|
|
OUTPUT_VARIABLE XMLRPC_C_CONFIG_LIBS
|
|
|
|
RETURN_VALUE XMLRPC_C_CONFIG_RESULT
|
|
|
|
)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2006-10-19 20:58:05 +04:00
|
|
|
|
|
|
|
# Parse the library names and directories.
|
2013-06-02 23:42:10 +04:00
|
|
|
if("${XMLRPC_C_CONFIG_RESULT}" STREQUAL "0")
|
2012-08-13 21:47:32 +04:00
|
|
|
string(REGEX REPLACE " +" ";"
|
2006-10-19 20:58:05 +04:00
|
|
|
XMLRPC_C_CONFIG_LIBS "${XMLRPC_C_CONFIG_LIBS}")
|
|
|
|
|
|
|
|
# Look for -L flags for directories and -l flags for library names.
|
2012-08-13 21:47:32 +04:00
|
|
|
set(XMLRPC_LIBRARY_DIRS)
|
|
|
|
set(XMLRPC_LIBRARY_NAMES)
|
|
|
|
foreach(flag ${XMLRPC_C_CONFIG_LIBS})
|
2014-04-06 23:30:00 +04:00
|
|
|
if("${flag}" MATCHES "^-L(.+)")
|
|
|
|
file(TO_CMAKE_PATH "${CMAKE_MATCH_1}" DIR)
|
|
|
|
list(APPEND XMLRPC_LIBRARY_DIRS "${DIR}")
|
|
|
|
elseif("${flag}" MATCHES "^-l(.+)")
|
|
|
|
list(APPEND XMLRPC_LIBRARY_NAMES "${CMAKE_MATCH_1}")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
|
|
|
endforeach()
|
2006-10-19 20:58:05 +04:00
|
|
|
|
|
|
|
# Search for each library needed using the directories given.
|
2012-08-13 21:47:32 +04:00
|
|
|
foreach(name ${XMLRPC_LIBRARY_NAMES})
|
2006-10-19 20:58:05 +04:00
|
|
|
# Look for this library.
|
2012-08-13 21:47:32 +04:00
|
|
|
find_library(XMLRPC_${name}_LIBRARY
|
2006-10-19 20:58:05 +04:00
|
|
|
NAMES ${name}
|
2008-06-10 00:04:06 +04:00
|
|
|
HINTS ${XMLRPC_LIBRARY_DIRS}
|
2006-10-19 20:58:05 +04:00
|
|
|
)
|
2012-08-13 21:47:32 +04:00
|
|
|
mark_as_advanced(XMLRPC_${name}_LIBRARY)
|
2006-10-19 20:58:05 +04:00
|
|
|
|
|
|
|
# If any library is not found then the whole package is not found.
|
2012-08-13 21:47:32 +04:00
|
|
|
if(NOT XMLRPC_${name}_LIBRARY)
|
|
|
|
set(XMLRPC_FOUND 0)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2006-10-19 20:58:05 +04:00
|
|
|
|
|
|
|
# Build an ordered list of all the libraries needed.
|
2012-08-13 21:47:32 +04:00
|
|
|
set(XMLRPC_LIBRARIES ${XMLRPC_LIBRARIES} "${XMLRPC_${name}_LIBRARY}")
|
2012-08-13 21:50:14 +04:00
|
|
|
endforeach()
|
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
message("Error running ${XMLRPC_C_CONFIG}: [${XMLRPC_C_CONFIG_RESULT}]")
|
|
|
|
set(XMLRPC_FOUND 0)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
|
|
|
endif()
|
2006-10-19 20:58:05 +04:00
|
|
|
|
|
|
|
# Report the results.
|
2012-08-13 21:47:32 +04:00
|
|
|
if(NOT XMLRPC_FOUND)
|
|
|
|
set(XMLRPC_DIR_MESSAGE
|
2006-10-19 20:58:05 +04:00
|
|
|
"XMLRPC was not found. Make sure the entries XMLRPC_* are set.")
|
2012-08-13 21:47:32 +04:00
|
|
|
if(NOT XMLRPC_FIND_QUIETLY)
|
|
|
|
message(STATUS "${XMLRPC_DIR_MESSAGE}")
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
if(XMLRPC_FIND_REQUIRED)
|
|
|
|
message(FATAL_ERROR "${XMLRPC_DIR_MESSAGE}")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|