diff mbox series

[v2,7/8] kernel-shark: Remove hard-coded install paths for libraries and plugins

Message ID 20190502124009.32208-8-ykaradzhov@vmware.com (mailing list archive)
State Superseded
Headers show
Series Modifications needed for KS 1.0 | expand

Commit Message

Yordan Karadzhov May 2, 2019, 12:40 p.m. UTC
The definition of KS_APP_NAME is used to derive standard installation
paths for the KernelShark libraries and plugins.

Suggested-by: Troy Engel <troyengel@gmail.com>
Signed-off-by: Yordan Karadzhov <ykaradzhov@vmware.com>
---
 kernel-shark/CMakeLists.txt             |  7 +++++--
 kernel-shark/build/deff.h.cmake         |  3 +++
 kernel-shark/src/CMakeLists.txt         | 12 ++++++------
 kernel-shark/src/KsUtils.cpp            |  4 ++--
 kernel-shark/src/plugins/CMakeLists.txt |  3 +--
 5 files changed, 17 insertions(+), 12 deletions(-)
diff mbox series

Patch

diff --git a/kernel-shark/CMakeLists.txt b/kernel-shark/CMakeLists.txt
index 1aee858..64f7de8 100644
--- a/kernel-shark/CMakeLists.txt
+++ b/kernel-shark/CMakeLists.txt
@@ -4,6 +4,7 @@  cmake_minimum_required(VERSION 2.8.11 FATAL_ERROR)
 # Set the name and version of the project
 project(kernel-shark)
 
+set(KS_APP_NAME "kernelshark")
 set(KS_VERSION_MAJOR 0)
 set(KS_VERSION_MINOR 9)
 set(KS_VERSION_PATCH 8)
@@ -39,6 +40,8 @@  if(NOT _INSTALL_PREFIX)
 	set(_INSTALL_PREFIX "/usr/local")
 endif()
 
+set(KS_PLUGIN_INSTALL_PREFIX ${_INSTALL_PREFIX}/lib/${KS_APP_NAME}/plugins/)
+
 if (NOT _DEBUG)
 
 	set(CMAKE_C_FLAGS   "${CMAKE_C_FLAGS} -O2")
@@ -46,7 +49,7 @@  if (NOT _DEBUG)
 
 endif (NOT _DEBUG)
 
-SET(CMAKE_INSTALL_RPATH "${_INSTALL_PREFIX}/lib/kshark/")
+SET(CMAKE_INSTALL_RPATH "${_INSTALL_PREFIX}/lib/${KS_APP_NAME}/")
 SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
 
 include_directories(${KS_DIR}/src/
@@ -79,7 +82,7 @@  if (_DOXYGEN_DOC AND DOXYGEN_FOUND)
 endif ()
 
 configure_file( ${KS_DIR}/build/ks.desktop.cmake
-                ${KS_DIR}/kernelshark.desktop)
+                ${KS_DIR}/${KS_APP_NAME}.desktop)
 
 configure_file( ${KS_DIR}/build/org.freedesktop.kshark-record.policy.cmake
                 ${KS_DIR}/org.freedesktop.kshark-record.policy)
diff --git a/kernel-shark/build/deff.h.cmake b/kernel-shark/build/deff.h.cmake
index 1cf8a80..efee2a1 100644
--- a/kernel-shark/build/deff.h.cmake
+++ b/kernel-shark/build/deff.h.cmake
@@ -14,6 +14,9 @@ 
 /** KernelShark installation prefix path. */
 #cmakedefine _INSTALL_PREFIX "@_INSTALL_PREFIX@"
 
+/** KernelShark plugins installation prefix path. */
+#cmakedefine KS_PLUGIN_INSTALL_PREFIX "@KS_PLUGIN_INSTALL_PREFIX@"
+
 /** Location of the trace-cmd executable. */
 #cmakedefine TRACECMD_BIN_DIR "@TRACECMD_BIN_DIR@"
 
