Changeset - 634ead433f2b
[Not reviewed]
Merge default
0 2 3
Hasan Yavuz ÖZDERYA - 10 years ago 2015-06-25 04:57:16
hy@ozderya.net
merge windows-setup
5 files changed with 67 insertions and 32 deletions:
0 comments (0 inline, 0 general)
CMakeLists.txt
Show inline comments
 
@@ -43,26 +43,26 @@ if (QWT_USE_STATIC)
 
  set(QWT_INCLUDE_DIR ${QWT_STATIC_INCLUDE})
 
else (QWT_USE_STATIC)
 
  find_package(Qwt 6.1 REQUIRED)
 
endif (QWT_USE_STATIC)
 

	
 
# includes
 
include_directories(${QWT_INCLUDE_DIR})
 

	
 
# wrap UI files
 
qt5_wrap_ui(UI_FILES mainwindow.ui portcontrol.ui about_dialog.ui)
 

	
 
# Tell CMake to create the helloworld executable
 
add_executable(serialplot main.cpp mainwindow.cpp portcontrol.cpp
 
  customcheckablebutton.cpp ${UI_FILES})
 
add_executable(serialplot WIN32 main.cpp mainwindow.cpp portcontrol.cpp
 
  customcheckablebutton.cpp ${UI_FILES} misc/windows_icon.rc)
 

	
 
# Use the Widgets module from Qt 5.
 
target_link_libraries(serialplot ${QWT_LIBRARY})
 
qt5_use_modules(serialplot Widgets SerialPort Svg)
 

	
 
# set compiler flags
 
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
 

	
 
# Enable C++11 support, fail if not supported
 
include(CheckCXXCompilerFlag)
 
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
 
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
 
