Skip to content

Commit

Permalink
build(cmake): error build on warning (LizardByte#2165)
Browse files Browse the repository at this point in the history
  • Loading branch information
ReenigneArcher authored and KuleRucket committed Jun 6, 2024
1 parent f177d26 commit 8785f22
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 6 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,9 @@ jobs:
mkdir -p artifacts
cd build
cmake -DCMAKE_BUILD_TYPE=Release \
cmake \
-DBUILD_WERROR=ON \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr \
-DSUNSHINE_ASSETS_DIR=share/sunshine \
-DSUNSHINE_EXECUTABLE_PATH=/usr/bin/sunshine \
Expand Down Expand Up @@ -576,7 +578,9 @@ jobs:
run: |
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release \
cmake \
-DBUILD_WERROR=ON \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr \
-DSUNSHINE_ASSETS_DIR=local/sunshine/assets \
-DSUNSHINE_EXECUTABLE_PATH=/usr/bin/sunshine \
Expand Down Expand Up @@ -784,7 +788,9 @@ jobs:
run: |
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo \
cmake \
-DBUILD_WERROR=ON \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DSUNSHINE_ASSETS_DIR=assets \
-G "MinGW Makefiles" \
..
Expand Down
20 changes: 19 additions & 1 deletion cmake/compile_definitions/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,25 @@

list(APPEND SUNSHINE_COMPILE_OPTIONS -Wall -Wno-sign-compare)
# Wall - enable all warnings
# Werror - treat warnings as errors
# Wno-maybe-uninitialized/Wno-uninitialized - disable warnings for maybe uninitialized variables
# Wno-sign-compare - disable warnings for signed/unsigned comparisons
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# GCC specific compile options

# GCC 12 and higher will complain about maybe-uninitialized
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 12)
list(APPEND SUNSHINE_COMPILE_OPTIONS -Wno-maybe-uninitialized)
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
# Clang specific compile options

# Clang doesn't actually complain about this this, so disabling for now
# list(APPEND SUNSHINE_COMPILE_OPTIONS -Wno-uninitialized)
endif()
if(BUILD_WERROR)
list(APPEND SUNSHINE_COMPILE_OPTIONS -Werror)
endif()

# setup assets directory
if(NOT SUNSHINE_ASSETS_DIR)
Expand All @@ -28,7 +46,7 @@ file(GLOB NVENC_SOURCES CONFIGURE_DEPENDS "src/nvenc/*.cpp" "src/nvenc/*.h")
list(APPEND PLATFORM_TARGET_FILES ${NVENC_SOURCES})

configure_file("${CMAKE_SOURCE_DIR}/src/version.h.in" version.h @ONLY)
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
include_directories("${CMAKE_CURRENT_BINARY_DIR}") # required for importing version.h

