Skip to content

Commit

Permalink
Complete migration to CMake (#301)
Browse files Browse the repository at this point in the history
  • Loading branch information
phnzb authored Jun 21, 2024
1 parent 9405f18 commit 515cd10
Show file tree
Hide file tree
Showing 59 changed files with 323 additions and 5,669 deletions.
12 changes: 1 addition & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ jobs:
permissions:
actions: write

build-synology:
uses: ./.github/workflows/synology.yml

build-qnap:
uses: ./.github/workflows/qnap.yml

build-linux-pkg:
uses: ./.github/workflows/linux-pkg.yml
with:
Expand All @@ -45,7 +39,7 @@ jobs:
env:
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
runs-on: ubuntu-latest
needs: [build-windows, build-linux, build-osx, build-synology, build-qnap, repack-qnap, build-linux-pkg]
needs: [build-windows, build-linux, build-osx, repack-qnap, build-linux-pkg]
permissions:
actions: write
steps:
Expand All @@ -59,9 +53,7 @@ jobs:
mv nzbget-windows-installers/* builds || true
mv nzbget-linux-installers/* builds || true
mv nzbget-osx-installers/* builds || true
mv nzbget-synology-packages/* builds || true
mv nzbget-qnap-packages/* builds || true
mv nzbget-qnap-native-packages/* builds || true
mv nzbget-deb-packages/* builds || true
mv nzbget-rpm-packages/* builds || true
cd builds
Expand Down Expand Up @@ -111,9 +103,7 @@ jobs:
nzbget-windows-installers
nzbget-linux-installers
nzbget-osx-installers
nzbget-synology-packages
nzbget-qnap-packages
nzbget-qnap-native-packages
- name: Delete unneded linux packages artifacts
uses: geekyeggo/delete-artifact@v4
Expand Down
26 changes: 11 additions & 15 deletions .github/workflows/osx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ jobs:
- name: Build
run: |
if [ "$GITHUB_REF_NAME" != "main" ]; then
bash osx/build-nzbget-x64.sh testing
bash osx/build-nzbget.sh x64 testing
else
bash osx/build-nzbget-x64.sh
bash osx/build-nzbget.sh x64
fi
- name: Rename build artifacts
Expand Down Expand Up @@ -51,34 +51,30 @@ jobs:
with:
fetch-depth: 0

- name: Change version for non-release
if: github.ref_name != 'main'
run: |
VERSION=$(cat configure.ac | grep AC_INIT | cut -d , -f 2 | xargs)
NEW_VERSION="$VERSION-testing-$(date '+%Y%m%d')"
sed -e "s|AC_INIT(nzbget.*|AC_INIT(nzbget, $NEW_VERSION, https://github.com/nzbgetcom/nzbget/issues)|g" -i '' configure.ac
echo NEW_VERSION=$NEW_VERSION >> $GITHUB_ENV
- name: Build
run: |
bash osx/build-nzbget-universal.sh
if [ "$GITHUB_REF_NAME" != "main" ]; then
bash osx/build-nzbget.sh universal testing
else
bash osx/build-nzbget.sh universal
fi
- name: Rename build artifacts
if: github.ref_name != 'main' && github.ref_name != 'develop'
run: |
cd osx/build/Release
NEW_VERSION_FEATURE="$NEW_VERSION-${GITHUB_REF_NAME/\//-}"
cd build
SUFFIX="${GITHUB_REF_NAME/\//-}"
for FILE in *.zip; do
[ -f $FILE ] || continue
NEW_FILE=${FILE/$NEW_VERSION/$NEW_VERSION_FEATURE}
NEW_FILE=${FILE/-bin-macos-universal.zip/-$SUFFIX-bin-macos-universal.zip}
mv $FILE $NEW_FILE
done
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: nzbget-osx-installers-universal
path: osx/build/Release/*.zip
path: build/*-universal.zip
retention-days: 5

combine-osx-artifacts:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/qnap-repack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- name: Rename build artifacts
if: github.ref_name != 'main'
run: |
VERSION=$(cat configure.ac | grep AC_INIT | cut -d , -f 2 | xargs)
VERSION=$(grep "set(VERSION " CMakeLists.txt | cut -d '"' -f 2)
NEW_VERSION="$VERSION-testing-$(date '+%Y%m%d')"
cd /qnap/nzbget/build/
for FILE in *.qpkg; do
Expand Down
49 changes: 0 additions & 49 deletions .github/workflows/qnap.yml

This file was deleted.

43 changes: 0 additions & 43 deletions .github/workflows/synology.yml

This file was deleted.

27 changes: 25 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ set_property(GLOBAL PROPERTY INCLUDES)
set(VERSION "24.2")
set(PACKAGE "nzbget")
set(PACKAGE_BUGREPORT "https://github.com/nzbgetcom/nzbget/issues")
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_C_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
Expand All @@ -38,6 +38,29 @@ project(
LANGUAGES C CXX
)

if(APPLE)
# On macOS Cmake, when cross-compiling, sometimes CMAKE_SYSTEM_PROCESSOR wrongfully stays
# the same as CMAKE_HOST_SYSTEM_PROCESSOR regardless the target CPU.
# The manual call to set(CMAKE_SYSTEM_PROCESSOR) has to be set after the project() call.
# because project() might reset CMAKE_SYSTEM_PROCESSOR back to the value of CMAKE_HOST_SYSTEM_PROCESSOR.
# Check if CMAKE_SYSTEM_PROCESSOR is not equal to CMAKE_OSX_ARCHITECTURES
if(NOT CMAKE_OSX_ARCHITECTURES STREQUAL "")
if(NOT CMAKE_SYSTEM_PROCESSOR STREQUAL CMAKE_OSX_ARCHITECTURES)
# Split CMAKE_OSX_ARCHITECTURES into a list
string(REPLACE ";" " " ARCH_LIST ${CMAKE_OSX_ARCHITECTURES})
separate_arguments(ARCH_LIST UNIX_COMMAND ${ARCH_LIST})
# Count the number of architectures
list(LENGTH ARCH_LIST ARCH_COUNT)
# Ensure that exactly one architecture is specified
if(NOT ARCH_COUNT EQUAL 1)
message(FATAL_ERROR "CMAKE_OSX_ARCHITECTURES must have exactly one value. Current value: ${CMAKE_OSX_ARCHITECTURES}")
endif()
set(CMAKE_SYSTEM_PROCESSOR ${CMAKE_OSX_ARCHITECTURES})
message(STATUS "CMAKE_SYSTEM_PROCESSOR is manually set to ${CMAKE_SYSTEM_PROCESSOR}")
endif()
endif()
endif()

if(CMAKE_BUILD_TYPE STREQUAL "Debug")
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|AppleClang")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -pthread -g -DDEBUG -Weverything -Wno-c++98-compat" CACHE STRING "" FORCE)
Expand Down
Loading

0 comments on commit 515cd10

Please sign in to comment.