1# Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. 2# 3# This program is free software; you can redistribute it and/or modify 4# it under the terms of the GNU General Public License, version 2.0, 5# as published by the Free Software Foundation. 6# 7# This program is also distributed with certain software (including 8# but not limited to OpenSSL) that is licensed under separate terms, 9# as designated in a particular file or component or in included license 10# documentation. The authors of MySQL hereby grant you an additional 11# permission to link the program and your derivative works with the 12# separately licensed software that they have included with MySQL. 13# 14# This program is distributed in the hope that it will be useful, 15# but WITHOUT ANY WARRANTY; without even the implied warranty of 16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17# GNU General Public License, version 2.0, for more details. 18# 19# You should have received a copy of the GNU General Public License 20# along with this program; if not, write to the Free Software 21# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 22 23# 24# XDR related checks 25# 26 27IF (WIN32) 28 # On windows we bundle the rpc header and some code as well 29 SET (CMAKE_REQUIRED_INCLUDES ${XCOM_BASEDIR}/windeps/sunrpc 30 ${XCOM_BASEDIR}/windeps/include) 31ENDIF() 32 33IF (NOT WIN32) 34 MYSQL_CHECK_RPC() 35 36 SET (CMAKE_REQUIRED_FLAGS_BACKUP ${CMAKE_REQUIRED_FLAGS}) 37 SET (CMAKE_REQUIRED_FLAGS "-Wno-error") 38 SET (CMAKE_REQUIRED_INCLUDES ${RPC_INCLUDE_DIRS}) 39ENDIF() 40 41# 42# Network interfaces related checks 43# 44 45#All the code below needs to be here because CMake is dumb and generates code 46# with unused vars 47 48CHECK_STRUCT_HAS_MEMBER("struct xdr_ops" x_putint32 rpc/xdr.h 49 HAVE_XDR_OPS_X_PUTINT32) 50CHECK_STRUCT_HAS_MEMBER("struct xdr_ops" x_getint32 rpc/xdr.h 51 HAVE_XDR_OPS_X_GETINT32) 52 53CHECK_C_SOURCE_COMPILES( 54 " 55 #include <rpc/types.h> 56 int main(void) { rpc_inline_t x; return 0; } 57 " 58 HAVE_RPC_INLINE_T) 59 60# Restore CMAKE_REQUIRED_FLAGS 61IF (NOT WIN32) 62 SET (CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_BACKUP}) 63ENDIF() 64 65 66IF(NOT APPLE 67 AND NOT WIN32 68 AND NOT FREEBSD) 69 70 SET(SAVED_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS}) 71 72 SET(CMAKE_REQUIRED_FLAGS "-Werror=sign-conversion") 73 74 CHECK_C_SOURCE_COMPILES( 75 " 76 #include <rpc/xdr.h> 77 int main() { XDR xdr; xdr.x_handy = -1; return (int)xdr.x_handy; } 78 " 79 OLD_XDR) 80 81 CHECK_C_COMPILER_FLAG("-Wincompatible-pointer-types" 82 HAS_INCOMPATIBLE_POINTER_TYPES) 83 IF (HAS_INCOMPATIBLE_POINTER_TYPES) 84 SET(CMAKE_REQUIRED_FLAGS 85 "${CMAKE_REQUIRED_FLAGS} -Werror=incompatible-pointer-types") 86 ELSE() 87 SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror") 88 ENDIF() 89 90 CHECK_C_SOURCE_COMPILES( 91 " 92 #include <rpc/xdr.h> 93 bool_t putlong(XDR* xdr, long *longp) 94 { return (bool_t)(*longp + xdr->x_handy); } 95 int main() { 96 XDR xdr; 97 struct xdr_ops ops; 98 long l; 99 100 ops.x_putlong = putlong; 101 return (int)ops.x_putlong(&xdr, &l); 102 } 103 " 104 X_PUTLONG_NOT_USE_CONST) 105 106 SET(CMAKE_REQUIRED_FLAGS ${SAVED_CMAKE_REQUIRED_FLAGS}) 107ENDIF() 108