Skip to content

Commit

Permalink
Adapt cmake build (#244)
Browse files Browse the repository at this point in the history
Signed-off-by: Ruslan Iusupov [email protected]

Co-authored-by: Ruslan Iusupov <[email protected]>
  • Loading branch information
rus0000 and Ruslan Iusupov authored Jan 26, 2022
1 parent d59c699 commit 08b09b3
Show file tree
Hide file tree
Showing 79 changed files with 561 additions and 263 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/BuildPR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ jobs:
run: ls -n /Applications/ | grep Xcode*
- name: Set XCode Version
run: sudo xcode-select -s /Applications/${{ matrix.xcode }}.app
- name: install qt 5
run: brew install qt@5
- name: install build environment
run: scripts/install.sh
- name: Build project
Expand Down Expand Up @@ -55,7 +53,7 @@ jobs:
- name: Build project
run: scripts/build.sh
- name: Make artifact executable
run: chmod -R +x build/release
run: chmod -R +x build/release
- name: Archive artifact
uses: actions/[email protected]
if: ${{ success() }}
Expand Down
Empty file modified .gitignore
100755 → 100644
Empty file.
129 changes: 78 additions & 51 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# SPDX-License-Identifier: MPL-2.0
#
# Copyright (C) 2016, Jack S. Smith
#
Expand All @@ -12,88 +13,114 @@
#
# List of changes:
# 01.Oct.2016, Jack Smith <[email protected]>, Original Author
#

cmake_minimum_required (VERSION 3.1)
cmake_minimum_required (VERSION 3.15)

project(dlt-viewer)

project (dlt-viewer)
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
set(LINUX TRUE)
endif()

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif()

set(QT_VERSION_REQ "5")

find_package(Qt5 ${QT_VERSION_REQ} REQUIRED COMPONENTS Core Network Widgets SerialPort PrintSupport)
find_package(Qt5 "5" REQUIRED COMPONENTS Core Network Widgets SerialPort PrintSupport)

if(Qt5Core_VERSION VERSION_LESS "5.5.1")
# Presumably Qt5Core implies all dependent libs too
message(FATAL_ERROR "QT minimum version required: 5.5.1")
endif()

set (CMAKE_VERBOSE_MAKEFILE FALSE)

set (CMAKE_AUTOMOC ON)
set (CMAKE_AUTOUIC ON)

set (CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

option(USE_QT_RPATH "Use RPATH for QT_LIBRARY_PATH to support non-standard QT install locations" ON)
get_target_property(DLT_QT5_LIBRARY_PATH Qt5::Core LOCATION)
get_filename_component(DLT_QT5_LIB_DIR ${DLT_QT5_LIBRARY_PATH} DIRECTORY)

if (USE_QT_RPATH)
# Add Qt to the RPATH, so that there is no need to set LD_LIBRARY_PATH at runtime if Qt is installed in a non-standard location
get_target_property(QT_LIBRARY_PATH Qt5::Core LOCATION)
get_filename_component(QT_LIB_DIR ${QT_LIBRARY_PATH} DIRECTORY)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH};${QT_LIB_DIR}")
if(NOT WIN32)
option(DLT_USE_QT_RPATH "Use RPATH for QT_LIBRARY_PATH to support non-standard QT install locations" ON)
if (DLT_USE_QT_RPATH)
# Add Qt to the RPATH, so that there is no need to set LD_LIBRARY_PATH at runtime if Qt is installed in a non-standard location
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH};${DLT_QT5_LIB_DIR}")
endif()
endif()

# Injection of the GCC-specific compilation flags
if(NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
add_definitions( "-Wall" )
add_definitions( "-Wextra" )
add_definitions( "-pedantic" )
add_definitions( "-Wno-variadic-macros" )
add_definitions( "-Wno-strict-aliasing" )
if(CMAKE_COMPILER_IS_GNUCXX)
message(STATUS "GCC detected, adding compile flags")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
add_definitions("-Wall" "-Wextra" "-pedantic" "-Wno-variadic-macros" "-Wno-strict-aliasing" "-fPIC")
endif()

# build executables in build/bin directory
set(BIN_DIR ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BIN_DIR})

add_definitions(-DQT5)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) # set location for all executables in the build folder

