From a837f2e73ab6d323796dcd78bf0022931719c200 Mon Sep 17 00:00:00 2001 From: bbbbx Date: Sun, 28 Aug 2022 00:49:51 +0800 Subject: [PATCH] Update action --- .github/workflows/build_macos.yml | 37 ++++++----------------------- CMakeLists.txt | 13 ++++++----- README.md | 39 ++++++++++++++++++++++++++++--- 3 files changed, 50 insertions(+), 39 deletions(-) diff --git a/.github/workflows/build_macos.yml b/.github/workflows/build_macos.yml index 5eac15b..6837cdc 100644 --- a/.github/workflows/build_macos.yml +++ b/.github/workflows/build_macos.yml @@ -2,8 +2,7 @@ name: Build macOS on: push: - tags: - - '*' + branches: [main] pull_request: branches: [main] @@ -14,38 +13,16 @@ jobs: runs-on: macos-latest strategy: matrix: - configuration: [Release] + configuration: [Debug, Release] steps: - uses: actions/checkout@v3 with: submodules: 'true' - - name: Install Package - uses: ConorMacBride/install-package@v1.1.0 - with: - brew: ffmpeg + - name: Install nasm + run: brew install nasm + - name: Compile FFmpeg + run: cd ${{github.workspace}}/extern/FFmpeg && mkdir build && ./configure --prefix=$(pwd)/build --disable-doc --disable-programs --disable-static --enable-shared && make -j8 && make install - name: Configure CMake - run: cmake . -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DFFmpeg_INCLUDE=$(brew --prefix)/include -DFFmpeg_LIB=$(brew --prefix)/lib + run: cmake . -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.configuration}} -DFFmpeg_INCLUDE=${{github.workspace}}/extern/FFmpeg/build/include -DFFmpeg_LIB=${{github.workspace}}/extern/FFmpeg/build/lib - name: Build run: cmake --build ${{github.workspace}}/build -j 8 --config ${{matrix.configuration}} - - name: Release - uses: actions/create-release@v1 - id: create-release - with: - draft: false - prerelease: false - release_name: ${{ github.ref }} - tag_name: ${{ github.ref }} - env: - GITHUB_TOKEN: ${{ github.token }} - - name: pack into zip - run: zip --junk-paths ShadeYourDesktop bin/ShadeYourDesktop - - name: Upload artifacts to release - uses: actions/upload-release-asset@v1 - with: - upload_url: ${{ steps.create-release.outputs.upload_url }} - asset_path: ./ShadeYourDesktop.zip - asset_name: ShadeYourDesktop.zip - asset_content_type: application/zip - env: - GITHUB_TOKEN: ${{ github.token }} - diff --git a/CMakeLists.txt b/CMakeLists.txt index 2240d9b..df3aca8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,8 @@ endif() project( ShadeYourDesktop ) +set( TARGET_NAME ${PROJECT_NAME} ) + set( CMAKE_CXX_STANDARD 17 ) set( CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin" ) @@ -61,10 +63,9 @@ elseif( MSVC ) list( APPEND SHADE_YOUR_DESKTOP_SRC "${CMAKE_CURRENT_SOURCE_DIR}/src/put_window_behind_desktop_icons_win.cpp" ) endif() -add_executable( ShadeYourDesktop ${SHADE_YOUR_DESKTOP_SRC} ) -target_link_directories( ShadeYourDesktop PRIVATE - ${FFmpeg_LIB} ) -target_link_libraries( ShadeYourDesktop +add_executable( ${TARGET_NAME} ${SHADE_YOUR_DESKTOP_SRC} ) +target_link_directories( ${TARGET_NAME} PRIVATE ${FFmpeg_LIB} ) +target_link_libraries( ${TARGET_NAME} glfw avformat avcodec @@ -74,8 +75,8 @@ target_link_libraries( ShadeYourDesktop if ( MSCV ) if ( ${CMAKE_VERSION} VERSION_LESS "3.6.0" ) - message( "\n\t[ WARNING ]\n\n\tCMake version is less then 3.6\n\n\t - Please update CMake and rerun; OR\n\t - Manually set 'ShadeYourDesktop' as StartUp Project in Visual Studio.\n") + message( "\n\t[ WARNING ]\n\n\tCMake version is less then 3.6\n\n\t - Please update CMake and rerun; OR\n\t - Manually set '${TARGET_NAME}' as StartUp Project in Visual Studio.\n") else() - set_property( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PERPROTY VS_STARTUP_PROJECT ShadeYourDesktop) + set_property( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PERPROTY VS_STARTUP_PROJECT ${TARGET_NAME}) endif() endif() diff --git a/README.md b/README.md index 7d3f972..249dacb 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Shade Your Desktop +# Shade Your Desktop [![Build macOS](https://github.com/bbbbx/ShadeYourDesktop/actions/workflows/build_macos.yml/badge.svg)](https://github.com/bbbbx/ShadeYourDesktop/actions/workflows/build_macos.yml)


@@ -11,12 +11,36 @@ - [FFmpeg](https://ffmpeg.org/download.html) +### Install FFmpeg with Homebrew + Use [Homebrew](https://brew.sh/) to install them: ```sh $ brew install ffmpeg ``` +### Install FFmpeg from source code + +Make sure the git submodules was updated: + +```sh +git submodule update --init --recursive +``` + +Compile shared libraries and install: + +```sh +$ cd extern/FFmpeg && \ +mkdir build && \ +./configure --prefix=$(pwd)/build --disable-doc --disable-programs --disable-static --enable-shared && \ +make -j8 && \ +make install +``` + +The installation directory should be `extern/FFmpeg/build`. + +If compilation complains `nasm/yasm not found or too old.`, you can use brew to install `nasm` or `yasm`, and try again. + ## Compile In order to include and link FFmpeg correctly, there are two options you need to specify, or just use the defaults: @@ -24,12 +48,21 @@ In order to include and link FFmpeg correctly, there are two options you need to - `FFmpeg_INCLUDE`: default is `/opt/homebrew/include` - `FFmpeg_LIB`: default is `/opt/homebrew/lib` -and make sure FFmpeg shared libraries(.ddl for Windows, .dylib for macOS) are included your path. +and make sure FFmpeg shared libraries(.ddl for Windows, .dylib for macOS, .so for Linux) are included your path. -Use [CMake](https://cmake.org/) to control compilation process: +Config CMake from project root directory: ```sh $ cmake . -B build -DFFmpeg_INCLUDE= -DFFmpeg_LIB= +``` + +For example: +1. if you install FFmpeg with Homebrew, `` could be `$(brew --prefix)/include`, and `` could be `$(brew --prefix)/lib`; +2. if you install FFmpeg from source code, `` could be `$(pwd)/extern/FFmpeg/build/include`, and `` could be `$(pwd)/extern/FFmpeg/build/lib`. + +Then compile: + +```sh $ cmake --build build -j 8 --config Release ```