Skip to content

Commit

Permalink
Add -DIN_PLACE=1 to cmake
Browse files Browse the repository at this point in the history
This configures the paths to run the software from the local build
directory. Much of this is done automatically by how cmake uses rpath,
but the two cases where we dlopen things have to be handled by us.

The simple solution is to hard wire the build directory path into the
binaries.

'etc' is also relocated to build/etc/ as that is part of how the verbs
providers are located.

Signed-off-by: Jason Gunthorpe <[email protected]>
Tested-by: Steve Wise <[email protected]>
Signed-off-by: Doug Ledford <[email protected]>
  • Loading branch information
jgunthorpe authored and dledford committed Dec 23, 2016
1 parent 77fbb25 commit 8a77a30
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 7 deletions.
23 changes: 21 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
# ninja
#
# Common options passed to cmake are:
# -DIN_PLACE=1
# Configure the build to be run from the build directory, this results in something
# that is not installable.
# -DCMAKE_EXPORT_COMPILE_COMMANDS=1
# Write a compile_commands.json file for clang tooling
# -DCMAKE_BUILD_TYPE=RelWithDebInfo
Expand Down Expand Up @@ -45,16 +48,23 @@ set(PACKAGE_VERSION "12")

#-------------------------
# Basic standard paths

# Override the CMAKE_INSTALL_ dirs to be under the build/ directory
if (IN_PLACE)
set(CMAKE_INSTALL_SYSCONFDIR "${CMAKE_BINARY_DIR}/etc")
set(CMAKE_INSTALL_BINDIR "${CMAKE_BINARY_DIR}/bin")
endif()

include(GNUInstallDirs)
# C include root
set(BUILD_INCLUDE ${CMAKE_BINARY_DIR}/include)
# Executables
set(BUILD_BIN ${CMAKE_BINARY_DIR}/bin)
# Libraries
set(BUILD_LIB ${CMAKE_BINARY_DIR}/lib)
# Used for IN_PLACE configuration
set(BUILD_ETC ${CMAKE_BINARY_DIR}/etc)

# Location to place provider .driver files
set(CONFIG_DIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}/libibverbs.d")
set(CMAKE_INSTALL_INITDDIR "${CMAKE_INSTALL_SYSCONFDIR}/init.d"
CACHE PATH "Location for init.d files")
set(CMAKE_INSTALL_SYSTEMD_SERVICEDIR "${CMAKE_INSTALL_PREFIX}/lib/systemd/system"
Expand Down Expand Up @@ -87,6 +97,15 @@ else()
set(CMAKE_INSTALL_FULL_UDEV_RULESDIR "${CMAKE_INSTALL_UDEV_RULESDIR}")
endif()

# Location to place provider .driver files
if (IN_PLACE)
set(CONFIG_DIR "${BUILD_ETC}/libibverbs.d")
set(VERBS_PROVIDER_DIR "${BUILD_LIB}")
set(ACM_PROVIDER_DIR "${BUILD_LIB}/ibacm")
else()
set(CONFIG_DIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}/libibverbs.d")
endif()

set(DISTRO_FLAVOUR "None" CACHE
STRING "Flavour of distribution to install for. This primarily impacts the init.d scripts installed.")

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ $ bash build.sh
```

*build/bin* will contain the sample programs and *build/lib* will contain the
shared libraries.
shared libraries. The build is configured to run all the programs 'in-place'
and cannot be installed.

NOTE: It is not currently easy to run from the build directory, the plugins
only load from the system path.
Expand Down
4 changes: 2 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ fi
cd "$BUILDDIR"

if [ "x$NINJA" == "x" ]; then
$CMAKE ..
$CMAKE -DIN_PLACE=1 ..
make
else
$CMAKE -GNinja ..
$CMAKE -DIN_PLACE=1 -GNinja ..
$NINJA
fi
4 changes: 2 additions & 2 deletions buildlib/rdma_functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ function(rdma_provider DEST)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${DEST}.driver" DESTINATION "${CONFIG_DIR}")

# Uninstalled driver file
file(MAKE_DIRECTORY "${BUILD_LIB}/libibverbs.d/")
file(WRITE "${BUILD_LIB}/libibverbs.d/${DEST}.driver" "driver ${BUILD_LIB}/${DEST}\n")
file(MAKE_DIRECTORY "${BUILD_ETC}/libibverbs.d/")
file(WRITE "${BUILD_ETC}/libibverbs.d/${DEST}.driver" "driver ${BUILD_LIB}/lib${DEST}\n")

# Create a static provider library
# FIXME: This is probably pointless, the provider library has no symbols so
Expand Down
5 changes: 5 additions & 0 deletions ibacm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ target_link_libraries(ibacmp LINK_PRIVATE
set_target_properties(ibacmp PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${BUILD_LIB}")
install(TARGETS ibacmp DESTINATION "${ACM_PROVIDER_DIR}")
# ACM providers are linked into a subdir so that IN_PLACE can work.
file(MAKE_DIRECTORY "${BUILD_LIB}/ibacm/")
execute_process(COMMAND "${CMAKE_COMMAND}" -E create_symlink
"../libibacmp.so"
"${BUILD_LIB}/ibacm/libibacmp.so")

rdma_executable(ib_acme
src/acme.c
Expand Down

0 comments on commit 8a77a30

Please sign in to comment.