diff mbox series

[1/2] kernel-shark: Avoid TRACECMD_BIN_DIR being set to the build path

Message ID 20190611152043.22572-2-ykaradzhov@vmware.com (mailing list archive)
State Superseded
Headers show
Series KernelShark build fixes for v1.0 | expand

Commit Message

Yordan Karadzhov June 11, 2019, 3:20 p.m. UTC
The full path to the build directory (which is random for every user)
is embedded in the final binary. This is a no-no for some Linux distros
which are requiring that the finished binaries should not have such paths
embedded in them.

Reported-by: Troy Engel <troyengel@gmail.com>
Signed-off-by: Yordan Karadzhov <ykaradzhov@vmware.com>
---
 kernel-shark/build/FindTraceCmd.cmake | 14 +++++++++-----
 kernel-shark/build/deff.h.cmake       |  2 +-
 kernel-shark/src/KsCaptureDialog.cpp  | 13 ++++++++-----
 3 files changed, 18 insertions(+), 11 deletions(-)
diff mbox series

Patch

diff --git a/kernel-shark/build/FindTraceCmd.cmake b/kernel-shark/build/FindTraceCmd.cmake
index 8c51f11..3d11347 100644
--- a/kernel-shark/build/FindTraceCmd.cmake
+++ b/kernel-shark/build/FindTraceCmd.cmake
@@ -12,10 +12,14 @@ 
 # MESSAGE(" Looking for trace-cmd ...")
 
 # First search in the user provided paths.
-find_path(TRACECMD_BIN_DIR      NAMES  trace-cmd
-                                PATHS  $ENV{TRACE_CMD}/tracecmd/
-                                       ${CMAKE_SOURCE_DIR}/../tracecmd/
-                                NO_DEFAULT_PATH)
+if (NOT CMAKE_BUILD_TYPE MATCHES Release)
+
+  find_program(TRACECMD_EXECUTABLE   NAMES  trace-cmd
+                                     PATHS  $ENV{TRACE_CMD}/tracecmd/
+                                            ${CMAKE_SOURCE_DIR}/../tracecmd/
+                                     NO_DEFAULT_PATH)
+
+endif (NOT CMAKE_BUILD_TYPE MATCHES Release)
 
 find_path(TRACECMD_INCLUDE_DIR  NAMES  trace-cmd/trace-cmd.h
                                 PATHS  $ENV{TRACE_CMD}/include/
@@ -34,7 +38,7 @@  find_library(TRACEEVENT_LIBRARY NAMES  traceevent/libtraceevent.a
 
 # If not found, search in the default system paths. Note that if the previous
 # search was successful "find_path" will do nothing this time.
-find_path(TRACECMD_BIN_DIR      NAMES  trace-cmd)
+find_program(TRACECMD_EXECUTABLE   NAMES  trace-cmd)
 find_path(TRACECMD_INCLUDE_DIR  NAMES  trace-cmd/trace-cmd.h)
 find_library(TRACECMD_LIBRARY   NAMES  trace-cmd/libtracecmd.so)
 find_library(TRACEEVENT_LIBRARY NAMES  traceevent/libtraceevent.so)
diff --git a/kernel-shark/build/deff.h.cmake b/kernel-shark/build/deff.h.cmake
index efee2a1..79726ff 100644
--- a/kernel-shark/build/deff.h.cmake
+++ b/kernel-shark/build/deff.h.cmake
@@ -18,7 +18,7 @@ 
 #cmakedefine KS_PLUGIN_INSTALL_PREFIX "@KS_PLUGIN_INSTALL_PREFIX@"
 
 /** Location of the trace-cmd executable. */
-#cmakedefine TRACECMD_BIN_DIR "@TRACECMD_BIN_DIR@"
+#cmakedefine TRACECMD_EXECUTABLE "@TRACECMD_EXECUTABLE@"
 
 /** "pkexec" executable. */
 #cmakedefine DO_AS_ROOT "@DO_AS_ROOT@"
diff --git a/kernel-shark/src/KsCaptureDialog.cpp b/kernel-shark/src/KsCaptureDialog.cpp
index b107595..96ab3e2 100644
--- a/kernel-shark/src/KsCaptureDialog.cpp
+++ b/kernel-shark/src/KsCaptureDialog.cpp
@@ -489,12 +489,15 @@  KsCaptureDialog::KsCaptureDialog(QWidget *parent)
 	connect(&_captureCtrl._closeButton,	&QPushButton::pressed,
 		this,				&KsCaptureDialog::close);
 
-	if (KsUtils::isInstalled())
-		captureExe = QString(_INSTALL_PREFIX) + QString("/bin");
-	else
-		captureExe = TRACECMD_BIN_DIR;
+	captureExe = QString(_INSTALL_PREFIX) + QString("/bin/trace-cmd");
+
+#ifdef TRACECMD_EXECUTABLE
+
+	if (!KsUtils::isInstalled())
+		captureExe = TRACECMD_EXECUTABLE;
+
+#endif
 
-	captureExe += "/trace-cmd";
 	_captureProc.setProgram(captureExe);
 
 	_captureMon.connectMe(&_captureProc, &_captureCtrl);