Skip to content

Commit

Permalink
Fix issues with xdr detection
Browse files Browse the repository at this point in the history
Add logic to detect and use the libtirpc xdr implementation on Linux.
Addresses #11.

Fall back to the system stdint.h to define size types in the bundled
xdr types.h when stdint.h is available.
  • Loading branch information
richmattes committed Dec 9, 2018
1 parent f0109df commit b05878f
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 10 deletions.
10 changes: 9 additions & 1 deletion cmake/internal/SearchForStuff.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ INCLUDE (CheckFunctionExists)
INCLUDE (CheckIncludeFiles)
INCLUDE (CheckLibraryExists)
INCLUDE (CheckSymbolExists)
INCLUDE (FindPkgConfig)

SET (PLAYER_EXTRA_LIB_DIRS "" CACHE STRING "List of extra library directories.")
MARK_AS_ADVANCED (PLAYER_EXTRA_LIB_DIRS)
SET (PLAYER_EXTRA_INCLUDE_DIRS "" CACHE STRING "List of extra include directories.")
MARK_AS_ADVANCED (PLAYER_EXTRA_INCLUDE_DIRS)
SET (CMAKE_REQUIRED_INCLUDES ${PLAYER_EXTRA_INCLUDE_DIRS})

CHECK_INCLUDE_FILES("stdint.h" HAVE_STDINT_H)

IF (PLAYER_OS_QNX)
SET (CMAKE_REQUIRED_LIBRARIES socket)
ELSEIF (PLAYER_OS_SOLARIS)
Expand All @@ -19,10 +22,16 @@ ENDIF (PLAYER_OS_QNX)
CHECK_FUNCTION_EXISTS (getaddrinfo HAVE_GETADDRINFO)
SET (CMAKE_REQUIRED_LIBRARIES)

IF (PLAYER_OS_LINUX AND PKG_CONFIG_FOUND)
PKG_CHECK_MODULES(TIRPC libtirpc)
ENDIF(PLAYER_OS_LINUX AND PKG_CONFIG_FOUND)

IF (PLAYER_OS_QNX)
SET (CMAKE_REQUIRED_LIBRARIES rpc)
ELSEIF (PLAYER_OS_SOLARIS)
SET (CMAKE_REQUIRED_LIBRARIES nsl)
ELSEIF (PLAYER_OS_LINUX AND TIRPC_FOUND)
SET (CMAKE_REQUIRED_LIBRARIES ${TIRPC_LIBRARIES})
ENDIF (PLAYER_OS_QNX)
CHECK_FUNCTION_EXISTS (xdr_free HAVE_XDR)
IF (HAVE_XDR)
Expand Down Expand Up @@ -141,7 +150,6 @@ INCLUDE (TestBigEndian)
TEST_BIG_ENDIAN (WORDS_BIGENDIAN)

# GTK checks
INCLUDE (FindPkgConfig)
IF (NOT PKG_CONFIG_FOUND)
MESSAGE (STATUS "WARNING: Could not find pkg-config. This will prevent searching for GTK and building many drivers.")
ELSE (NOT PKG_CONFIG_FOUND)
Expand Down
1 change: 1 addition & 0 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
/* enable TCP_NODELAY */
#cmakedefine ENABLE_TCP_NODELAY 1

