Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a DEV_MODE option to enable more warnings #195

Merged
merged 2 commits into from
Dec 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/linux-gcc13.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
{ "name": "Static", "option": "OFF"}
]
env:
CMAKE_OPTIONS: -DCMAKE_CXX_EXTENSIONS=OFF -DBUILD_TESTING=ON
CMAKE_OPTIONS: -DDEV_MODE=ON -DBUILD_TESTING=ON
steps:
- uses: lukka/get-cmake@latest

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
name: libebml
runs-on: ubuntu-latest
env:
CMAKE_OPTIONS: -DCMAKE_CXX_EXTENSIONS=OFF -DBUILD_TESTING=ON
CMAKE_OPTIONS: -DDEV_MODE=ON -DBUILD_TESTING=ON
steps:
- uses: lukka/get-cmake@latest

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/macos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
matrix:
arch: [x86_64, arm64]
env:
CMAKE_OPTIONS: -DCMAKE_CXX_EXTENSIONS=OFF -DBUILD_TESTING=ON
CMAKE_OPTIONS: -DDEV_MODE=ON -DBUILD_TESTING=ON
steps:
- uses: lukka/get-cmake@latest

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/uwp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ jobs:
{ "name": "arm64", "option": "arm64"},
]
env:
CMAKE_OPTIONS: -DCMAKE_CXX_EXTENSIONS=OFF -DCMAKE_SYSTEM_NAME="WindowsStore" -DCMAKE_SYSTEM_VERSION="10.0" -DCMAKE_CXX_FLAGS_INIT="-DWINVER=0x0A00 -DWINAPI_FAMILY=WINAPI_FAMILY_PC_APP"
CMAKE_OPTIONS: -DDEV_MODE=ON -DCMAKE_SYSTEM_NAME="WindowsStore" -DCMAKE_SYSTEM_VERSION="10.0" -DCMAKE_CXX_FLAGS_INIT="-DWINVER=0x0A00 -DWINAPI_FAMILY=WINAPI_FAMILY_PC_APP"
# TODO use CreateFile2 and add -DENABLE_WIN32_IO=ON
steps:
- uses: lukka/get-cmake@latest

- name: Get pushed code
uses: actions/checkout@v3

- name: Configure
run: cmake -S . -B _build ${{ env.CMAKE_OPTIONS }} -A ${{ matrix.arch.option }} -DBUILD_SHARED_LIBS=OFF

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
{ "name": "arm64", "option": "arm64", "env": "ARM64"},
]
env:
CMAKE_OPTIONS: -DENABLE_WIN32_IO=ON -DCMAKE_CXX_EXTENSIONS=OFF -DCMAKE_CXX_FLAGS_INIT="-DWINVER=0x0501" -DBUILD_TESTING=ON
CMAKE_OPTIONS: -DENABLE_WIN32_IO=ON -DDEV_MODE=ON -DCMAKE_CXX_FLAGS_INIT="-DWINVER=0x0501" -DBUILD_TESTING=ON
steps:
- uses: lukka/get-cmake@latest

Expand Down
25 changes: 25 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,37 @@ option(DISABLE_PKGCONFIG "Disable PkgConfig module generation" OFF)
option(DISABLE_CMAKE_CONFIG "Disable CMake package config module generation" OFF)
cmake_dependent_option(BUILD_SHARED_LIBS "Build libebml as a shared library (except Windows)" OFF "NOT WIN32" OFF)
option(BUILD_TESTING "Build tests" OFF)
option(DEV_MODE "Developer mode with extra compilation checks" OFF)

include(GNUInstallDirs)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

include(CheckCXXCompilerFlag)
include(CMakeParseArguments)
function(add_cxx_flag_if_supported)
foreach(flagname ${ARGN})
string(REPLACE "-" "_" TEST_RESULT ${flagname})
check_cxx_compiler_flag(${flagname} HAVE_FLAG_${TEST_RESULT})
# message(STATUS "supported ${flagname}: ${HAVE_FLAG_${TEST_RESULT}}")

if (HAVE_FLAG_${TEST_RESULT})
add_compile_options(${flagname})
endif()
endforeach()
endfunction()

if(DEV_MODE)
message(STATUS "Using developer mode for ${CMAKE_CXX_COMPILER_ID}")
set(CMAKE_CXX_EXTENSIONS OFF)
add_cxx_flag_if_supported(-Wall -Wno-comment -Wfatal-errors -fstack-protector-strong -Wnon-virtual-dtor -Wextra
-Wunused -Wpedantic -Woverloaded-virtual -Wshadow
-Wno-self-assign -Wno-mismatched-tags -Wno-inconsistent-missing-override
-Wno-potentially-evaluated-expression -Wno-extra-semi -Wno-gnu-zero-variadic-macro-arguments)
add_cxx_flag_if_supported(-Qunused-arguments)
endif()

set(libebml_SOURCES
src/EbmlBinary.cpp
src/EbmlContexts.cpp
Expand Down