diff --git a/kernel-shark/src/CMakeLists.txt b/kernel-shark/src/CMakeLists.txt
index b7dbd7e..2f28cae 100644
--- a/kernel-shark/src/CMakeLists.txt
+++ b/kernel-shark/src/CMakeLists.txt
@@ -69,19 +69,19 @@  if (Qt5Widgets_FOUND AND Qt5Network_FOUND)
 
     set_target_properties(kshark-gui PROPERTIES  SUFFIX ".so.${KS_VERSION_STRING}")
 
-    message(STATUS "kernelshark")
-    add_executable(kernelshark          kernelshark.cpp)
-    target_link_libraries(kernelshark   kshark-gui)
+    message(STATUS ${KS_APP_NAME})
+    add_executable(${KS_APP_NAME}          kernelshark.cpp)
+    target_link_libraries(${KS_APP_NAME}   kshark-gui)
 
     message(STATUS "kshark-record")
     add_executable(kshark-record        kshark-record.cpp)
     target_link_libraries(kshark-record kshark-gui)
 
-    install(TARGETS kernelshark kshark-record kshark kshark-plot kshark-gui
+    install(TARGETS ${KS_APP_NAME} kshark-record kshark kshark-plot kshark-gui
             RUNTIME DESTINATION ${_INSTALL_PREFIX}/bin/
-            LIBRARY DESTINATION ${_INSTALL_PREFIX}/lib/kshark/)
+            LIBRARY DESTINATION ${_INSTALL_PREFIX}/lib/${KS_APP_NAME}/)
 
-    install(FILES "${KS_DIR}/kernelshark.desktop"
+    install(FILES "${KS_DIR}/${KS_APP_NAME}.desktop"
             DESTINATION /usr/share/applications/)
 
     install(FILES "${KS_DIR}/org.freedesktop.kshark-record.policy"
diff --git a/kernel-shark/src/KsUtils.cpp b/kernel-shark/src/KsUtils.cpp
index ee481bf..e2091be 100644
--- a/kernel-shark/src/KsUtils.cpp
+++ b/kernel-shark/src/KsUtils.cpp
@@ -621,8 +621,8 @@  char *KsPluginManager::_pluginLibFromName(const QString &plugin, int &n)
 		n = asprintf(&lib, "%s/plugin-%s.so",
 			     pathStr.c_str(), pluginStr.c_str());
 	} else {
-		n = asprintf(&lib, "%s/lib/kshark/plugins/plugin-%s.so",
-			     _INSTALL_PREFIX, pluginStr.c_str());
+		n = asprintf(&lib, "%s/plugin-%s.so",
+			     KS_PLUGIN_INSTALL_PREFIX, pluginStr.c_str());
 	}
 
 	return lib;
diff --git a/kernel-shark/src/plugins/CMakeLists.txt b/kernel-shark/src/plugins/CMakeLists.txt
index 64cf98d..6c77179 100644
--- a/kernel-shark/src/plugins/CMakeLists.txt
+++ b/kernel-shark/src/plugins/CMakeLists.txt
@@ -18,7 +18,6 @@  function(BUILD_PLUGIN)
 endfunction()
 
 set(PLUGIN_LIST "")
-
 BUILD_PLUGIN(NAME sched_events
              SOURCE sched_events.c SchedEvents.cpp)
 list(APPEND PLUGIN_LIST "sched_events default") # This plugin will be loaded by default
@@ -29,6 +28,6 @@  BUILD_PLUGIN(NAME missed_events
 list(APPEND PLUGIN_LIST "missed_events default") # This plugin will be loaded by default
 
 install(TARGETS sched_events missed_events
-        LIBRARY DESTINATION ${_INSTALL_PREFIX}/lib/kshark/plugins/)
+        LIBRARY DESTINATION ${KS_PLUGIN_INSTALL_PREFIX})
 
 set(PLUGINS ${PLUGIN_LIST} PARENT_SCOPE)