Skip to content

Commit

Permalink
Merge pull request #51 from MuonPi/v2.0.2
Browse files Browse the repository at this point in the history
V2.0.2
  • Loading branch information
dtreffenstaedt authored Nov 12, 2021
2 parents 6e324fe + 9d219c8 commit 6155337
Show file tree
Hide file tree
Showing 318 changed files with 15,833 additions and 27,118 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
*.stash
myon_detector/upload_script.sh
*.pdf
.DS_Store
.vscode/settings.json
174 changes: 174 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
cmake_minimum_required (VERSION 3.10)
project (muondetector LANGUAGES CXX C)

string(TIMESTAMP PROJECT_DATE_STRING "%b %d, %Y")

option(MUONDETECTOR_BUILD_GUI "Build the gui for the muondetector" ON)
option(MUONDETECTOR_BUILD_DAEMON "Build the daemon for the muondetector. Defaults to ON on armv7l architecture" OFF)
set(MUONDETECTOR_ON_RASPBERRYPI OFF)

include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/version.cmake")

execute_process(COMMAND bash "-c" "git rev-parse --short HEAD | tr -d '\n'"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE PROJECT_VERSION_HASH)



if ((${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7l"))
set(MUONDETECTOR_BUILD_DAEMON ON)
set(MUONDETECTOR_ON_RASPBERRYPI ON)
endif ()

set(MUONDETECTOR_CONFIG_DIR "${CMAKE_CURRENT_SOURCE_DIR}/config")

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/output/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/output/lib")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/output/bin")

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)



add_compile_options(
-Wall
-O3
)

if (MSVC)
# Force to always compile with W4
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
endif()
else()

add_compile_options(
-Wextra
-Wshadow
-Wpedantic
)

endif()

if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7l")
add_compile_options(
-mthumb
-mthumb-interwork
-march=armv7-a
)
endif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7l")


if (NOT (WIN32 OR APPLE))
set(CPACK_GENERATOR "DEB")
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/MuonPi/muondetector")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "MuonPi <[email protected]>")
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
endif ()
set(CPACK_RESOURCE_FILE_LICENSE "${MUONDETECTOR_CONFIG_DIR}/license")
set(CPACK_PACKAGE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/output/packages")
set(CPACK_PACKAGE_VENDOR "MuonPi.org")
set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")


set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)



if(WIN32)
set(QWT_DIR "C:/Qwt-6.2.0")
set(OPENSSL_DIR "C:/Qt/Tools/OpenSSL/Win_x64")
set(QTROOT "C:/Qt")
set(QTTOOLS "${QTROOT}/Tools")
set(SDKROOT "${QTROOT}/5.15.2/mingw81_64")
list(APPEND CMAKE_PREFIX_PATH "${SDKROOT}")
list(APPEND CMAKE_PREFIX_PATH "${SDKROOT}/lib/cmake/Qt5QuickCompiler")
list(APPEND CMAKE_PREFIX_PATH "${SDKROOT}/lib/cmake/Qt5")

if (MSVC)
if("${MSVC_RUNTIME}" STREQUAL "")
set(MSVC_RUNTIME "static")
endif()
# Set compiler options.
set(variables
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_MINSIZEREL
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_MINSIZEREL
CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_RELWITHDEBINFO
)
if(${MSVC_RUNTIME} STREQUAL "static")
message(STATUS
"MSVC -> forcing use of statically-linked runtime."
)
foreach(variable ${variables})
if(${variable} MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${variable} "${${variable}}")
endif()
endforeach()
else()
message(STATUS
"MSVC -> forcing use of dynamically-linked runtime."
)
foreach(variable ${variables})
if(${variable} MATCHES "/MT")
string(REGEX REPLACE "/MT" "/MD" ${variable} "${${variable}}")
endif()
endforeach()
endif()
endif()


else()

set(Qt5_DIR "/usr/lib/x86_64-linux-gnu/cmake/Qt5/")

endif ()



include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/library.cmake")

set(MUONDETECTOR_ALL_FILES
"${MUONDETECTOR_LIBRARY_SOURCE_FILES}"
"${MUONDETECTOR_LIBRARY_HEADER_FILES}"
)
if (MUONDETECTOR_BUILD_GUI)
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/gui.cmake")

set(MUONDETECTOR_ALL_FILES
"${MUONDETECTOR_ALL_FILES}"
"${MUONDETECTOR_GUI_SOURCE_FILES}"
"${MUONDETECTOR_GUI_HEADER_FILES}"
)
endif (MUONDETECTOR_BUILD_GUI)
if (MUONDETECTOR_BUILD_DAEMON)
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/daemon.cmake")

set(MUONDETECTOR_ALL_FILES
"${MUONDETECTOR_ALL_FILES}"
"${MUONDETECTOR_DAEMON_SOURCE_FILES}"
"${MUONDETECTOR_DAEMON_HEADER_FILES}"
"${MUONDETECTOR_LOGIN_SOURCE_FILES}"
"${MUONDETECTOR_LOGIN_HEADER_FILES}"
)
endif (MUONDETECTOR_BUILD_DAEMON)

add_custom_target(clangformat COMMAND clang-format -style=WebKit -i ${MUONDETECTOR_ALL_FILES})


set(CPACK_DEB_COMPONENT_INSTALL ON)

include(CPack)
22 changes: 0 additions & 22 deletions Dockerfile

This file was deleted.

23 changes: 14 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,21 @@ Depending on the device of you choice, install the GUI for controlling the softw
- "muondetector-gui_1.1.2-windows-x64.zip" on a 64-bit Windows machine

### Installation from source
When compiling directly from the git repository you need to manually build and install the [paho-mqttpp](https://github.com/eclipse/paho.mqtt.cpp) library.

The steps to building the daemon are as follows:
1. enter the build directory
2. run `mkdir library && mkdir daemon && mkdir gui`
3. run `cd library && cmake ../../source/library && make`
4. run `cd ../daemon && cmake ../../source/daemon && make package`
5. (Optional) `cd ../gui && cmake ../../source/gui && make package`
6. `cd ../packages`
7. install the debian packages found there with `sudo apt install ./<filename>.deb`
1. Install all dependencies
2. Enter the build directory
3. run `cmake ../source`
6. run `make package`
7. enter `output/packages`
8. install the debian packages found there with `sudo apt install ./<filename>.deb`

#### Options
Possible options are:

`MUONDETECTOR_BUILD_GUI` This defaults to `ON`

`MUONDETECTOR_BUILD_DAEMON` This defaults to `ON` on a raspberry pi system and `OFF` otherwise. Note that you can not turn it on on a non-raspberry pi system.

## TROUBLESHOOTING AND DEPENDENCIES:

Expand All @@ -60,7 +65,7 @@ When trying to create a Makefile with qmake (qt version 5.7.1 on raspbian) there

Cheat-Sheet Copy&Paste:

`sudo apt install qt5-default pyqt5-dev qt5-qmake libqt5serialport5-dev libqt5svg5-dev libqwt-qt5-dev libqwt-dev libcrypto++-dev libcrypto++-doc libcrypto++-utils libcrypto++-dev libcrypto++-doc libcrypto++-utils lftp libpaho-mqttpp qtdeclarative5-dev libconfig++-dev`
`sudo apt install qt5-default pyqt5-dev qt5-qmake libqt5serialport5-dev libqt5svg5-dev libqwt-qt5-dev libqwt-dev libcrypto++-dev libcrypto++-doc libcrypto++-utils libcrypto++-dev libcrypto++-doc libcrypto++-utils lftp libmosquitto-dev qtdeclarative5-dev libconfig++-dev`

### Troubleshooting

Expand Down
3 changes: 0 additions & 3 deletions build/.gitignore

This file was deleted.

41 changes: 41 additions & 0 deletions cmake/Macdeployqt.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# The MIT License (MIT)
#
# Copyright (c) 2017 Nathan Osman
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
find_package(Qt5Core REQUIRED)
# Retrieve the absolute path to qmake and then use that path to find
# the macdeployqt binary
get_target_property(_qmake_executable Qt5::qmake IMPORTED_LOCATION)
get_filename_component(_qt_bin_dir "${_qmake_executable}" DIRECTORY)
find_program(MACDEPLOYQT_EXECUTABLE macdeployqt HINTS "${_qt_bin_dir}")
# Add commands that copy the required Qt files to the application bundle
# represented by the target
function(macdeployqt target directory options)

add_custom_command(TARGET ${target} POST_BUILD
COMMAND "${MACDEPLOYQT_EXECUTABLE}"
\"$<TARGET_FILE_DIR:${target}>/../..\"
-always-overwrite
${options}
COMMENT "Deploying Qt..."
)
endfunction()

mark_as_advanced(MACDEPLOYQT_EXECUTABLE)
12 changes: 8 additions & 4 deletions source/cmake/Windeployqt.cmake → cmake/Windeployqt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ get_target_property(_qmake_executable Qt5::qmake IMPORTED_LOCATION)
get_filename_component(_qt_bin_dir "${_qmake_executable}" DIRECTORY)
find_program(WINDEPLOYQT_EXECUTABLE windeployqt HINTS "${_qt_bin_dir}")

if(WINDEPLOYQT_EXECUTABLE)
message(STATUS "windeploy_qt found: ${WINDEPLOYQT_EXECUTABLE}")
endif()

# Running this with MSVC 2015 requires CMake 3.6+
if((MSVC_VERSION VERSION_EQUAL 1900 OR MSVC_VERSION VERSION_GREATER 1900)
AND CMAKE_VERSION VERSION_LESS "3.6")
Expand All @@ -42,9 +46,9 @@ function(windeployqt target directory options)
add_custom_command(TARGET ${target} POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E
env PATH="${_qt_bin_dir}" "${WINDEPLOYQT_EXECUTABLE}"
--verbose 0
#--verbose 0
${options}
--release
#--release
--no-compiler-runtime
--no-angle
--no-opengl-sw
Expand All @@ -65,7 +69,6 @@ function(windeployqt target directory options)
execute_process(
COMMAND \"${CMAKE_COMMAND}\" -E
env PATH=\"${_qt_bin_dir}\" \"${WINDEPLOYQT_EXECUTABLE}\"
--release
${options}
--dry-run
--no-compiler-runtime
Expand Down Expand Up @@ -93,6 +96,7 @@ function(windeployqt target directory options)
# so we fall back to one of CMake's own modules for copying them over
set(CMAKE_INSTALL_UCRT_LIBRARIES TRUE)
include(InstallRequiredSystemLibraries)
message(STATUS "CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS: ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS}")
foreach(lib ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS})
get_filename_component(filename "${lib}" NAME)
add_custom_command(TARGET ${target} POST_BUILD
Expand All @@ -103,4 +107,4 @@ function(windeployqt target directory options)

endfunction()

mark_as_advanced(WINDEPLOYQT_EXECUTABLE)
mark_as_advanced(WINDEPLOYQT_EXECUTABLE)
Loading

0 comments on commit 6155337

Please sign in to comment.