option(USE_STANDARD_INSTALLATION_LOCATION "Use standard GNU installation locations" OFF)

if (USE_STANDARD_INSTALLATION_LOCATION)
include(GNUInstallDirs) # for standard installation locations
set(PLUGIN_INSTALLATION_PATH ${CMAKE_INSTALL_FULL_LIBDIR}/dlt-viewer/plugins)
set(RESOURCE_INSTALLATION_PATH ${CMAKE_INSTALL_FULL_DATADIR}/dlt-viewer)
set(EXECUTABLE_INSTALLATION_PATH ${CMAKE_INSTALL_FULL_BINDIR})
set(LIBRARY_INSTALLATION_PATH ${CMAKE_INSTALL_FULL_LIBDIR})
add_compile_definitions(QT5)

option(DLT_USE_STANDARD_INSTALLATION_LOCATION "Use standard GNU installation locations" OFF)
if(NOT WIN32)
if(DLT_USE_STANDARD_INSTALLATION_LOCATION)
include(GNUInstallDirs)
set(DLT_PLUGIN_INSTALLATION_PATH "${CMAKE_INSTALL_FULL_LIBDIR}/dlt-viewer/plugins")
set(DLT_RESOURCE_INSTALLATION_PATH "${CMAKE_INSTALL_FULL_DATADIR}/dlt-viewer")
set(DLT_EXECUTABLE_INSTALLATION_PATH "${CMAKE_INSTALL_FULL_BINDIR}")
set(DLT_LIBRARY_INSTALLATION_PATH "${CMAKE_INSTALL_FULL_LIBDIR}")
else()
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "DLTViewer")
endif()
if(NOT DLT_PLUGIN_INSTALLATION_PATH)
set(DLT_PLUGIN_INSTALLATION_PATH "usr/bin/plugins")
endif()
if(NOT DLT_RESOURCE_INSTALLATION_PATH)
set(DLT_RESOURCE_INSTALLATION_PATH "usr/share")
endif()
if(NOT DLT_EXECUTABLE_INSTALLATION_PATH)
set(DLT_EXECUTABLE_INSTALLATION_PATH "usr/bin")
endif()
if(NOT DLT_LIBRARY_INSTALLATION_PATH)
set(DLT_LIBRARY_INSTALLATION_PATH "usr/lib")
endif()
endif()
else()
set(PLUGIN_INSTALLATION_PATH deploy/plugins)
set(RESOURCE_INSTALLATION_PATH deploy)
set(EXECUTABLE_INSTALLATION_PATH deploy)
set(LIBRARY_INSTALLATION_PATH deploy)
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
# AppData is a modern install location. No Admin rights required.
file(TO_CMAKE_PATH "$ENV{LOCALAPPDATA}/Programs" CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX} CACHE PATH "..." FORCE)
endif()

if(NOT DLT_PLUGIN_INSTALLATION_PATH)
set(DLT_PLUGIN_INSTALLATION_PATH "plugins")
endif()
if(NOT DLT_RESOURCE_INSTALLATION_PATH)
set(DLT_RESOURCE_INSTALLATION_PATH ".")
endif()
if(NOT DLT_EXECUTABLE_INSTALLATION_PATH)
set(DLT_EXECUTABLE_INSTALLATION_PATH ".")
endif()
if(NOT DLT_LIBRARY_INSTALLATION_PATH)
set(DLT_LIBRARY_INSTALLATION_PATH ".")
endif()
endif()

add_definitions(-DPLUGIN_INSTALLATION_PATH="${PLUGIN_INSTALLATION_PATH}")
option(DLT_PARSER "Build DLT Parser" OFF)

if(DLT_PARSER)
add_subdirectory(parser)
endif()

add_subdirectory(parser)
add_subdirectory(qdlt)
add_subdirectory(src)
add_subdirectory(plugin)
#add_subdirectory(dlt-console-viewer)

