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

Restore Snap Support #350

Closed
Closed
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
9 changes: 6 additions & 3 deletions snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ environment:

apps:
packetsender:
command: usr/local/bin/packetsender
command: usr/local/bin/PacketSender
desktop: usr/share/applications/packetsender.desktop

plugs:
Expand All @@ -33,10 +33,13 @@ apps:

parts:
packetsender:
plugin: qmake
plugin: cmake
source: https://github.com/dannagle/PacketSender.git
source-branch: master
qmake-project-file: src/PacketSenderSnap.pro
cmake-parameters:
- /root/parts/packetsender/src/src
- -D SNAP=1

build-packages:
- build-essential
- qt6-base-dev
Expand Down
135 changes: 95 additions & 40 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,20 @@ project(PacketSender)

set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
include(GNUInstallDirs)
set(CMAKE_AUTOUIC ON)

if(${SNAP})
set(QMAKE_MAJREV 6)
else()
set(QMAKE_MAJREV 5)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
endif()


FIND_PACKAGE(Qt5 COMPONENTS Core Gui Network Widgets)
FIND_PACKAGE(QT NAMES Qt${QMAKE_MAJREV} REQUIRED COMPONENTS Core)
FIND_PACKAGE(Qt${QMAKE_MAJREV} COMPONENTS Gui Network Widgets)

set(
PACKETSENDER_UI_HEADERS
Expand Down Expand Up @@ -80,46 +90,91 @@ set(
translations.qrc
)

QT5_ADD_RESOURCES(srcs_qrc ${PACKETSENDER_QRC})
QT5_WRAP_UI(moc_uis ${PACKETSENDER_UIS})
QT5_WRAP_CPP(moc_srcs ${PACKETSENDER_UI_HEADERS})

add_executable(
${PROJECT_NAME}
${srcs_qrc}
${moc_uis}
${moc_srcs}
${PACKETSENDER_SRCS}
)

target_link_libraries(${PROJECT_NAME} Qt5::Widgets Qt5::Network Qt5::Core)
QT5_USE_MODULES(${PROJECT_NAME} Core Gui Network Widgets)

install(TARGETS
${PROJECT_NAME}
DESTINATION bin
)

include(GetGitRevisionDescription)
git_describe(GIT_VERSION --tags)
string(REGEX REPLACE "^v([0-9]+)\\..*" "\\1" GIT_VERSION_MAJOR "${GIT_VERSION}")
string(REGEX REPLACE "^v[0-9]+\\.([0-9]+).*" "\\1" GIT_VERSION_MINOR "${GIT_VERSION}")
string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" GIT_VERSION_PATCH "${GIT_VERSION}")
string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.[0-9]+(.*)" "\\1" GIT_VERSION_SHA1 "${GIT_VERSION}")
set(GIT_VERSION_SHORT "${GIT_VERSION_MAJOR}.${GIT_VERSION_MINOR}")
get_git_head_revision(GIT_REFSPEC GIT_HASH)

set(CPACK_GENERATOR "DEB")
set(CPACK_PACKAGE_NAME "${PROJECT_NAME}")
set(CPACK_PACKAGE_VENDOR "${PROJECT_NAME} project")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A network test utility for sending / receiving TCP and UDP packets http://packetsender.com/")
set(CPACK_PACKAGE_VERSION ${GIT_VERSION_SHORT})
set(CPACK_PACKAGE_VERSION_MAJOR ${GIT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${GIT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH 0)
set(CPACK_PACKAGE_CONTACT "[email protected]")

include(CPack)

if(${SNAP})

QT_ADD_RESOURCES(srcs_qrc ${PACKETSENDER_QRC})
add_executable(
${PROJECT_NAME}
${srcs_qrc}
${moc_uis}
${moc_srcs}
${PACKETSENDER_SRCS}
)
target_link_libraries(${PROJECT_NAME} PRIVATE
Qt::Core
Qt::Gui
Qt::Network
Qt::Widgets
)

execute_process(COMMAND git -C ../../../project rev-parse --short HEAD OUTPUT_VARIABLE GIT_SHA COMMAND_ERROR_IS_FATAL ANY OUTPUT_STRIP_TRAILING_WHITESPACE)
target_compile_definitions(PacketSender PRIVATE
GUI_BUILD
ISSNAP=1
QT_DISABLE_DEPRECATED_BEFORE=0x050F00
GIT_CURRENT_SHA1=\"${GIT_SHA}\"
)
target_compile_definitions(${PROJECT_NAME} PRIVATE
_FORTIFY_SOURCE=2
)

install(TARGETS ${PROJECT_NAME}
BUNDLE DESTINATION .
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

install(FILES packetsender.desktop DESTINATION /usr/share/applications)
install(FILES packetsender.svg DESTINATION /usr/share/icons)

else()

QT5_ADD_RESOURCES(srcs_qrc ${PACKETSENDER_QRC})
QT5_WRAP_UI(moc_uis ${PACKETSENDER_UIS})
QT5_WRAP_CPP(moc_srcs ${PACKETSENDER_UI_HEADERS})

add_executable(
${PROJECT_NAME}
${srcs_qrc}
${moc_uis}
${moc_srcs}
${PACKETSENDER_SRCS}
)
target_link_libraries(${PROJECT_NAME} PRIVATE
Qt5::Core
Qt5::Gui
Qt5::Network
Qt5::Widgets
)

QT5_USE_MODULES(${PROJECT_NAME} Core Gui Network Widgets)

install(TARGETS
${PROJECT_NAME}
DESTINATION bin
)

include(GetGitRevisionDescription)
git_describe(GIT_VERSION --tags)
string(REGEX REPLACE "^v([0-9]+)\\..*" "\\1" GIT_VERSION_MAJOR "${GIT_VERSION}")
string(REGEX REPLACE "^v[0-9]+\\.([0-9]+).*" "\\1" GIT_VERSION_MINOR "${GIT_VERSION}")
string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" GIT_VERSION_PATCH "${GIT_VERSION}")
string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.[0-9]+(.*)" "\\1" GIT_VERSION_SHA1 "${GIT_VERSION}")
set(GIT_VERSION_SHORT "${GIT_VERSION_MAJOR}.${GIT_VERSION_MINOR}")
get_git_head_revision(GIT_REFSPEC GIT_HASH)

set(CPACK_GENERATOR "DEB")
set(CPACK_PACKAGE_NAME "${PROJECT_NAME}")
set(CPACK_PACKAGE_VENDOR "${PROJECT_NAME} project")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A network test utility for sending / receiving TCP and UDP packets http://packetsender.com/")
set(CPACK_PACKAGE_VERSION ${GIT_VERSION_SHORT})
set(CPACK_PACKAGE_VERSION_MAJOR ${GIT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${GIT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH 0)
set(CPACK_PACKAGE_CONTACT "[email protected]")

include(CPack)
endif()


74 changes: 0 additions & 74 deletions src/PacketSenderSnap.pro

This file was deleted.

Loading