diff --git a/Makefile b/Makefile index 8626b91b..7dc3406e 100644 --- a/Makefile +++ b/Makefile @@ -300,7 +300,7 @@ CMAKE_COMMAND = /usr/bin/cmake BUILD_TYPE ?= RelWithDebInfo $(kshark-dir)/build/Makefile: $(kshark-dir)/CMakeLists.txt - $(Q) cd $(kshark-dir)/build && $(CMAKE_COMMAND) -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -D_INSTALL_PREFIX=$(prefix) -D_LIBDIR=$(libdir) .. + $(Q) mkdir -p $(kshark-dir)/build && cd $(kshark-dir)/build && $(CMAKE_COMMAND) -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DCMAKE_INSTALL_PREFIX=$(prefix) -DCMAKE_INSTALL_LIBDIR=$(libdir) .. gui: force $(MAKE) $(CMD_TARGETS) @@ -452,8 +452,7 @@ clean: $(MAKE) -C $(src)/utest clean $(MAKE) -C $(src)/python clean $(MAKE) -C $(src)/tracecmd clean - if [ -f $(kshark-dir)/build/Makefile ]; then $(MAKE) -C $(kshark-dir)/build clean; fi - cd $(kshark-dir)/build; ./cmake_clean.sh + rm -rf $(kshark-dir)/build ##### PYTHON STUFF ##### diff --git a/kernel-shark/CMakeLists.txt b/kernel-shark/CMakeLists.txt index c95249e9..26e271c2 100644 --- a/kernel-shark/CMakeLists.txt +++ b/kernel-shark/CMakeLists.txt @@ -1,45 +1,31 @@ # Check if cmake has the required version -cmake_minimum_required(VERSION 2.8.11 FATAL_ERROR) +cmake_minimum_required(VERSION 3.4.3 FATAL_ERROR) -# Set the name and version of the project -project(kernel-shark) +set(VERSION_MAJOR 1) +set(VERSION_MINOR 2) +set(VERSION_PATCH 0) -set(KS_APP_NAME "kernelshark") -set(KS_VERSION_MAJOR 1) -set(KS_VERSION_MINOR 2) -set(KS_VERSION_PATCH 0) -set(KS_VERSION_STRING ${KS_VERSION_MAJOR}.${KS_VERSION_MINOR}.${KS_VERSION_PATCH}) -message("\n project: Kernel Shark: (version: ${KS_VERSION_STRING})\n") +project( + kernelshark + VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} +) -set(KS_DIR ${CMAKE_SOURCE_DIR}) - -if (NOT _INSTALL_PREFIX) - set(_INSTALL_PREFIX "/usr/local") -endif (NOT _INSTALL_PREFIX) - -if (NOT _LIBDIR) - set(_LIBDIR "${_INSTALL_PREFIX}/lib") -endif (NOT _LIBDIR) - -include(${KS_DIR}/build/FindTraceCmd.cmake) -include(${KS_DIR}/build/FindJSONC.cmake) - -find_package(Doxygen) +include(GNUInstallDirs) +include(cmake/FindTraceCmd.cmake) +include(cmake/FindJSONC.cmake) set(OpenGL_GL_PREFERENCE LEGACY) find_package(OpenGL) find_package(GLUT) - find_package(Qt5Widgets 5.7.1) -find_package(Qt5Network) if (Qt5Widgets_FOUND) - message(STATUS "Found Qt5Widgets: (version ${Qt5Widgets_VERSION})") - endif (Qt5Widgets_FOUND) +find_package(Qt5Network) +find_package(Doxygen) +find_program(DO_AS_ROOT pkexec) -set(LIBRARY_OUTPUT_PATH "${KS_DIR}/lib") -set(EXECUTABLE_OUTPUT_PATH "${KS_DIR}/bin") +option("DOCUMENTATION" OFF) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pthread -fPIC") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11 -pthread -fPIC") @@ -58,58 +44,40 @@ if (NOT CMAKE_CXX_FLAGS_PACKAGE) set(CMAKE_CXX_FLAGS_PACKAGE "-O3") endif (NOT CMAKE_CXX_FLAGS_PACKAGE) -set(KS_PLUGIN_INSTALL_PREFIX ${_LIBDIR}/${KS_APP_NAME}/plugins/) - -set(KS_ICON KS_icon_shark.svg) -set(KS_ICON_FIN KS_icon_fin.svg) -set(KS_LOGO KS_logo_symbol.svg) -set(KS_LOGO_LABEL KS_logo_horizontal.svg) - -set(CMAKE_INSTALL_RPATH "${_LIBDIR}/${KS_APP_NAME}/") +set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}/") -if (CMAKE_BUILD_TYPE MATCHES Package) +if(CMAKE_BUILD_TYPE MATCHES Package) set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) -else (CMAKE_BUILD_TYPE MATCHES Package) +else(CMAKE_BUILD_TYPE MATCHES Package) set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) -endif (CMAKE_BUILD_TYPE MATCHES Package) +endif(CMAKE_BUILD_TYPE MATCHES Package) -include_directories(${KS_DIR}/src/ - ${KS_DIR}/build/src/ - ${JSONC_INCLUDE_DIR} - ${TRACECMD_INCLUDE_DIR} - ${TRACEFS_INCLUDE_DIR}) +include_directories( + src/ + ../lib/trace-cmd/include/private/ + ${CMAKE_CURRENT_BINARY_DIR}/src/ + ${JSONC_INCLUDE_DIR} + ${TRACECMD_INCLUDE_DIR} + ${TRACEFS_INCLUDE_DIR} +) -message("") message(STATUS "C flags : " ${CMAKE_C_FLAGS}) message(STATUS "CXX flags : " ${CMAKE_CXX_FLAGS}) message(STATUS "Linker flags : " ${CMAKE_EXE_LINKER_FLAGS}) -add_subdirectory(${KS_DIR}/src) -add_subdirectory(${KS_DIR}/examples) - -if (_DOXYGEN_DOC AND DOXYGEN_FOUND) - - message("\n doxygen documentation ...") - add_custom_target(doc ALL) - add_custom_command(TARGET doc - COMMAND doxygen dox_config > dox_build.log - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/Documentation/doxygen) - - set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES - "${KS_DIR}/Documentation/doxygen/dox_build.log" - "${KS_DIR}/Documentation/doxygen/html" - "${KS_DIR}/Documentation/doxygen/latex") - -endif () - -configure_file( ${KS_DIR}/build/ks.desktop.cmake - ${KS_DIR}/${KS_APP_NAME}.desktop) - -configure_file( ${KS_DIR}/build/org.freedesktop.kshark-record.policy.cmake - ${KS_DIR}/org.freedesktop.kshark-record.policy) - -message("") +add_definitions( + -DKS_VERSION_STRING="${PROJECT_VERSION}" + -D_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}" + -DKS_PLUGIN_INSTALL_PREFIX="${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}/plugins/" + -DTRACECMD_EXECUTABLE="${TRACECMD_EXECUTABLE}" +) + +add_subdirectory(src) +add_subdirectory(bin) +add_subdirectory(examples) +add_subdirectory(contrib) +add_subdirectory(Documentation) diff --git a/kernel-shark/Documentation/CMakeLists.txt b/kernel-shark/Documentation/CMakeLists.txt new file mode 100644 index 00000000..5ea2e410 --- /dev/null +++ b/kernel-shark/Documentation/CMakeLists.txt @@ -0,0 +1,14 @@ +if(${DOXYGEN_FOUND}) + message(STATUS "Build doxygen documentation ...") + add_custom_target(doc ALL) + add_custom_command( + TARGET doc + COMMAND doxygen dox_config > dox_build.log + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/Documentation/doxygen + ) + add_custom_command( + TARGET doc + COMMAND mv html/ latex/ dox_build.log ${CMAKE_CURRENT_BINARY_DIR}/ + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/Documentation/doxygen + ) +endif() diff --git a/kernel-shark/Documentation/doxygen/dox_config b/kernel-shark/Documentation/doxygen/dox_config index 89b92842..1efb7ba5 100644 --- a/kernel-shark/Documentation/doxygen/dox_config +++ b/kernel-shark/Documentation/doxygen/dox_config @@ -13,4 +13,4 @@ CASE_SENSE_NAMES = YES SORT_MEMBER_DOCS = NO STRICT_PROTO_MATCHING = YES DOT_MULTI_TARGETS = YES -PROJECT_LOGO = ../../icons/KS_logo_stacked.svg +PROJECT_LOGO = ../../contrib/icons/KS_logo_stacked.svg diff --git a/kernel-shark/README b/kernel-shark/README index 6c360bb1..8d9717e1 100644 --- a/kernel-shark/README +++ b/kernel-shark/README @@ -67,6 +67,7 @@ the option BUILD_TYPE= to the make process. tree before performing the following) make + mkdir -p kernel-shark/build cd kernel-shark/build cmake ../ make @@ -102,11 +103,10 @@ Examples: cmake -DCMAKE_BUILD_TYPE=Package -DCMAKE_C_FLAGS_PACKAGE="-O3 -pedantic" ../ -2.1.2.4 Use the script "cmake_clean.sh" if you want to delete all already +2.1.2.4 Remove the build directory if you want to delete all already compiled objects and all files generated by CMake. - cd kernel-shark/build - ./cmake-clean.sh + rm -rf kernel-shark/build 3. After building the code "kernel-shark/lib" will contain all libraries and "kernel-shark/bin" will contain all executables. diff --git a/kernel-shark/bin/CMakeLists.txt b/kernel-shark/bin/CMakeLists.txt new file mode 100644 index 00000000..955bb814 --- /dev/null +++ b/kernel-shark/bin/CMakeLists.txt @@ -0,0 +1,6 @@ +if(Qt5Widgets_FOUND AND Qt5Network_FOUND) + install( + PROGRAMS kshark-su-record + DESTINATION ${CMAKE_INSTALL_BINDIR}/ + ) +endif(Qt5Widgets_FOUND AND Qt5Network_FOUND) diff --git a/kernel-shark/bin/kshark-su-record b/kernel-shark/bin/kshark-su-record index 70d781d8..4056cf79 100755 --- a/kernel-shark/bin/kshark-su-record +++ b/kernel-shark/bin/kshark-su-record @@ -1,5 +1,5 @@ -#!/bin/bash +#!/usr/bin/env bash xhost +si:localuser:root &>/dev/null -pkexec kshark-record -o ${PWD}/trace.dat +pkexec kshark-record -o "${PWD}/trace.dat" diff --git a/kernel-shark/build/cmake_clean.sh b/kernel-shark/build/cmake_clean.sh deleted file mode 100755 index 2e7c8f94..00000000 --- a/kernel-shark/build/cmake_clean.sh +++ /dev/null @@ -1,13 +0,0 @@ -make clean -rm CMakeCache.txt -rm cmake_install.cmake -rm Makefile -rm -rf CMakeFiles/ -rm -rf src/ -rm -rf examples/ -rm -f ../lib/* -rm ../kernelshark.desktop -rm ../org.freedesktop.kshark-record.policy -rm -f ../src/KsCmakeDef.hpp -rm -f CMakeDoxyfile.in -rm -f CMakeDoxygenDefaults.cmake diff --git a/kernel-shark/build/cmake_uninstall.sh b/kernel-shark/build/cmake_uninstall.sh deleted file mode 100755 index ae9eab5b..00000000 --- a/kernel-shark/build/cmake_uninstall.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -CYAN='\e[36m' -PURPLE='\e[35m' -NC='\e[0m' # No Color - -if [[ $EUID -ne 0 ]]; then - echo -e "${PURPLE}Permission denied${NC}" 1>&2 - exit 100 -fi - -if [ -e install_manifest.txt ] -then - echo -e "${CYAN}Uninstall the project...${NC}" - xargs rm -v < install_manifest.txt - rm -f install_manifest.txt -fi diff --git a/kernel-shark/build/ks.desktop.cmake b/kernel-shark/build/ks.desktop.cmake deleted file mode 100644 index 2b02c0db..00000000 --- a/kernel-shark/build/ks.desktop.cmake +++ /dev/null @@ -1,10 +0,0 @@ -[Desktop Entry] -Version=@KS_VERSION_STRING@ -Type=Application -Name=Kernel Shark -GenericName=Kernel Shark -Comment= -Exec=@_INSTALL_PREFIX@/bin/@KS_APP_NAME@ -Icon=@_INSTALL_PREFIX@/share/icons/@KS_APP_NAME@/@KS_ICON@ -Categories=System; -Terminal=false diff --git a/kernel-shark/build/FindJSONC.cmake b/kernel-shark/cmake/FindJSONC.cmake similarity index 100% rename from kernel-shark/build/FindJSONC.cmake rename to kernel-shark/cmake/FindJSONC.cmake diff --git a/kernel-shark/build/FindTraceCmd.cmake b/kernel-shark/cmake/FindTraceCmd.cmake similarity index 100% rename from kernel-shark/build/FindTraceCmd.cmake rename to kernel-shark/cmake/FindTraceCmd.cmake diff --git a/kernel-shark/contrib/CMakeLists.txt b/kernel-shark/contrib/CMakeLists.txt new file mode 100644 index 00000000..bebf9cc8 --- /dev/null +++ b/kernel-shark/contrib/CMakeLists.txt @@ -0,0 +1,24 @@ +configure_file( + ${PROJECT_NAME}.desktop.in + ${PROJECT_NAME}.desktop +) + +configure_file( + org.freedesktop.kshark-record.policy.in + org.freedesktop.kshark-record.policy +) + +install( + FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.desktop" + DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/applications/ +) + +install( + FILES "icons/${PROJECT_NAME}.svg" + DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/apps/" +) + +install( + FILES "${CMAKE_CURRENT_BINARY_DIR}/org.freedesktop.kshark-record.policy" + DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/polkit-1/actions/" +) diff --git a/kernel-shark/icons/CC_BY-4.0 b/kernel-shark/contrib/icons/CC_BY-4.0 similarity index 100% rename from kernel-shark/icons/CC_BY-4.0 rename to kernel-shark/contrib/icons/CC_BY-4.0 diff --git a/kernel-shark/icons/KS_icon_fin.svg b/kernel-shark/contrib/icons/KS_icon_fin.svg similarity index 100% rename from kernel-shark/icons/KS_icon_fin.svg rename to kernel-shark/contrib/icons/KS_icon_fin.svg diff --git a/kernel-shark/icons/KS_logo_horizontal.svg b/kernel-shark/contrib/icons/KS_logo_horizontal.svg similarity index 100% rename from kernel-shark/icons/KS_logo_horizontal.svg rename to kernel-shark/contrib/icons/KS_logo_horizontal.svg diff --git a/kernel-shark/icons/KS_logo_stacked.svg b/kernel-shark/contrib/icons/KS_logo_stacked.svg similarity index 100% rename from kernel-shark/icons/KS_logo_stacked.svg rename to kernel-shark/contrib/icons/KS_logo_stacked.svg diff --git a/kernel-shark/icons/KS_logo_symbol.svg b/kernel-shark/contrib/icons/KS_logo_symbol.svg similarity index 100% rename from kernel-shark/icons/KS_logo_symbol.svg rename to kernel-shark/contrib/icons/KS_logo_symbol.svg diff --git a/kernel-shark/icons/KS_icon_shark.svg b/kernel-shark/contrib/icons/kernelshark.svg similarity index 100% rename from kernel-shark/icons/KS_icon_shark.svg rename to kernel-shark/contrib/icons/kernelshark.svg diff --git a/kernel-shark/icons/ksharkicon.png b/kernel-shark/contrib/icons/ksharkicon.png similarity index 100% rename from kernel-shark/icons/ksharkicon.png rename to kernel-shark/contrib/icons/ksharkicon.png diff --git a/kernel-shark/contrib/kernelshark.desktop.in b/kernel-shark/contrib/kernelshark.desktop.in new file mode 100644 index 00000000..e28a6c56 --- /dev/null +++ b/kernel-shark/contrib/kernelshark.desktop.in @@ -0,0 +1,10 @@ +[Desktop Entry] +Version=@PROJECT_VERSION@ +Type=Application +Name=Kernel Shark +GenericName=Kernel Shark +Comment= +Exec=@CMAKE_INSTALL_BINDIR@/@PROJECT_NAME@ +Icon=@PROJECT_NAME@ +Categories=System; +Terminal=false diff --git a/kernel-shark/build/org.freedesktop.kshark-record.policy.cmake b/kernel-shark/contrib/org.freedesktop.kshark-record.policy.in similarity index 86% rename from kernel-shark/build/org.freedesktop.kshark-record.policy.cmake rename to kernel-shark/contrib/org.freedesktop.kshark-record.policy.in index 988db782..fbd0f874 100644 --- a/kernel-shark/build/org.freedesktop.kshark-record.policy.cmake +++ b/kernel-shark/contrib/org.freedesktop.kshark-record.policy.in @@ -11,7 +11,7 @@ auth_admin auth_admin - @_INSTALL_PREFIX@/bin/kshark-record + @CMAKE_INSTALL_BINDIR@/kshark-record true diff --git a/kernel-shark/examples/CMakeLists.txt b/kernel-shark/examples/CMakeLists.txt index 032f3057..570c7b80 100644 --- a/kernel-shark/examples/CMakeLists.txt +++ b/kernel-shark/examples/CMakeLists.txt @@ -1,33 +1,31 @@ -message("\n examples ...") +message(STATUS "Building examples ...") -message(STATUS "dataload") -add_executable(dload dataload.c) -target_link_libraries(dload kshark) +message(STATUS "Building dload") +add_executable(dload dataload.c) +target_link_libraries(dload kshark) -message(STATUS "datafilter") -add_executable(dfilter datafilter.c) -target_link_libraries(dfilter kshark) +message(STATUS "Building dfilter") +add_executable(dfilter datafilter.c) +target_link_libraries(dfilter kshark) -message(STATUS "datahisto") -add_executable(dhisto datahisto.c) -target_link_libraries(dhisto kshark) +message(STATUS "Building dhisto") +add_executable(dhisto datahisto.c) +target_link_libraries(dhisto kshark) -message(STATUS "confogio") -add_executable(confio configio.c) -target_link_libraries(confio kshark) +message(STATUS "Building confio") +add_executable(confio configio.c) +target_link_libraries(confio kshark) -message(STATUS "dataplot") -add_executable(dplot dataplot.cpp) -target_link_libraries(dplot kshark-plot) +message(STATUS "Building dplot") +add_executable(dplot dataplot.cpp) +target_link_libraries(dplot kshark-plot) -if (Qt5Widgets_FOUND) +if(Qt5Widgets_FOUND) + message(STATUS "Building widgetdemo") + add_executable(widgetdemo widgetdemo.cpp) + target_link_libraries(widgetdemo kshark-gui) - message(STATUS "widgetdemo") - add_executable(widgetdemo widgetdemo.cpp) - target_link_libraries(widgetdemo kshark-gui) - - message(STATUS "cmd_split") - add_executable(cmd_split cmd_split.cpp) - target_link_libraries(cmd_split kshark-gui) - -endif (Qt5Widgets_FOUND) + message(STATUS "Building cmd_split") + add_executable(cmd_split cmd_split.cpp) + target_link_libraries(cmd_split kshark-gui) +endif(Qt5Widgets_FOUND) diff --git a/kernel-shark/src/CMakeLists.txt b/kernel-shark/src/CMakeLists.txt index 457c1007..d3eefe6b 100644 --- a/kernel-shark/src/CMakeLists.txt +++ b/kernel-shark/src/CMakeLists.txt @@ -1,107 +1,137 @@ -message("\n src ...") - -message(STATUS "libkshark") -add_library(kshark SHARED libkshark.c - libkshark-model.c - libkshark-plugin.c - libkshark-configio.c - libkshark-collection.c) - -target_link_libraries(kshark ${TRACECMD_LIBRARY} - ${TRACEFS_LIBRARY} - ${TRACEEVENT_LIBRARY} - ${JSONC_LIBRARY} - ${CMAKE_DL_LIBS}) - -set_target_properties(kshark PROPERTIES SUFFIX ".so.${KS_VERSION_STRING}") - -install(TARGETS kshark LIBRARY DESTINATION ${_LIBDIR}/${KS_APP_NAME}) - -if (OPENGL_FOUND AND GLUT_FOUND) - - message(STATUS "libkshark-plot") - add_library(kshark-plot SHARED libkshark-plot.c - KsPlotTools.cpp) - - target_link_libraries(kshark-plot kshark - ${GLUT_LIBRARY} - ${OPENGL_LIBRARIES}) - - set_target_properties(kshark-plot PROPERTIES SUFFIX ".so.${KS_VERSION_STRING}") - - install(TARGETS kshark-plot LIBRARY DESTINATION ${_LIBDIR}/${KS_APP_NAME}) - -endif (OPENGL_FOUND AND GLUT_FOUND) - -if (Qt5Widgets_FOUND AND Qt5Network_FOUND) - - message(STATUS "libkshark-gui") - set (ks-guiLib_hdr KsUtils.hpp - KsModels.hpp - KsGLWidget.hpp - KsSearchFSM.hpp - KsDualMarker.hpp - KsWidgetsLib.hpp - KsTraceGraph.hpp - KsTraceViewer.hpp - KsMainWindow.hpp - KsCaptureDialog.hpp - KsQuickContextMenu.hpp - KsAdvFilteringDialog.hpp) - - QT5_WRAP_CPP(ks-guiLib_hdr_moc ${ks-guiLib_hdr}) - - add_library(kshark-gui SHARED ${ks-guiLib_hdr_moc} KsUtils.cpp - KsModels.cpp - KsSession.cpp - KsGLWidget.cpp - KsSearchFSM.cpp - KsDualMarker.cpp - KsWidgetsLib.cpp - KsTraceGraph.cpp - KsTraceViewer.cpp - KsMainWindow.cpp - KsCaptureDialog.cpp - KsQuickContextMenu.cpp - KsAdvFilteringDialog.cpp) - - target_link_libraries(kshark-gui kshark-plot - Qt5::Widgets - Qt5::Network) - - - set_target_properties(kshark-gui PROPERTIES SUFFIX ".so.${KS_VERSION_STRING}") - - 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 ${KS_APP_NAME} kshark-record kshark-gui - RUNTIME DESTINATION ${_INSTALL_PREFIX}/bin/ - LIBRARY DESTINATION ${_LIBDIR}/${KS_APP_NAME}/) - - install(FILES "${KS_DIR}/${KS_APP_NAME}.desktop" - DESTINATION ${_INSTALL_PREFIX}/share/applications/) - - install(FILES "${KS_DIR}/icons/${KS_ICON}" - "${KS_DIR}/icons/${KS_ICON_FIN}" - DESTINATION ${_INSTALL_PREFIX}/share/icons/${KS_APP_NAME}) - - install(FILES "${KS_DIR}/org.freedesktop.kshark-record.policy" - DESTINATION /usr/share/polkit-1/actions/) - - install(PROGRAMS "${KS_DIR}/bin/kshark-su-record" - DESTINATION ${_INSTALL_PREFIX}/bin/) - -endif (Qt5Widgets_FOUND AND Qt5Network_FOUND) +message(STATUS "Building src ...") + +configure_file( + deff.h.in + KsCmakeDef.hpp +) + +message(STATUS "Building libkshark") +add_library( + kshark + SHARED + libkshark.c + libkshark-model.c + libkshark-plugin.c + libkshark-configio.c + libkshark-collection.c +) + +target_link_libraries( + kshark + ${TRACECMD_LIBRARY} + ${TRACEFS_LIBRARY} + ${TRACEEVENT_LIBRARY} + ${JSONC_LIBRARY} + ${CMAKE_DL_LIBS} +) + +set_target_properties( + kshark + PROPERTIES + SUFFIX + ".so.${PROJECT_VERSION}" +) + +install( + TARGETS kshark + LIBRARY + DESTINATION + ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}/ +) + +if(OPENGL_FOUND AND GLUT_FOUND) + message(STATUS "Build libkshark-plot") + add_library( + kshark-plot + SHARED + libkshark-plot.c + KsPlotTools.cpp + ) + target_link_libraries( + kshark-plot + kshark + ${GLUT_LIBRARY} + ${OPENGL_LIBRARIES} + ) + set_target_properties( + kshark-plot + PROPERTIES + SUFFIX + ".so.${PROJECT_VERSION}" + ) + install( + TARGETS kshark-plot + LIBRARY + DESTINATION + ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME} +) +endif(OPENGL_FOUND AND GLUT_FOUND) + +if(Qt5Widgets_FOUND AND Qt5Network_FOUND) + message(STATUS "Build libkshark-gui") + set( + GUILIB_HEADERS + KsUtils.hpp + KsModels.hpp + KsGLWidget.hpp + KsSearchFSM.hpp + KsDualMarker.hpp + KsWidgetsLib.hpp + KsTraceGraph.hpp + KsTraceViewer.hpp + KsMainWindow.hpp + KsCaptureDialog.hpp + KsQuickContextMenu.hpp + KsAdvFilteringDialog.hpp + ) + QT5_WRAP_CPP(GUILIB_HEADERS_MOC ${GUILIB_HEADERS}) + + add_library( + kshark-gui + SHARED + ${GUILIB_HEADERS_MOC} + KsUtils.cpp + KsModels.cpp + KsSession.cpp + KsGLWidget.cpp + KsSearchFSM.cpp + KsDualMarker.cpp + KsWidgetsLib.cpp + KsTraceGraph.cpp + KsTraceViewer.cpp + KsMainWindow.cpp + KsCaptureDialog.cpp + KsQuickContextMenu.cpp + KsAdvFilteringDialog.cpp + ) + + target_link_libraries( + kshark-gui + kshark-plot + Qt5::Widgets + Qt5::Network + ) + + set_target_properties( + kshark-gui + PROPERTIES + SUFFIX + ".so.${PROJECT_VERSION}" + ) + + message(STATUS "Building ${PROJECT_NAME}") + add_executable(${PROJECT_NAME} kernelshark.cpp) + target_link_libraries(${PROJECT_NAME} kshark-gui) + + message(STATUS "Building kshark-record") + add_executable(kshark-record kshark-record.cpp) + target_link_libraries(kshark-record kshark-gui) + + install( + TARGETS ${PROJECT_NAME} kshark-record kshark-gui + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}/ + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}/ + ) +endif(Qt5Widgets_FOUND AND Qt5Network_FOUND) add_subdirectory(plugins) - -find_program(DO_AS_ROOT pkexec) - -configure_file( ${KS_DIR}/build/deff.h.cmake - ${KS_DIR}/src/KsCmakeDef.hpp) diff --git a/kernel-shark/src/KsMainWindow.cpp b/kernel-shark/src/KsMainWindow.cpp index fc4e9a94..fa599d3e 100644 --- a/kernel-shark/src/KsMainWindow.cpp +++ b/kernel-shark/src/KsMainWindow.cpp @@ -945,10 +945,7 @@ void KsMainWindow::_record() QString message; message = "Record is currently not supported."; - message += " Install \"pkexec\" and then do:
"; - message += " cd build
sudo ./cmake_uninstall.sh
"; - message += " ./cmake_clean.sh
cmake ..
make
"; - message += " sudo make install"; + message += " Install \"pkexec\", rebuild and install kernelshark."; _error(message, "recordCantStart", false, false); return; diff --git a/kernel-shark/build/deff.h.cmake b/kernel-shark/src/deff.h.in similarity index 50% rename from kernel-shark/build/deff.h.cmake rename to kernel-shark/src/deff.h.in index 79726ff6..61a4ec33 100644 --- a/kernel-shark/build/deff.h.cmake +++ b/kernel-shark/src/deff.h.in @@ -8,21 +8,6 @@ #ifndef _KS_CONFIG_H #define _KS_CONFIG_H -/** KernelShark Version number. */ -#cmakedefine KS_VERSION_STRING "@KS_VERSION_STRING@" - -/** 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_EXECUTABLE "@TRACECMD_EXECUTABLE@" - -/** "pkexec" executable. */ -#cmakedefine DO_AS_ROOT "@DO_AS_ROOT@" - #ifdef __cplusplus #include diff --git a/kernel-shark/src/libkshark.h b/kernel-shark/src/libkshark.h index 0d6c50d1..a44f46ec 100644 --- a/kernel-shark/src/libkshark.h +++ b/kernel-shark/src/libkshark.h @@ -26,7 +26,7 @@ extern "C" { // trace-cmd #include "trace-cmd/trace-cmd.h" -#include "trace-cmd/trace-filter-hash.h" +#include "trace-filter-hash.h" #include "traceevent/event-parse.h" #include "tracefs/tracefs.h" diff --git a/kernel-shark/src/plugins/CMakeLists.txt b/kernel-shark/src/plugins/CMakeLists.txt index 6c771792..63089588 100644 --- a/kernel-shark/src/plugins/CMakeLists.txt +++ b/kernel-shark/src/plugins/CMakeLists.txt @@ -1,33 +1,41 @@ -message("\n src/plugins ...") - -function(BUILD_PLUGIN) - set(options ) - set(oneValueArgs NAME) - set(multiValueArgs SOURCE) - cmake_parse_arguments(ADD_PLUGIN "${options}" - ${oneValueArgs} - ${multiValueArgs} - ${ARGN}) - - message(STATUS ${ADD_PLUGIN_NAME}) - - add_library(${ADD_PLUGIN_NAME} SHARED ${ADD_PLUGIN_SOURCE}) - set_target_properties(${ADD_PLUGIN_NAME} PROPERTIES PREFIX "plugin-") - target_link_libraries(${ADD_PLUGIN_NAME} kshark) - +message(STATUS "Building plugins ...") + +function(build_plugin) + set(options) + set(oneValueArgs NAME) + set(multiValueArgs SOURCE) + cmake_parse_arguments( + ADD_PLUGIN "${options}" + ${oneValueArgs} + ${multiValueArgs} + ${ARGN} + ) + + message(STATUS ${ADD_PLUGIN_NAME}) + + add_library(${ADD_PLUGIN_NAME} SHARED ${ADD_PLUGIN_SOURCE}) + set_target_properties(${ADD_PLUGIN_NAME} PROPERTIES PREFIX "plugin-") + target_link_libraries(${ADD_PLUGIN_NAME} kshark) endfunction() set(PLUGIN_LIST "") -BUILD_PLUGIN(NAME sched_events - SOURCE sched_events.c SchedEvents.cpp) +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 # list(APPEND PLUGIN_LIST "sched_events") # This plugin isn't loaded by default -BUILD_PLUGIN(NAME missed_events - SOURCE missed_events.c MissedEvents.cpp) +build_plugin( + NAME missed_events + SOURCE missed_events.c MissedEvents.cpp +) list(APPEND PLUGIN_LIST "missed_events default") # This plugin will be loaded by default -install(TARGETS sched_events missed_events - LIBRARY DESTINATION ${KS_PLUGIN_INSTALL_PREFIX}) +install( + TARGETS sched_events missed_events + LIBRARY + DESTINATION "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}/plugins/" +) set(PLUGINS ${PLUGIN_LIST} PARENT_SCOPE)