Skip to content

Commit

Permalink
cmake: Support building nis module on system having libtirpc
Browse files Browse the repository at this point in the history
glibc has removed Sun RPC. Use replacement libtirpc headers and library in
nis moduleupdated path for rpc.h for systems using libtirpc

See python/cpython#5137

This closes python-cmake-buildsystem#224

Co-authored-by: Jean-Christophe Fillion-Robin <jchris.fillionr@kitware.com>
  • Loading branch information
2 people authored and Dan Dees committed Jun 5, 2022
1 parent f5fd65c commit cfa6df8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
4 changes: 4 additions & 0 deletions cmake/ConfigureChecks.cmake
Expand Up @@ -107,6 +107,9 @@ endif()
find_path(SQLITE3_INCLUDE_PATH sqlite3.h)
find_library(SQLITE3_LIBRARY sqlite3)

find_path(TIRPC_RPC_INCLUDE_PATH rpc.h PATHS "/usr/include/tirpc/rpc")
find_library(TIRPC_LIBRARY tirpc)

if(WIN32)
set(M_LIBRARIES )
set(HAVE_LIBM 1)
Expand Down Expand Up @@ -2495,3 +2498,4 @@ endif()
if(CMAKE_SYSTEM MATCHES Windows)
set(PY_PLATFORM win32)
endif()

18 changes: 17 additions & 1 deletion cmake/extensions/CMakeLists.txt
Expand Up @@ -147,7 +147,23 @@ endif()
# UNIX-only extensions
add_python_extension(fcntl REQUIRES UNIX SOURCES fcntlmodule.c)
add_python_extension(grp REQUIRES UNIX SOURCES grpmodule.c)
add_python_extension(nis REQUIRES UNIX HAVE_LIBNSL SOURCES nismodule.c LIBRARIES ${HAVE_LIBNSL})

set(nis_REQUIRES UNIX HAVE_LIBNSL)
set(nis_LIBRARIES ${HAVE_LIBNSL})
set(nis_INCLUDEDIRS )
if(TIRPC_LIBRARY AND TIRPC_RPC_INCLUDE_PATH)
# if rpc.h is provided by libtirpc (instead of being provided by glibc). See python/cpython#5137
list(APPEND nis_REQUIRES )
list(APPEND nis_LIBRARIES ${TIRPC_LIBRARY})
list(APPEND nis_INCLUDEDIRS ${TIRPC_RPC_INCLUDE_PATH}/../)
endif()
add_python_extension(nis
REQUIRES ${nis_REQUIRES}
SOURCES nismodule.c
LIBRARIES ${nis_LIBRARIES}
INCLUDEDIRS ${nis_INCLUDEDIRS}
)

add_python_extension(posix REQUIRES UNIX BUILTIN SOURCES posixmodule.c)
add_python_extension(pwd REQUIRES UNIX BUILTIN SOURCES pwdmodule.c) # this is needed to find out the user's home dir if $HOME is not set
add_python_extension(resource REQUIRES UNIX SOURCES resource.c)
Expand Down

0 comments on commit cfa6df8

Please sign in to comment.