@@ -104,78 +104,107 @@ message("SCM revision: ${VERSION_REVISIO
 
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/version.h.in" "${CMAKE_CURRENT_BINARY_DIR}/version.h")
 

	
 
# add make run target
 
add_custom_target(run
 
    COMMAND serialplot
 
    DEPENDS serialplot
 
    WORKING_DIRECTORY ${CMAKE_PROJECT_DIR}
 
)
 

	
 
# installing
 
install(TARGETS serialplot DESTINATION bin)
 

	
 
# for windows put libraries to install directory
 
if (WIN32)
 
  file(GLOB WINDOWS_INSTALL_LIBRARIES
 
    "${CMAKE_BINARY_DIR}/windows_install_libraries/*.*")
 
  install(FILES ${WINDOWS_INSTALL_LIBRARIES} DESTINATION bin)
 
endif (WIN32)
 

	
 
# install menu item and icon
 
find_program(XDG-DESKTOP-MENU xdg-desktop-menu)
 
find_program(XDG-ICON-RESOURCE xdg-icon-resource)
 

	
 
# first copy files to share/serialplot/
 
install(FILES
 
  ${CMAKE_SOURCE_DIR}/misc/serialplot.desktop
 
  ${CMAKE_SOURCE_DIR}/misc/serialplot.png
 
  DESTINATION share/serialplot)
 
if (UNIX)
 
  # first copy files to share/serialplot/
 
  install(FILES
 
    ${CMAKE_SOURCE_DIR}/misc/serialplot.desktop
 
    ${CMAKE_SOURCE_DIR}/misc/serialplot.png
 
    DESTINATION share/serialplot)
 

	
 
# install copyright file (in debian format)
 
install(FILES
 
  ${CMAKE_SOURCE_DIR}/debian/copyright
 
  DESTINATION share/doc/serialplot/)
 
  # install copyright file (in debian format)
 
  install(FILES
 
    ${CMAKE_SOURCE_DIR}/debian/copyright
 
    DESTINATION share/doc/serialplot/)
 

	
 
install(CODE "
 
  install(CODE "
 
  execute_process(COMMAND ${XDG-DESKTOP-MENU} install --novendor ${CMAKE_INSTALL_PREFIX}/share/serialplot/serialplot.desktop)
 
  execute_process(COMMAND ${XDG-ICON-RESOURCE} install --novendor --size 256 ${CMAKE_INSTALL_PREFIX}/share/serialplot/serialplot.png)
 
")
 
endif (UNIX)
 

	
 
# uninstalling
 
configure_file(
 
  "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
 
  "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
 
  IMMEDIATE @ONLY)
 

	
 
add_custom_target(uninstall
 
  COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
 
  COMMAND ${XDG-DESKTOP-MENU} uninstall --novendor serialplot.desktop
 
  COMMAND ${XDG-ICON-RESOURCE} uninstall --novendor --size 256 serialplot)
 
if (UNIX)
 
  add_custom_target(uninstall
 
    COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
 
    COMMAND ${XDG-DESKTOP-MENU} uninstall --novendor serialplot.desktop
 
    COMMAND ${XDG-ICON-RESOURCE} uninstall --novendor --size 256 serialplot)
 
endif (UNIX)
 

	
 
# packaging
 
set(CPACK_GENERATOR "DEB")
 
if (UNIX)
 
  set(CPACK_GENERATOR "DEB")
 
elseif (WIN32)
 
  set(CPACK_GENERATOR "NSIS")
 
endif (UNIX)
 

	
 
include(InstallRequiredSystemLibraries)
 

	
 
set(CPACK_PACKAGE_NAME "serialplot")
 
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Small and simple software for plotting data from serial port")
 
set(CPACK_PACKAGE_CONTACT "Hasan Yavuz Özderya <hy@ozderya.net>")
 
set(CPACK_PACKAGE_VERSION_MAJOR ${MAJOR_VERSION})
 
set(CPACK_PACKAGE_VERSION_MINOR ${MINOR_VERSION})
 
set(CPACK_PACKAGE_VERSION_PATCH ${PATCH_VERSION})
 
set(CPACK_STRIP_FILES TRUE)
 
set(CPACK_PACKAGE_EXECUTABLES "serialplot")
 
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libqt5widgets5 (>= 5.2.1), libqt5serialport5 (>= 5.2.1), libc6 (>= 2.19)")
 
if (NOT QWT_USE_STATIC)
 
  set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}, libqwt6-qt5 (>= 6.1.1)")
 
endif (NOT QWT_USE_STATIC)
 
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_SOURCE_DIR}/debian/postinst" "${CMAKE_SOURCE_DIR}/debian/postrm")
 

	
 
# set debian package name
 
string(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_PACKAGE_NAME_LOWERCASE)
 
find_program(DPKG_PROGRAM dpkg DOC "dpkg program of Debian-based systems")
 
if(DPKG_PROGRAM)
 
  execute_process(
 
    COMMAND ${DPKG_PROGRAM} --print-architecture
 
    OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE
 
    OUTPUT_STRIP_TRAILING_WHITESPACE)
 
  set(CPACK_PACKAGE_FILE_NAME
 
	"${CPACK_PACKAGE_NAME_LOWERCASE}_${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
 
else(DPKG_PROGRAM)
 
  set(CPACK_PACKAGE_FILE_NAME
 
	"${CPACK_PACKAGE_NAME_LOWERCASE}_${PROJECT_VERSION}-${PROJECT_VERSION_REVISION}_${CMAKE_SYSTEM_NAME}")
 
endif(DPKG_PROGRAM)
 
if (UNIX)
 
  set(CPACK_PACKAGE_EXECUTABLES "serialplot")
 
elseif (WIN32)
 
  set(CPACK_PACKAGE_EXECUTABLES "serialplot;SerialPlot")
 
  set(CPACK_CREATE_DESKTOP_LINKS "serialplot")
 
  set(CPACK_NSIS_MODIFY_PATH "ON")
 
  set(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/misc/serialplot.bmp")
 
  string(REPLACE "/" "\\\\" CPACK_PACKAGE_ICON ${CPACK_PACKAGE_ICON})
 
  set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING")
 
  set(CPACK_NSIS_MENU_LINKS
 
    "https://bitbucket.org/hyOzd/serialplot" "SerialPlot source code on bitbucket.org")
 
endif (UNIX)
 

	
 
if (UNIX)
 
  # set debian package name
 
  string(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_PACKAGE_NAME_LOWERCASE)
 
  find_program(DPKG_PROGRAM dpkg DOC "dpkg program of Debian-based systems")
 
  if(DPKG_PROGRAM)
 
    execute_process(
 
      COMMAND ${DPKG_PROGRAM} --print-architecture
 
      OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE
 
      OUTPUT_STRIP_TRAILING_WHITESPACE)
 
    set(CPACK_PACKAGE_FILE_NAME
 
      "${CPACK_PACKAGE_NAME_LOWERCASE}_${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
 
  else(DPKG_PROGRAM)
 
    set(CPACK_PACKAGE_FILE_NAME
 
      "${CPACK_PACKAGE_NAME_LOWERCASE}_${PROJECT_VERSION}-${PROJECT_VERSION_REVISION}_${CMAKE_SYSTEM_NAME}")
 
  endif(DPKG_PROGRAM)
 
endif (UNIX)
 

	
 
include(CPack)
mainwindow.cpp
Show inline comments
 
@@ -26,24 +26,29 @@
 
#include <QTextStream>
 
#include <QtDebug>
 
#include <QtEndian>
 
#include <qwt_plot.h>
 
#include <limits.h>
 
#include <cmath>
 
#include <iostream>
 

	
 
#include "utils.h"
 
#include "version.h"
 
#include "floatswap.h"
 

	
 
#if defined(Q_OS_WIN) && defined(QT_STATIC)
 
#include <QtPlugin>
 
Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)
 
#endif
 

	
 
MainWindow::MainWindow(QWidget *parent) :
 
    QMainWindow(parent),
 
    ui(new Ui::MainWindow),
 
    portControl(&serialPort)
 
{
 
    ui->setupUi(this);
 
    ui->tabWidget->insertTab(0, &portControl, "Port");
 
    ui->tabWidget->setCurrentIndex(0);
 

	
 
    setupAboutDialog();
 

	
 
    // init UI signals
misc/serialplot.bmp
Show inline comments
 
new file 100644
 
binary diff not shown
Show images
misc/serialplot.ico
Show inline comments
 
new file 100644
 
binary diff not shown
misc/windows_icon.rc
Show inline comments
 
new file 100644
 
IDI_ICON1               ICON    DISCARDABLE     "serialplot.ico"
 
\ No newline at end of file
0 comments (0 inline, 0 general)