diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml new file mode 100644 index 0000000..c3ef845 --- /dev/null +++ b/.semaphore/semaphore.yml @@ -0,0 +1,49 @@ +version: v1.0 +name: Linux-x64 +agent: + machine: + type: e1-standard-2 + os_image: ubuntu1804 +blocks: + - name: Upgrade System + dependencies: [] + task: + prologue: + commands: + - checkout + jobs: + - name: Fetch Version 3.18 of CMake + commands: + - ./build-tools/000-upgrade-system/upgrade-cmake.sh + env_vars: + - name: CMAKE_CACHE_STRING + value: cmake-3-18-0 + - name: CMAKE_VERSION + value: 3.18.0 + - name: Build + dependencies: + - Upgrade System + task: + prologue: + commands: + - sem-version cpp 8 + - checkout + jobs: + - name: Configure & Build + commands: + - ./build-tools/001-configure-and-build/configure-and-build.sh + env_vars: + - name: CMAKE_CACHE_STRING + value: cmake-3-18-0 + - name: CMAKE_VERSION + value: 3.18.0 + - name: Publish + dependencies: + - Build + skip: + when: branch != 'master' + task: + jobs: + - name: Publish + commands: + - ./build-tools/002-publish/publish.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ef7a0a..f7116cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.14) project(wakeup DESCRIPTION "Wake your computer from sleep by sending a Magic Packet" LANGUAGES CXX @@ -8,12 +8,12 @@ set(Boost_NO_BOOST_CMAKE On) set(CMAKE_CXX_EXTENSIONS Off) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED On) +set(CMAKE_POSITION_INDEPENDENT_CODE On) include(./cmake/CPM.cmake) set(BOOST_VERSION 1.67.0) find_package(Boost ${BOOST_VERSION} QUIET) -get_cmake_property(_variableNames VARIABLES) if (NOT ${Boost_FOUND}) CPMAddPackage( NAME boost-cmake @@ -22,7 +22,9 @@ if (NOT ${Boost_FOUND}) ) elseif (NOT TARGET Boost::system) # Add Boost::system target for Boost packages compiled without CMake - add_library(Boost_system INTERFACE) + if (NOT TARGET Boost_system) + add_library(Boost_system INTERFACE) + endif () add_library(Boost::system ALIAS Boost_system) endif () diff --git a/build-tools/000-upgrade-system/upgrade-cmake.sh b/build-tools/000-upgrade-system/upgrade-cmake.sh new file mode 100755 index 0000000..094b458 --- /dev/null +++ b/build-tools/000-upgrade-system/upgrade-cmake.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env sh + +# Exit if CMake version is already cached +cache has_key "${CMAKE_CACHE_STRING}" && exit 0 + +# Download and extract desired version +wget -q "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-Linux-x86_64.tar.gz" +tar zxf "cmake-${CMAKE_VERSION}-Linux-x86_64.tar.gz" + +# Store the newly downloaded version in the cache +cache store "${CMAKE_CACHE_STRING}" "./cmake-${CMAKE_VERSION}-Linux-x86_64/" diff --git a/build-tools/001-configure-and-build/configure-and-build.sh b/build-tools/001-configure-and-build/configure-and-build.sh new file mode 100755 index 0000000..0ca07c9 --- /dev/null +++ b/build-tools/001-configure-and-build/configure-and-build.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env sh + +# Restore CMake from cache +cache restore "${CMAKE_CACHE_STRING}" + +# Configure build +"./cmake-${CMAKE_VERSION}-Linux-x86_64/bin/cmake" -B build -DCMAKE_BUILD_TYPE=Release . + +# Build +"./cmake-${CMAKE_VERSION}-Linux-x86_64/bin/cmake" --build build -j 3 + +# Store the built binary as an artifact +artifact push workflow build/wakeup diff --git a/build-tools/002-publish/publish.sh b/build-tools/002-publish/publish.sh new file mode 100755 index 0000000..6da460b --- /dev/null +++ b/build-tools/002-publish/publish.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env sh + +# Fetch the current artifact +artifact pull workflow build/wakeup + +# Create a tar-ball +tar zcf "wakeup-$(build/wakeup --version).tar.gz" build/wakeup + +# Publish the final tar-balled binary +artifact push project "wakeup-$(build/wakeup --version).tar.gz"