#cmakedefine HAVE_STDINT_H 1
#cmakedefine HAVE_GETADDRINFO 1
#cmakedefine HAVE_I2C 1
#cmakedefine HAVE_JPEG 1
Expand Down
11 changes: 10 additions & 1 deletion libplayerinterface/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ SET (playerinterfaceSrcs ${playerxdr_h}

IF (PLAYER_OS_QNX)
SET (interfaceLibFlag -lrpc)
ELSEIF (PLAYER_OS_LINUX AND TIRPC_FOUND)
SET (interfaceLibFlag -ltirpc)
set (interfaceCflags ${TIRPC_CFLAGS})
INCLUDE_DIRECTORIES(${TIRPC_INCLUDE_DIRS})
ELSE (PLAYER_OS_QNX)
SET (interfaceLibFlag)
ENDIF (PLAYER_OS_QNX)
Expand All @@ -112,12 +116,17 @@ SET_SOURCE_FILES_PROPERTIES (${playerxdr_h} ${playerxdr_c} PROPERTIES GENERATED
IF (PLAYER_OS_QNX)
TARGET_LINK_LIBRARIES (playerinterface rpc)
PLAYERCORE_ADD_INT_LINK_LIB (rpc)
ELSEIF (PLAYER_OS_LINUX AND TIRPC_FOUND)
TARGET_LINK_LIBRARIES (playerinterface ${TIRPC_LIBRARIES})
PLAYERCORE_ADD_INT_LINK_LIB (tirpc)
TARGET_INCLUDE_DIRECTORIES (playerinterface PUBLIC ${TIRPC_INCLUDE_DIRS})
ENDIF (PLAYER_OS_QNX)
IF (NOT HAVE_XDR)
TARGET_LINK_LIBRARIES (playerinterface playerreplace)
TARGET_INCLUDE_DIRECTORIES(playerinterface PUBLIC "${PROJECT_SOURCE_DIR}/replace")
ENDIF (NOT HAVE_XDR)
PLAYER_MAKE_PKGCONFIG ("playerinterface" "Player Interface library - part of the Player Project"
"" "" "" "${interfaceLibFlag}")
"" "" "${interfaceCflags}" "${interfaceLibFlag}")

PLAYER_INSTALL_HEADERS (playerinterface ${playerxdr_h}
addr_util.h
Expand Down
14 changes: 7 additions & 7 deletions replace/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ IF (NOT HAVE_XDR)
xdr_mem.c
xdr_sizeof.c)
IF (PLAYER_OS_WIN)
SET (ws2_32lib ws2_32)
SET (ws2_32lib ws2_32)
ENDIF (PLAYER_OS_WIN)
ENDIF (NOT HAVE_XDR)

Expand Down Expand Up @@ -57,7 +57,7 @@ ENDIF (NOT HAVE_NANOSLEEP)
IF (NOT HAVE_POLL)
SET (replaceSrcs ${replaceSrcs} poll.c)
IF (PLAYER_OS_WIN)
SET (ws2_32lib ws2_32)
SET (ws2_32lib ws2_32)
ENDIF (PLAYER_OS_WIN)
ENDIF (NOT HAVE_POLL)

Expand All @@ -69,12 +69,12 @@ IF (replaceSrcs)
PLAYER_ADD_LIBRARY (playerreplace ${replaceSrcs})
TARGET_LINK_LIBRARIES (playerreplace playercommon)
IF (PLAYER_OS_WIN)
IF (NOT HAVE_XDR OR NOT HAVE_POLL)
TARGET_LINK_LIBRARIES (playerreplace ws2_32)
ENDIF (NOT HAVE_XDR OR NOT HAVE_POLL)
PLAYER_MAKE_PKGCONFIG ("playerreplace" "Player library of replacements for missing platform functionality - part of the Player Project" "playercommon ${ws2_32Lib}" "" "" "")
IF (NOT HAVE_XDR OR NOT HAVE_POLL)
TARGET_LINK_LIBRARIES (playerreplace ws2_32)
ENDIF (NOT HAVE_XDR OR NOT HAVE_POLL)
PLAYER_MAKE_PKGCONFIG ("playerreplace" "Player library of replacements for missing platform functionality - part of the Player Project" "playercommon ${ws2_32Lib}" "" "" "")
ELSE (PLAYER_OS_WIN)
PLAYER_MAKE_PKGCONFIG ("playerreplace" "Player library of replacements for missing platform functionality - part of the Player Project" "playercommon" "" "" "")
PLAYER_MAKE_PKGCONFIG ("playerreplace" "Player library of replacements for missing platform functionality - part of the Player Project" "playercommon" "" "" "")
ENDIF (PLAYER_OS_WIN)
ENDIF (replaceSrcs)

7 changes: 6 additions & 1 deletion replace/rpc/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
#ifndef _RPC_TYPES_H
#define _RPC_TYPES_H 1

#include "config.h"

typedef int bool_t;
typedef int enum_t;
/* This needs to be changed to uint32_t in the future */
Expand Down Expand Up @@ -81,6 +83,9 @@ typedef unsigned long long int u_quad_t;
#endif

/* Fixed-size types, underlying types depend on word size and compiler. */
#if HAVE_STDINT_H
#include <stdint.h>
#else
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef signed short int int16_t;
Expand All @@ -91,7 +96,7 @@ typedef unsigned int uint32_t;
typedef signed long long int int64_t;
typedef unsigned long long int uint64_t;
//#endif

#endif
typedef char* caddr_t;

//#include <sys/time.h>
Expand Down

0 comments on commit b05878f

Please sign in to comment.