Skip to content

Commit

Permalink
Merge pull request #374 from bluca/pkgconfig
Browse files Browse the repository at this point in the history
Pkgconfig: followup changes from PR #373
  • Loading branch information
jgunthorpe authored Sep 8, 2018
2 parents 65e0b30 + 58859b3 commit a2e3979
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 20 deletions.
9 changes: 3 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ set(IBVERBS_PROVIDER_SUFFIX "-rdmav${IBVERBS_PABI_VERSION}.so")
if (IN_PLACE)
set(CMAKE_INSTALL_SYSCONFDIR "${CMAKE_BINARY_DIR}/etc")
set(CMAKE_INSTALL_BINDIR "${CMAKE_BINARY_DIR}/bin")
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}")
set(CMAKE_INSTALL_LIBDIR "lib")
set(CMAKE_INSTALL_INCLUDEDIR "include")
endif()

include(GNUInstallDirs)
Expand Down Expand Up @@ -368,10 +371,6 @@ if (ENABLE_RESOLVE_NEIGH)
set(NL_KIND 3)
set(NL_INCLUDE_DIRS ${NL3_INCLUDE_DIRS})
set(NL_LIBRARIES ${NL3_LIBRARIES})
set(NL_CFLAGS ${NL3_CFLAGS})
set(NL_LDFLAGS ${NL3_LDFLAGS})
# CMake separates ldflags with a semicolon, cannot be used in a command
string(REPLACE ";" " " NL_LDFLAGS "${NL_LDFLAGS}")
else()
# FIXME: I don't know why we have this fallback, all supported distros
# have libnl3
Expand All @@ -380,8 +379,6 @@ if (ENABLE_RESOLVE_NEIGH)
set(NL_KIND 1)
set(NL_INCLUDE_DIRS ${NL1_INCLUDE_DIRS})
set(NL_LIBRARIES ${NL1_LIBRARIES})
set(NL_LDFLAGS ${NL1_LDFLAGS})
set(NL_CFLAGS ${NL1_CFLAGS})
else()
message(FATAL_ERROR "Cannot find libnl-3.0 or libnl-1")
endif()
Expand Down
17 changes: 12 additions & 5 deletions buildlib/rdma_functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,18 @@ function(rdma_finalize_libs)
endfunction()

# Generate a pkg-config file
function(rdma_pkg_config PC_LIB_NAME PC_LIB_PRIVATE PC_INCLUDE_PRIVATE PC_REQUIRES)
function(rdma_pkg_config PC_LIB_NAME PC_REQUIRES_PRIVATE PC_LIB_PRIVATE)
set(PC_LIB_NAME "${PC_LIB_NAME}")
set(PC_LIB_PRIVATE "${PC_LIB_PRIVATE}")
set(PC_INCLUDE_PRIVATE "${PC_INCLUDE_PRIVATE}")
set(PC_REQUIRES "${PC_REQUIRES}")
configure_file(${CMAKE_SOURCE_DIR}/buildlib/template.pc.in ${CMAKE_CURRENT_BINARY_DIR}/lib${PC_LIB_NAME}.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/lib${PC_LIB_NAME}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
set(PC_REQUIRES_PRIVATE "${PC_REQUIRES_PRIVATE}")
get_target_property(PC_VERSION ${PC_LIB_NAME} VERSION)

# With IN_PLACE=1 the install step is not ran, so generate the file in the build dir
if (IN_PLACE)
set(PC_RPATH "-Wl,-rpath,\${libdir}")
configure_file(${CMAKE_SOURCE_DIR}/buildlib/template.pc.in ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/pkgconfig/lib${PC_LIB_NAME}.pc @ONLY)
else()
configure_file(${CMAKE_SOURCE_DIR}/buildlib/template.pc.in ${CMAKE_CURRENT_BINARY_DIR}/lib${PC_LIB_NAME}.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/lib${PC_LIB_NAME}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
endif()
endfunction()
9 changes: 5 additions & 4 deletions buildlib/template.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@

Name: lib@PC_LIB_NAME@
Description: RDMA Core Userspace Library
Version: @PACKAGE_VERSION@
Libs: -L${libdir} -l@PC_LIB_NAME@
URL: https://github.com/linux-rdma/rdma-core
Version: @PC_VERSION@
Libs.private: @PC_LIB_PRIVATE@
Cflags: -I${includedir} @PC_INCLUDE_PRIVATE@
Requires: @PC_REQUIRES@
Libs: -L${libdir} -l@PC_LIB_NAME@ @PC_RPATH@
Requires.private: @PC_REQUIRES_PRIVATE@
Cflags: -I${includedir}
2 changes: 0 additions & 2 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,6 @@ Architecture: linux-any
Multi-Arch: same
Depends: ibverbs-providers (= ${binary:Version}),
libibverbs1 (= ${binary:Version}),
libnl-3-dev,
libnl-route-3-dev,
${misc:Depends}
Description: Development files for the libibverbs library
libibverbs is a library that allows userspace processes to use RDMA
Expand Down
2 changes: 2 additions & 0 deletions debian/libibverbs-dev.install
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ usr/lib/*/libibverbs*.so
usr/lib/*/libmlx4.so
usr/lib/*/libmlx5.so
usr/lib/*/pkgconfig/libibverbs.pc
usr/lib/*/pkgconfig/libmlx4.pc
usr/lib/*/pkgconfig/libmlx5.pc
usr/share/man/man3/ibv_*
usr/share/man/man3/mbps_to_ibv_rate.3
usr/share/man/man3/mlx4dv_*.3
Expand Down
2 changes: 1 addition & 1 deletion libibumad/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ rdma_library(ibumad libibumad.map
umad_str.c
)

rdma_pkg_config("ibumad" "" "" "libibverbs")
rdma_pkg_config("ibumad" "" "")
2 changes: 1 addition & 1 deletion libibverbs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ target_link_libraries(ibverbs LINK_PRIVATE
kern-abi
)

rdma_pkg_config("ibverbs" "${NL_LDFLAGS} ${CMAKE_THREAD_LIBS_INIT}" "${NL_CFLAGS}" "")
rdma_pkg_config("ibverbs" "" "${CMAKE_THREAD_LIBS_INIT}")
2 changes: 1 addition & 1 deletion librdmacm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ install(TARGETS rspreload DESTINATION "${CMAKE_INSTALL_LIBDIR}/rsocket/")
rdma_install_symlink("librspreload.so" "${CMAKE_INSTALL_LIBDIR}/rsocket/librspreload.so.1")
rdma_install_symlink("librspreload.so" "${CMAKE_INSTALL_LIBDIR}/rsocket/librspreload.so.1.0.0")

rdma_pkg_config("rdmacm" "" "" "libibverbs")
rdma_pkg_config("rdmacm" "libibverbs" "${CMAKE_THREAD_LIBS_INIT}")
2 changes: 2 additions & 0 deletions providers/mlx4/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ publish_headers(infiniband
)

install(FILES "mlx4.conf" DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}/modprobe.d/")

rdma_pkg_config("mlx4" "libibverbs" "${CMAKE_THREAD_LIBS_INIT}")
2 changes: 2 additions & 0 deletions providers/mlx5/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ publish_headers(infiniband
mlx5_api.h
mlx5dv.h
)

rdma_pkg_config("mlx5" "libibverbs" "${CMAKE_THREAD_LIBS_INIT}")

0 comments on commit a2e3979

Please sign in to comment.