#get_cmake_property(_variableNames VARIABLES)
#foreach (_variableName ${_variableNames})
# message(STATUS "${_variableName}=${${_variableName}}")
#endforeach()
message(STATUS "\n\t** DLT Viewer Build Summary **")
message(STATUS "\tCMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
message(STATUS "\tCMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
message(STATUS "\tCMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
message(STATUS "\tCMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
message(STATUS "\tDLT_QT5_LIB_DIR: ${DLT_QT5_LIB_DIR}\n")
Binary file added doc/dlt_viewer_plugins_programming_guide.pdf
Binary file not shown.
Empty file modified doc/images/genivi_chrome_1_transparent.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified doc/images/genivi_transparent.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 22 additions & 10 deletions parser/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,29 @@
# 01.Oct.2016, Jack Smith <[email protected]>, Original Author
#

# cmake 2.8.12 doesn't have AUTOUIC ??
QT5_WRAP_UI( UI_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/mainwindow.ui )
add_executable(dlt-parser main.cpp
mainwindow.cpp
mainwindow.ui
qdltparser.cpp)

#message( STATUS "UI_HEADERS=[${UI_HEADERS}]")
target_link_libraries(dlt-parser Qt5::Widgets)

add_executable(dlt-parser main.cpp
mainwindow.cpp
mainwindow.ui
qdltparser.cpp
${UI_HEADERS})
set_target_properties(dlt-parser PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
INSTALL_RPATH "$ORIGIN/../lib;$<$<BOOL:${DLT_USE_QT_RPATH}>:${DLT_QT5_LIB_DIR}>")

if(CMAKE_COMPILER_IS_GNUCXX)
# https://stackoverflow.com/questions/45329372/ubuntu-recognizes-executable-as-shared-library-and-wont-run-it-by-clicking
# https://forum.juce.com/t/cmake-executable-build-shows-up-as-shared-library-on-linux-mint/45503/6
target_link_options(dlt-parser PRIVATE "-no-pie")
endif()

target_link_libraries(dlt-parser Qt5::Widgets -lstdc++)
install(TARGETS dlt-parser
DESTINATION "${DLT_EXECUTABLE_INSTALLATION_PATH}"
# Underscore for NSIS compatibility https://gitlab.kitware.com/cmake/cmake/-/issues/19982
COMPONENT dlt_parser)

install(TARGETS dlt-parser DESTINATION ${EXECUTABLE_INSTALLATION_PATH})
install(FILES
../ReleaseNotes_Parser.txt
DESTINATION "${DLT_EXECUTABLE_INSTALLATION_PATH}"
COMPONENT dlt_parser)
46 changes: 22 additions & 24 deletions plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (C) 2016, Jack S. Smith
#
#
# This file is part of GENIVI DLT-Viewer project.
#
#
# This Source Code Form is subject to the terms of the
# Mozilla Public License (MPL), v. 2.0.
# If a copy of the MPL was not distributed with this file,
Expand All @@ -13,36 +13,34 @@
# 01.Oct.2016, Jack Smith <[email protected]>, Original Author
#

# build plugins in build/bin/plugins directory
set(PLUGIN_DIR ${BIN_DIR}/plugins)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PLUGIN_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PLUGIN_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PLUGIN_DIR})

set (CMAKE_AUTOMOC ON)
set (CMAKE_AUTOUIC ON)

function(add_plugin NAME)

target_link_libraries(${NAME} qdlt Qt5::Widgets)
install(TARGETS ${NAME} DESTINATION ${PLUGIN_INSTALLATION_PATH})

# set the location of the plugins in such a way that they can be located by the dlt-viewer executable when running in
# directly from the build folder (without "make install")
set_target_properties(${NAME} PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
)
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/plugins
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/plugins
INSTALL_RPATH "$ORIGIN/../../lib;$<$<BOOL:${DLT_USE_QT_RPATH}>:${DLT_QT5_LIB_DIR}>")

install(TARGETS ${NAME}
DESTINATION "${DLT_PLUGIN_INSTALLATION_PATH}"
COMPONENT ${NAME})
endfunction()


add_subdirectory(dltviewerplugin)
add_subdirectory(nonverboseplugin)
add_subdirectory(filetransferplugin)
add_subdirectory(dltsystemviewerplugin)
add_subdirectory(dummycontrolplugin)
add_subdirectory(dummyviewerplugin)
add_subdirectory(dummycommandplugin)
add_subdirectory(dummydecoderplugin)
add_subdirectory(dltdbusplugin)
add_subdirectory(dltlogstorageplugin)
add_subdirectory(dltsystemviewerplugin)
add_subdirectory(dlttestrobotplugin)
add_subdirectory(dltviewerplugin)
add_subdirectory(filetransferplugin)
add_subdirectory(nonverboseplugin)

option(DLT_DUMMY_PLUGINS "Build Dummy plugins" OFF)
if(DLT_DUMMY_PLUGINS)
add_subdirectory(dummycontrolplugin)
add_subdirectory(dummyviewerplugin)
add_subdirectory(dummycommandplugin)
add_subdirectory(dummydecoderplugin)
endif()
9 changes: 3 additions & 6 deletions plugin/dltdbusplugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,10 @@
# 01.Oct.2016, Jack Smith <[email protected]>, Original Author
#

# cmake 2.8.12 doesn't have AUTOUIC ??
QT5_WRAP_UI( UI_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/form.ui )

add_library(dltdbusplugin MODULE dltdbusplugin.cpp
form.cpp
dbus.cpp
${UI_HEADERS})
form.cpp
dbus.cpp
${UI_HEADERS})

