[v2,2/3] kernel-shark: Avoid TRACECMD_BIN_DIR being set to the build path
diff mbox series

Message ID 20190614132609.16465-3-ykaradzhov@vmware.com
State Accepted
Headers show
Series
  • KernelShark build fixes for v1.0
Related show

Commit Message

Yordan Karadzhov June 14, 2019, 1:26 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 | 18 +++++++++++-------
 kernel-shark/build/deff.h.cmake       |  2 +-
 kernel-shark/src/KsCaptureDialog.cpp  |  7 +++----
 3 files changed, 15 insertions(+), 12 deletions(-)

Patch
diff mbox series

diff --git a/kernel-shark/build/FindTraceCmd.cmake b/kernel-shark/build/FindTraceCmd.cmake
index 8c51f11..2da4eee 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 (CMAKE_BUILD_TYPE MATCHES Debug)
+
+  find_program(TRACECMD_EXECUTABLE   NAMES  trace-cmd
+                                     PATHS  $ENV{TRACE_CMD}/tracecmd/
+                                            ${CMAKE_SOURCE_DIR}/../tracecmd/
+                                     NO_DEFAULT_PATH)
+
+endif (CMAKE_BUILD_TYPE MATCHES Debug)
 
 find_path(TRACECMD_INCLUDE_DIR  NAMES  trace-cmd/trace-cmd.h
                                 PATHS  $ENV{TRACE_CMD}/include/
@@ -34,16 +38,16 @@  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)
 
-IF (TRACECMD_INCLUDE_DIR AND TRACECMD_LIBRARY)
+IF (TRACECMD_INCLUDE_DIR AND TRACECMD_LIBRARY AND TRACECMD_EXECUTABLE)
 
   SET(TRACECMD_FOUND TRUE)
 
-ENDIF (TRACECMD_INCLUDE_DIR AND TRACECMD_LIBRARY)
+ENDIF (TRACECMD_INCLUDE_DIR AND TRACECMD_LIBRARY AND TRACECMD_EXECUTABLE)
 
 IF (TRACECMD_FOUND)
 
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..7f8cf64 100644
--- a/kernel-shark/src/KsCaptureDialog.cpp
+++ b/kernel-shark/src/KsCaptureDialog.cpp
@@ -489,12 +489,11 @@  KsCaptureDialog::KsCaptureDialog(QWidget *parent)
 	connect(&_captureCtrl._closeButton,	&QPushButton::pressed,
 		this,				&KsCaptureDialog::close);
 
-	if (KsUtils::isInstalled())
-		captureExe = QString(_INSTALL_PREFIX) + QString("/bin");
+	if (!KsUtils::isInstalled())
+		captureExe = QString(_INSTALL_PREFIX) + QString("/bin/trace-cmd");
 	else
-		captureExe = TRACECMD_BIN_DIR;
+		captureExe = TRACECMD_EXECUTABLE;
 
-	captureExe += "/trace-cmd";
 	_captureProc.setProgram(captureExe);
 
 	_captureMon.connectMe(&_captureProc, &_captureCtrl);