diff --git a/.github/workflows/build-deb-ubuntu-22.04.yml b/.github/workflows/build-deb-ubuntu-22.04.yml new file mode 100644 index 000000000..518bce0f8 --- /dev/null +++ b/.github/workflows/build-deb-ubuntu-22.04.yml @@ -0,0 +1,33 @@ +on: + push: + branches: [master, deb] + release: + type: [published] +name: deb build for Ubuntu 22.04 +jobs: + build: + runs-on: ubuntu-22.04 + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install dependencies + run: sudo apt-get update && + sudo apt-get install -y + build-essential cmake git + libgtk-3-dev libxml2-dev + libcurl4-openssl-dev libad9361-dev + libaio-dev libiio-dev libgtkdatabox-dev + libjansson-dev libmatio-dev libfftw3-dev + + - name: Generate deb package + run: mkdir build && cd $_ && + cmake -DENABLE_PACKAGING=ON .. && make package + + - name: Upload deb package + uses: actions/upload-artifact@v3 + with: + name: iio-oscilloscope-Ubuntu22.04.deb + path: build/iio-oscilloscope-*-Linux.deb + if-no-files-found: error diff --git a/CMakeLists.txt b/CMakeLists.txt index baa0b610d..a5df4e6c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,7 @@ cmake_minimum_required(VERSION 2.8.7) # needed to use VERSION in 'project()' cmake_policy(SET CMP0048 NEW) set(OSC_VERSION_MAJOR 0) -set(OSC_VERSION_MINOR 8) +set(OSC_VERSION_MINOR 15) set(OSC_VERSION "${OSC_VERSION_MAJOR}.${OSC_VERSION_MINOR}") project(iio-oscilloscope VERSION ${OSC_VERSION} @@ -33,6 +33,12 @@ endif() include(GNUInstallDirs) +if(ENABLE_PACKAGING AND ${CMAKE_INSTALL_FULL_LIBDIR} STREQUAL /usr/local/lib) + # /usr/local/lib might not be in LD_LIBRAY_PATH + set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}") + set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) +endif() + # Get the GIT hash of the latest commit include(FindGit OPTIONAL) if (GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git") @@ -337,3 +343,10 @@ if(NOT EXISTS "${TARGET_PATH}") endif() add_subdirectory(plugins) +option(ENABLE_PACKAGING "Create .deb/.rpm/.tar.gz packages via 'make package'" OFF) + +if(ENABLE_PACKAGING) + if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") + include(cmake/LinuxPackaging.cmake) + endif() +endif() diff --git a/cmake/LinuxPackaging.cmake b/cmake/LinuxPackaging.cmake new file mode 100644 index 000000000..35167b9d7 --- /dev/null +++ b/cmake/LinuxPackaging.cmake @@ -0,0 +1,47 @@ +# support creating some basic binpkgs via `make package` +set(CPACK_SET_DESTDIR ON) +set(CPACK_GENERATOR TGZ) + +FIND_PROGRAM(RPMBUILD_CMD rpmbuild) +if (RPMBUILD_CMD) + # Check if optional dependency is included + if(LIBAD9361_LIBRARIES) + set(LIBAD9361_RPM ", libad9361 >= 0.2") + endif() + if(LIBAD9166_LIBRARIES) + set(LIBAD9166_RPM ", libad9166 >= 0.2") + endif() + # Manual setup of rpm requires, Fedora >= 36 centric + set(CPACK_PACKAGE_RELOCATABLE OFF) + set(CPACK_GENERATOR ${CPACK_GENERATOR};RPM) + set(CPACK_RPM_PACKAGE_REQUIRES "libiio >= 0.23, gtk3 >= 3.24, gtkdatabox >= 1.0.0, jansson >= 2.12, matio >= 1.5.17, fftw >= 3.3.8, curl >= 7.68.0${LIBAD9361_RPM}${LIBAD9166_RPM}") + message(STATUS "Package dependencies (.rpm): " ${CPACK_RPM_PACKAGE_REQUIRES}) +endif() + +FIND_PROGRAM(DEBBUILD_CMD dpkg) +if (DEBBUILD_CMD) + # Check if optional dependency is included + if(LIBAD9361_LIBRARIES) + set(LIBAD9361_DEB ", libad9361-0 (>= 0.2) | libad9361 (>= 0.2)") + endif() + if(LIBAD9166_LIBRARIES) + set(LIBAD9166_DEB ", libad9166 (>= 0.2)") + endif() + set(CPACK_GENERATOR ${CPACK_GENERATOR};DEB) + + set(CPACK_DEBIAN_PACKAGE_DEPENDS "libiio0 (>= 0.23) | libiio (>= 0.23), libgtk-3-0 (>= 3.24.18), libgtkdatabox1 (>= 1.0.0), libjansson4 (>= 2.12), libmatio11 (>= 1.5.21), libfftw3-3 (>= 3.3.8), libcurl4 (>= 7.68.0)${LIBAD9361_DEB}${LIBAD9166_DEB}") + message(STATUS "Package dependencies (.deb): " ${CPACK_DEBIAN_PACKAGE_DEPENDS}) +endif() + +set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY 0) +set(CPACK_PACKAGE_VERSION_MAJOR ${OSC_VERSION_MAJOR}) +set(CPACK_PACKAGE_VERSION_MINOR ${OSC_VERSION_MINOR}) +set(CPACK_PACKAGE_VERSION_PATCH ${OSC_VERSION_GIT}) +set(CPACK_BUNDLE_NAME osc) +set(CPACK_PACKAGE_VERSION ${OSCIO_VERSION}) +if (DEBBUILD_CMD) + # debian specific package settings + set(CPACK_PACKAGE_CONTACT "Engineerzone ") +endif() + +include(CPack)