target_link_libraries(dltdbusplugin qdlt Qt5::Widgets )

Expand Down
3 changes: 0 additions & 3 deletions plugin/dltlogstorageplugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
# 01.Oct.2016, Jack Smith <[email protected]>, Original Author
#

# cmake 2.8.12 doesn't have AUTOUIC ??
QT5_WRAP_UI( UI_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/logstorageconfigcreatorform.ui )

add_library(dltlogstorageplugin MODULE dltlogstorageconfigcreatorplugin.cpp
logstorageconfigcreatorform.cpp
logstoragefilter.cpp
Expand Down
14 changes: 6 additions & 8 deletions plugin/dltsystemviewerplugin/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (C) 2016, Jack S. Smith
#
#
# This file is part of GENIVI DLT-Viewer project.
#
#
# This Source Code Form is subject to the terms of the
# Mozilla Public License (MPL), v. 2.0.
# If a copy of the MPL was not distributed with this file,
Expand All @@ -13,12 +13,10 @@
# 01.Oct.2016, Jack Smith <[email protected]>, Original Author
#

# cmake 2.8.12 doesn't have AUTOUIC ??
QT5_WRAP_UI( UI_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/form.ui )

add_library(dltsystemviewerplugin MODULE dltsystemviewerplugin.cpp
form.cpp
${UI_HEADERS})
add_library(dltsystemviewerplugin MODULE
dltsystemviewerplugin.cpp
form.cpp
${UI_HEADERS})

target_link_libraries(dltsystemviewerplugin qdlt Qt5::Widgets )

Expand Down
4 changes: 0 additions & 4 deletions plugin/dlttestrobotplugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
# 01.Oct.2016, Jack Smith <[email protected]>, Original Author
#


#cmake 2.8.12 doesn't have AUTOUIC ??
QT5_WRAP_UI( UI_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/form.ui )

add_library(dlttestrobotplugin MODULE dlttestrobotplugin.cpp
form.cpp
${UI_HEADERS})
Expand Down
20 changes: 6 additions & 14 deletions plugin/dltviewerplugin/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (C) 2016, Jack S. Smith
#
#
# This file is part of GENIVI DLT-Viewer project.
#
#
# This Source Code Form is subject to the terms of the
# Mozilla Public License (MPL), v. 2.0.
# If a copy of the MPL was not distributed with this file,
Expand All @@ -13,17 +13,9 @@
# 01.Oct.2016, Jack Smith <[email protected]>, Original Author
#

set (CMAKE_AUTOMOC ON)

# cmake 2.8.12 doesn't have AUTOUIC ??
QT5_WRAP_UI( UI_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/form.ui )

#message( STATUS "UI_HEADERS=[${UI_HEADERS}]")

add_library(dltviewerplugin MODULE dltviewerplugin.cpp
form.cpp
${UI_HEADERS})

target_link_libraries(dltviewerplugin qdlt Qt5::Widgets )
add_library(dltviewerplugin MODULE
dltviewerplugin.cpp
form.cpp
)

add_plugin(dltviewerplugin)
Loading

0 comments on commit 08b09b3

Please sign in to comment.