summaryrefslogtreecommitdiffstats
path: root/Utilities/cmxmlrpc/CMakeLists.txt
blob: 86a7870aba749270cde197b0bac94bd03ed10587 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
PROJECT(XMLRPC)

INCLUDE_REGULAR_EXPRESSION("^.*$")

# Include all the necessary files for macros
SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake")

# Check if header file exists and add it to the list.
SET(CURRENT_INCLUDES)
INCLUDE (CheckIncludeFiles)
MACRO(CHECK_INCLUDE_FILE_CONCAT FILE VARIABLE)
  CHECK_INCLUDE_FILES("${CURRENT_INCLUDES};${FILE}" ${VARIABLE})
  IF(${VARIABLE})
    SET(CURRENT_INCLUDES ${CURRENT_INCLUDES} ${FILE})
  ENDIF(${VARIABLE})
ENDMACRO(CHECK_INCLUDE_FILE_CONCAT)

CHECK_INCLUDE_FILE_CONCAT("stdio.h" HAVE_STDIO_H)
CHECK_INCLUDE_FILE_CONCAT("stdarg.h" HAVE_STDARG_H)
CHECK_INCLUDE_FILE_CONCAT("sys/filio.h" HAVE_SYS_FILIO_H)
CHECK_INCLUDE_FILE_CONCAT("sys/ioctl.h" HAVE_SYS_IOCTL_H)
CHECK_INCLUDE_FILE_CONCAT("wchar.h" HAVE_WCHAR_H)

IF(HAVE_WCHAR_H)
  OPTION(HAVE_UNICODE_WCHAR "Enable Unicode Support" YES)
  MARK_AS_ADVANCED(HAVE_UNICODE_WCHAR)
ELSE(HAVE_WCHAR_H)
  SET(HAVE_UNICODE_WCHAR 0)
ENDIF(HAVE_WCHAR_H)

INCLUDE (CheckSymbolExists)
CHECK_SYMBOL_EXISTS(asprintf "${CURRENT_INCLUDES}" HAVE_ASPRINTF)
CHECK_SYMBOL_EXISTS(setgroups "${CURRENT_INCLUDES}" HAVE_SETGROUPS)

INCLUDE (CheckTypeSize)
CHECK_TYPE_SIZE(size_t  SIZEOF_SIZE_T)

INCLUDE (TryCompileFromSource)
SET(HEADER_INCLUDES "${CURRENT_INCLUDES}")
TRY_COMPILE_FROM_SOURCE("va_list list1, list2; list1 = list2"
  VA_LIST_ISNOT_ARRAY_DEFINE)
SET(VA_LIST_IS_ARRAY_DEFINE 0)
IF(NOT VA_LIST_ISNOT_ARRAY_DEFINE)
  SET(VA_LIST_IS_ARRAY_DEFINE 1)
ENDIF(NOT VA_LIST_ISNOT_ARRAY_DEFINE)
TRY_COMPILE_FROM_SOURCE("int x __attribute__((__unused__))"
  ATTR_UNUSED_VAR)
SET(ATTR_UNUSED)
IF(ATTR_UNUSED_VAR)
  SET(ATTR_UNUSED "__attribute__((__unused__))")
ENDIF(ATTR_UNUSED_VAR)

SET(HAVE_LIBWWW_SSL)
SET(DIRECTORY_SEPARATOR "/")

SET(HAVE_PTHREADS 0)
IF(CMAKE_BUILD_XMLRPC_WITH_THREADS)
  FIND_PACKAGE(Threads)
  IF(WIN32 OR CMAKE_USE_PTHREADS_INIT)
    SET(HAVE_PTHREADS 1)
  ENDIF(WIN32 OR CMAKE_USE_PTHREADS_INIT)
ENDIF(CMAKE_BUILD_XMLRPC_WITH_THREADS)

INCLUDE_DIRECTORIES(
  "${CMAKE_CURRENT_SOURCE_DIR}"
  "${CMAKE_CURRENT_BINARY_DIR}"
  ${CMAKE_EXPAT_INCLUDES}
  ${CMAKE_CURL_INCLUDES}
  )

CONFIGURE_FILE(
  "${CMAKE_CURRENT_SOURCE_DIR}/xmlrpc_config.h.in"
  "${CMAKE_CURRENT_BINARY_DIR}/xmlrpc_config.h"
  )
CONFIGURE_FILE(
  "${CMAKE_CURRENT_SOURCE_DIR}/xmlrpc_amconfig.h.in"
  "${CMAKE_CURRENT_BINARY_DIR}/xmlrpc_amconfig.h"
  )

# DISABLING UNTIL A TRY-COMPILE CAN DETERMINE IF IT IS SAFE
# See internal_stdio_core.h.in for explanation.
#CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/internal_stdio_core.h.in
#               ${CMAKE_CURRENT_BINARY_DIR}/internal/stdio_core.h
#               @ONLY IMMEDIATE)

SET(xmlrpc_SRCS
  #XmlRpcCpp.cpp
  xmlrpc_array.c
  xmlrpc_authcookie.c
  xmlrpc_base64.c
  xmlrpc_client.c
  xmlrpc_data.c
  xmlrpc_expat.c
  xmlrpc_parse.c
  xmlrpc_registry.c
  xmlrpc_serialize.c
  xmlrpc_curl_transport.c
  #xmlrpc_server_abyss.c
  xmlrpc_struct.c
  xmlrpc_strutil.c
  xmlrpc_support.c
  casprintf.c
  )
IF(HAVE_UNICODE_WCHAR)
  SET(xmlrpc_SRCS
    ${xmlrpc_SRCS}
    xmlrpc_utf8.c
    )
ENDIF(HAVE_UNICODE_WCHAR)
IF(WIN32)
  SET(xmlrpc_SRCS ${xmlrpc_SRCS}
    win32_pthreads.c
    )
ENDIF(WIN32)

ADD_LIBRARY(cmXMLRPC ${xmlrpc_SRCS})
TARGET_LINK_LIBRARIES(cmXMLRPC ${CMAKE_EXPAT_LIBRARIES} ${CMAKE_CURL_LIBRARIES})
IF(HAVE_PTHREADS)
  TARGET_LINK_LIBRARIES(cmXMLRPC ${CMAKE_THREAD_LIBS_INIT})
ENDIF(HAVE_PTHREADS)

ADD_EXECUTABLE(xrtest synch_client.c)
TARGET_LINK_LIBRARIES(xrtest cmXMLRPC)

ADD_TEST(Test-XMLRPC ${EXECUTABLE_OUTPUT_PATH}/xrtest)