Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Streamline kernelshark cmake setup #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 #####
Expand Down
110 changes: 39 additions & 71 deletions kernel-shark/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -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)
14 changes: 14 additions & 0 deletions kernel-shark/Documentation/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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()
2 changes: 1 addition & 1 deletion kernel-shark/Documentation/doxygen/dox_config
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions kernel-shark/README
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ the option BUILD_TYPE=<type> to the make process.
tree before performing the following)

make
mkdir -p kernel-shark/build
cd kernel-shark/build
cmake ../
make
Expand Down Expand Up @@ -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.
6 changes: 6 additions & 0 deletions kernel-shark/bin/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
4 changes: 2 additions & 2 deletions kernel-shark/bin/kshark-su-record
Original file line number Diff line number Diff line change
@@ -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"
13 changes: 0 additions & 13 deletions kernel-shark/build/cmake_clean.sh

This file was deleted.

17 changes: 0 additions & 17 deletions kernel-shark/build/cmake_uninstall.sh

This file was deleted.

10 changes: 0 additions & 10 deletions kernel-shark/build/ks.desktop.cmake

This file was deleted.

File renamed without changes.
24 changes: 24 additions & 0 deletions kernel-shark/contrib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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/"
)
File renamed without changes.
10 changes: 10 additions & 0 deletions kernel-shark/contrib/kernelshark.desktop.in
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<allow_inactive>auth_admin</allow_inactive>
<allow_active>auth_admin</allow_active>
</defaults>
<annotate key="org.freedesktop.policykit.exec.path">@_INSTALL_PREFIX@/bin/kshark-record</annotate>
<annotate key="org.freedesktop.policykit.exec.path">@CMAKE_INSTALL_BINDIR@/kshark-record</annotate>
<annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
</action>

Expand Down
50 changes: 24 additions & 26 deletions kernel-shark/examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Loading