Skip to content

Commit 8a77a30

Browse files
jgunthorpedledford
authored andcommitted
Add -DIN_PLACE=1 to cmake
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]>
1 parent 77fbb25 commit 8a77a30

File tree

5 files changed

+32
-7
lines changed

5 files changed

+32
-7
lines changed

CMakeLists.txt

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
# ninja
66
#
77
# Common options passed to cmake are:
8+
# -DIN_PLACE=1
9+
# Configure the build to be run from the build directory, this results in something
10+
# that is not installable.
811
# -DCMAKE_EXPORT_COMPILE_COMMANDS=1
912
# Write a compile_commands.json file for clang tooling
1013
# -DCMAKE_BUILD_TYPE=RelWithDebInfo
@@ -45,16 +48,23 @@ set(PACKAGE_VERSION "12")
4548

4649
#-------------------------
4750
# Basic standard paths
51+
52+
# Override the CMAKE_INSTALL_ dirs to be under the build/ directory
53+
if (IN_PLACE)
54+
set(CMAKE_INSTALL_SYSCONFDIR "${CMAKE_BINARY_DIR}/etc")
55+
set(CMAKE_INSTALL_BINDIR "${CMAKE_BINARY_DIR}/bin")
56+
endif()
57+
4858
include(GNUInstallDirs)
4959
# C include root
5060
set(BUILD_INCLUDE ${CMAKE_BINARY_DIR}/include)
5161
# Executables
5262
set(BUILD_BIN ${CMAKE_BINARY_DIR}/bin)
5363
# Libraries
5464
set(BUILD_LIB ${CMAKE_BINARY_DIR}/lib)
65+
# Used for IN_PLACE configuration
66+
set(BUILD_ETC ${CMAKE_BINARY_DIR}/etc)
5567

56-
# Location to place provider .driver files
57-
set(CONFIG_DIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}/libibverbs.d")
5868
set(CMAKE_INSTALL_INITDDIR "${CMAKE_INSTALL_SYSCONFDIR}/init.d"
5969
CACHE PATH "Location for init.d files")
6070
set(CMAKE_INSTALL_SYSTEMD_SERVICEDIR "${CMAKE_INSTALL_PREFIX}/lib/systemd/system"
@@ -87,6 +97,15 @@ else()
8797
set(CMAKE_INSTALL_FULL_UDEV_RULESDIR "${CMAKE_INSTALL_UDEV_RULESDIR}")
8898
endif()
8999

100+
# Location to place provider .driver files
101+
if (IN_PLACE)
102+
set(CONFIG_DIR "${BUILD_ETC}/libibverbs.d")
103+
set(VERBS_PROVIDER_DIR "${BUILD_LIB}")
104+
set(ACM_PROVIDER_DIR "${BUILD_LIB}/ibacm")
105+
else()
106+
set(CONFIG_DIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}/libibverbs.d")
107+
endif()
108+
90109
set(DISTRO_FLAVOUR "None" CACHE
91110
STRING "Flavour of distribution to install for. This primarily impacts the init.d scripts installed.")
92111

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ $ bash build.sh
4242
```
4343

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

4748
NOTE: It is not currently easy to run from the build directory, the plugins
4849
only load from the system path.

build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ fi
2323
cd "$BUILDDIR"
2424

2525
if [ "x$NINJA" == "x" ]; then
26-
$CMAKE ..
26+
$CMAKE -DIN_PLACE=1 ..
2727
make
2828
else
29-
$CMAKE -GNinja ..
29+
$CMAKE -DIN_PLACE=1 -GNinja ..
3030
$NINJA
3131
fi

buildlib/rdma_functions.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ function(rdma_provider DEST)
7979
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${DEST}.driver" DESTINATION "${CONFIG_DIR}")
8080

8181
# Uninstalled driver file
82-
file(MAKE_DIRECTORY "${BUILD_LIB}/libibverbs.d/")
83-
file(WRITE "${BUILD_LIB}/libibverbs.d/${DEST}.driver" "driver ${BUILD_LIB}/${DEST}\n")
82+
file(MAKE_DIRECTORY "${BUILD_ETC}/libibverbs.d/")
83+
file(WRITE "${BUILD_ETC}/libibverbs.d/${DEST}.driver" "driver ${BUILD_LIB}/lib${DEST}\n")
8484

8585
# Create a static provider library
8686
# FIXME: This is probably pointless, the provider library has no symbols so

ibacm/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ target_link_libraries(ibacmp LINK_PRIVATE
3636
set_target_properties(ibacmp PROPERTIES
3737
LIBRARY_OUTPUT_DIRECTORY "${BUILD_LIB}")
3838
install(TARGETS ibacmp DESTINATION "${ACM_PROVIDER_DIR}")
39+
# ACM providers are linked into a subdir so that IN_PLACE can work.
40+
file(MAKE_DIRECTORY "${BUILD_LIB}/ibacm/")
41+
execute_process(COMMAND "${CMAKE_COMMAND}" -E create_symlink
42+
"../libibacmp.so"
43+
"${BUILD_LIB}/ibacm/libibacmp.so")
3944

4045
rdma_executable(ib_acme
4146
src/acme.c

0 commit comments

Comments
 (0)