+ # On Windows we need to statically link the libqsvg imageformat
+ # plugin (and the QtSvg component) for SVG graphics/icons to work.
+ # We also need QWindowsIntegrationPlugin, Qt5PlatformSupport, and all
+ # Qt libs and their dependencies.
+ add_definitions(-DQT_STATICPLUGIN)
+ list(APPEND PULSEVIEW_LINK_LIBS Qt5::QSvgPlugin)
+ list(APPEND PULSEVIEW_LINK_LIBS Qt5::QWindowsIntegrationPlugin)
+ list(APPEND PULSEVIEW_LINK_LIBS -lQt5PlatformSupport ${QT5ALL_LDFLAGS})
+endif()
+
+if(ANDROID)
+ list(APPEND PULSEVIEW_LINK_LIBS "-llog")
+endif()
+
+if(ANDROID)
+ add_library(${PROJECT_NAME} SHARED ${pulseview_SOURCES} ${pulseview_RESOURCES_RCC})
+else()
+ add_executable(${PROJECT_NAME} ${pulseview_SOURCES} ${pulseview_RESOURCES_RCC})
+endif()
+
+target_link_libraries(${PROJECT_NAME} ${PULSEVIEW_LINK_LIBS})
+
+if(WIN32 AND NOT ${CMAKE_BUILD_TYPE} STREQUAL "Debug")
+ # Pass -mwindows so that no "DOS box" opens when PulseView is started.
+ set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-mwindows")
+endif()
+
+#===============================================================================
+#= Installation
+#-------------------------------------------------------------------------------
+
+# Install the executable.
+install(TARGETS ${PROJECT_NAME} DESTINATION bin/)
+
+# Install the manpage.
+install(FILES doc/pulseview.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 COMPONENT doc)
+
+# Install the desktop file.
+install(FILES contrib/org.sigrok.PulseView.desktop DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/applications)
+
+# Install the AppData/AppStream file.
+install(FILES contrib/org.sigrok.PulseView.appdata.xml DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/metainfo)
+
+# Install the PulseView icons.
+install(FILES icons/pulseview.png DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/48x48/apps)
+install(FILES icons/pulseview.svg DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/apps)
+
+# Generate Windows installer script.
+configure_file(contrib/pulseview_cross.nsi.in contrib/pulseview_cross.nsi @ONLY)
+
+#===============================================================================
+#= Packaging (handled by CPack)
+#-------------------------------------------------------------------------------
+
+set(CPACK_PACKAGE_VERSION_MAJOR ${PV_VERSION_MAJOR})
+set(CPACK_PACKAGE_VERSION_MINOR ${PV_VERSION_MINOR})
+set(CPACK_PACKAGE_VERSION_PATCH ${PV_VERSION_MICRO})
+set(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_CURRENT_SOURCE_DIR}/README)
+set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/COPYING)
+set(CPACK_SOURCE_IGNORE_FILES ${CMAKE_CURRENT_BINARY_DIR} ".gitignore" ".git")
+set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${PV_VERSION_STRING}")
+set(CPACK_SOURCE_GENERATOR "TGZ")
+
+include(CPack)
+
+#===============================================================================
+#= Tests
+#-------------------------------------------------------------------------------