set(SUNSHINE_TARGET_FILES
"${CMAKE_SOURCE_DIR}/third-party/nanors/rs.c"
Expand Down
11 changes: 10 additions & 1 deletion cmake/compile_definitions/windows.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ enable_language(RC)
set(CMAKE_RC_COMPILER windres)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")

# gcc complains about misleading indentation in some mingw includes
list(APPEND SUNSHINE_COMPILE_OPTIONS -Wno-misleading-indentation)

# curl
add_definitions(-DCURL_STATICLIB)
include_directories(SYSTEM ${CURL_STATIC_INCLUDE_DIRS})
Expand All @@ -28,8 +31,14 @@ file(GLOB NVPREFS_FILES CONFIGURE_DEPENDS
include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/third-party/ViGEmClient/include")
set_source_files_properties("${CMAKE_SOURCE_DIR}/third-party/ViGEmClient/src/ViGEmClient.cpp"
PROPERTIES COMPILE_DEFINITIONS "UNICODE=1;ERROR_INVALID_DEVICE_OBJECT_PARAMETER=650")
set(VIGEM_COMPILE_FLAGS "")
string(APPEND VIGEM_COMPILE_FLAGS "-Wno-unknown-pragmas ")
string(APPEND VIGEM_COMPILE_FLAGS "-Wno-misleading-indentation ")
string(APPEND VIGEM_COMPILE_FLAGS "-Wno-class-memaccess ")
string(APPEND VIGEM_COMPILE_FLAGS "-Wno-unused-function ")
string(APPEND VIGEM_COMPILE_FLAGS "-Wno-unused-variable ")
set_source_files_properties("${CMAKE_SOURCE_DIR}/third-party/ViGEmClient/src/ViGEmClient.cpp"
PROPERTIES COMPILE_FLAGS "-Wno-unknown-pragmas -Wno-misleading-indentation -Wno-class-memaccess")
PROPERTIES COMPILE_FLAGS ${VIGEM_COMPILE_FLAGS})

# sunshine icon
if(NOT DEFINED SUNSHINE_ICON_PATH)
Expand Down
2 changes: 2 additions & 0 deletions cmake/prep/options.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
option(BUILD_WERROR "Enable -Werror flag." OFF)

# if this option is set, the build will exit after configuring special package configuration files
option(SUNSHINE_CONFIGURE_ONLY "Configure special files only, then exit." OFF)

Expand Down
1 change: 1 addition & 0 deletions docker/debian-bookworm.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ RUN <<_MAKE
#!/bin/bash
set -e
cmake \
-DBUILD_WERROR=ON \
-DCMAKE_CUDA_COMPILER:PATH=/build/cuda/bin/nvcc \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr \
Expand Down
1 change: 1 addition & 0 deletions docker/debian-bullseye.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ set -e
source "$HOME/.nvm/nvm.sh"
nvm use 20.9.0
cmake \
-DBUILD_WERROR=ON \
-DCMAKE_CUDA_COMPILER:PATH=/build/cuda/bin/nvcc \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr \
Expand Down
1 change: 1 addition & 0 deletions docker/fedora-38.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ RUN <<_MAKE
#!/bin/bash
set -e
cmake \
-DBUILD_WERROR=ON \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr \
-DSUNSHINE_ASSETS_DIR=share/sunshine \
Expand Down
1 change: 1 addition & 0 deletions docker/fedora-39.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ RUN <<_MAKE
#!/bin/bash
set -e
cmake \
-DBUILD_WERROR=ON \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr \
-DSUNSHINE_ASSETS_DIR=share/sunshine \
Expand Down
1 change: 1 addition & 0 deletions docker/ubuntu-20.04.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ set -e
source "$HOME/.nvm/nvm.sh"
nvm use 20.9.0
cmake \
-DBUILD_WERROR=ON \
-DCMAKE_CUDA_COMPILER:PATH=/build/cuda/bin/nvcc \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr \
Expand Down
1 change: 1 addition & 0 deletions docker/ubuntu-22.04.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ source "$HOME/.nvm/nvm.sh"
nvm use 20.9.0
#Actually build
cmake \
-DBUILD_WERROR=ON \
-DCMAKE_CUDA_COMPILER:PATH=/build/cuda/bin/nvcc \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr \
Expand Down
1 change: 1 addition & 0 deletions packaging/linux/Arch/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ build() {
-S "$pkgname" \
-B build \
-Wno-dev \
-D BUILD_WERROR=ON \
-D CMAKE_INSTALL_PREFIX=/usr \
-D SUNSHINE_EXECUTABLE_PATH=/usr/bin/sunshine \
-D SUNSHINE_ASSETS_DIR="share/sunshine"
Expand Down
1 change: 1 addition & 0 deletions packaging/linux/flatpak/dev.lizardbyte.sunshine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ modules:
npm_config_nodedir: /usr/lib/sdk/node18
NPM_CONFIG_LOGLEVEL: info
config-opts:
- -DBUILD_WERROR=ON
- -DCMAKE_BUILD_TYPE=Release
- -DCMAKE_INSTALL_PREFIX=/app
- -DCMAKE_CUDA_COMPILER=/app/cuda/bin/nvcc
Expand Down
3 changes: 2 additions & 1 deletion packaging/macos/Portfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ depends_lib port:avahi \

boost.version 1.81

configure.args -DCMAKE_INSTALL_PREFIX=${prefix} \
configure.args -DBUILD_WERROR=ON \
-DCMAKE_INSTALL_PREFIX=${prefix} \
-DSUNSHINE_ASSETS_DIR=etc/sunshine/assets

startupitem.create yes
Expand Down

0 comments on commit 8785f22

Please sign in to comment.