Skip to content

Commit

Permalink
build: Pass extra cmake flags
Browse files Browse the repository at this point in the history
Add ability to provide extra cmake flags when building library
and when creating RPMs or DEBs using EXTRA_CMAKE_FLAGS.

Set an environment variable prior execution to provide
this information to build scripts:
export EXTRA_CMAKE_FLAGS="<flags>"

Cc: Benjamin Drung <benjamin.drung@profitbricks.com>
Cc: Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.de>
Signed-off-by: Alaa Hleihel <alaa@mellanox.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Doug Ledford <dledford@redhat.com>
  • Loading branch information
alaahl authored and dledford committed Feb 4, 2018
1 parent c7f4e44 commit 66a625a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
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 -DIN_PLACE=1 ..
$CMAKE -DIN_PLACE=1 ${EXTRA_CMAKE_FLAGS:-} ..
make
else
$CMAKE -DIN_PLACE=1 -GNinja ..
$CMAKE -DIN_PLACE=1 -GNinja ${EXTRA_CMAKE_FLAGS:-} ..
$NINJA
fi
3 changes: 2 additions & 1 deletion debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ override_dh_auto_configure:
-DCMAKE_INSTALL_LIBEXECDIR:PATH=/usr/lib \
-DCMAKE_INSTALL_SHAREDSTATEDIR:PATH=/var/lib \
-DCMAKE_INSTALL_RUNDIR:PATH=/run \
-DCMAKE_INSTALL_UDEV_RULESDIR:PATH=/lib/udev/rules.d
-DCMAKE_INSTALL_UDEV_RULESDIR:PATH=/lib/udev/rules.d \
$(EXTRA_CMAKE_FLAGS)

override_dh_auto_build:
ninja -C build-deb -v
Expand Down
5 changes: 4 additions & 1 deletion redhat/rdma-core.spec
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ discover and use SCSI devices via the SCSI RDMA Protocol over InfiniBand.
%define _rundir /var/run
%endif

%{!?EXTRA_CMAKE_FLAGS: %define EXTRA_CMAKE_FLAGS %{nil}}

# Pass all of the rpm paths directly to GNUInstallDirs and our other defines.
%cmake %{CMAKE_FLAGS} \
-DCMAKE_BUILD_TYPE=Release \
Expand All @@ -222,7 +224,8 @@ discover and use SCSI devices via the SCSI RDMA Protocol over InfiniBand.
-DCMAKE_INSTALL_INITDDIR:PATH=%{_initrddir} \
-DCMAKE_INSTALL_RUNDIR:PATH=%{_rundir} \
-DCMAKE_INSTALL_DOCDIR:PATH=%{_docdir}/%{name}-%{version} \
-DCMAKE_INSTALL_UDEV_RULESDIR:PATH=%{_udevrulesdir}
-DCMAKE_INSTALL_UDEV_RULESDIR:PATH=%{_udevrulesdir} \
%{EXTRA_CMAKE_FLAGS}
%make_jobs

%install
Expand Down
5 changes: 4 additions & 1 deletion suse/rdma-core.spec
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,8 @@ on those changes.
%define _rundir /var/run
%endif

%{!?EXTRA_CMAKE_FLAGS: %define EXTRA_CMAKE_FLAGS %{nil}}

# Pass all of the rpm paths directly to GNUInstallDirs and our other defines.
%cmake %{CMAKE_FLAGS} \
-DCMAKE_MODULE_LINKER_FLAGS="-Wl,--as-needed -Wl,-z,now" \
Expand All @@ -338,7 +340,8 @@ on those changes.
-DCMAKE_INSTALL_INITDDIR:PATH=%{_initddir} \
-DCMAKE_INSTALL_RUNDIR:PATH=%{_rundir} \
-DCMAKE_INSTALL_DOCDIR:PATH=%{_docdir}/%{name}-%{version} \
-DCMAKE_INSTALL_UDEV_RULESDIR:PATH=%{_udevrulesdir}
-DCMAKE_INSTALL_UDEV_RULESDIR:PATH=%{_udevrulesdir} \
%{EXTRA_CMAKE_FLAGS}
%make_jobs

%install
Expand Down

0 comments on commit 66a625a

Please sign in to comment.