From 28cafe307b3d1d3d5a3c9d3428eaf4a992f187d7 Mon Sep 17 00:00:00 2001 From: Sylvain Glaize Date: Tue, 28 Feb 2023 23:29:04 +0100 Subject: [PATCH] Update CMake with default Warning settings. Build workflow is also updated. --- .github/workflows/build.yml | 3 --- BUILD.md | 16 +++++++++------- CMakeLists.txt | 11 ++++++++++- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 10c33fe..7459634 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,9 +12,6 @@ env: jobs: build: runs-on: ubuntu-latest - env: - MICRAL_WARNINGS: -Wall -Werror -Wno-unknown-pragmas -Wno-unused-variable - steps: - uses: actions/checkout@v2 diff --git a/BUILD.md b/BUILD.md index a5e0047..4411e14 100644 --- a/BUILD.md +++ b/BUILD.md @@ -37,10 +37,11 @@ make The CMAKE reacts to these environment variables: -* MICRAL_WARNINGS sets up the warnings for compilation. Recommended value is: +* You can override default warning settings by using the MICRAL_WARNINGS environment variable. Recommended value is: * For GCC: MICRAL_WARNINGS="-Wall -Werror -Wno-unknown-pragmas -Wno-unused-variable" * For Clang: MICRAL_WARNINGS="-Wall -Werror -Wno-unknown-pragmas -Wno-unused-variable" * For other compilers: not tested yet +* If not set, default settings are applied Reasons for exceptions: @@ -76,9 +77,10 @@ make The CMAKE reacts to these environment variables: -* MICRAL_WARNINGS sets up the warnings for compilation. Recommended value is: - * For Clang: MICRAL_WARNINGS="-Wall -Werror -Wno-unknown-pragmas -Wno-unused-variable" - * For other compilers: not tested yet +* You can override default warning settings by using the MICRAL_WARNINGS environment variable. Recommended value is: + * For Clang: MICRAL_WARNINGS="-Wall -Werror -Wno-unknown-pragmas -Wno-unused-variable" + * For other compilers: not tested yet +* If not set, default settings are applied Reasons for exceptions: @@ -127,9 +129,9 @@ emcmake cmake ../ # or cmake ../ -DCMAKE_BUILD_TYPE=Debug make ``` -* MICRAL_WARNINGS sets up the warnings for compilation. Recommended value is: - * For Clang: MICRAL_WARNINGS="-Wall -Werror -Wno-unknown-pragmas -Wno-unused-variable ** - -Wno-unused-command-line-argument**" +* You can override default warning settings by using the MICRAL_WARNINGS environment variable. Recommended value is: + * For Clang: MICRAL_WARNINGS="-Wall -Werror -Wno-unknown-pragmas -Wno-unused-variable" +* If not set, default settings are applied * To get the files to deploy, see Packaging further in this document. - Test in a web server : python -m http.server in Python 3 or python -m SimpleHTTPServer in Python 2 diff --git a/CMakeLists.txt b/CMakeLists.txt index c1e7871..e8bbfd1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,16 @@ function(set_warnings target) separate_arguments(WARNING_PARAMETERS NATIVE_COMMAND $ENV{MICRAL_WARNINGS}) target_compile_options(${target} PRIVATE ${WARNING_PARAMETERS}) else() - message(STATUS "MICRAL_WARNINGS environment variable not found. No specific warning setup done.") + if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + message(STATUS "MICRAL_WARNINGS environment variable not found. Set default for Clang. (${target})") + target_compile_options(${target} PRIVATE -Wall -Werror -Wno-unknown-pragmas -Wno-unused-variable) + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + message(STATUS "MICRAL_WARNINGS environment variable not found. Set default for GCC. (${target})") + target_compile_options(${target} PRIVATE -Wall -Werror -Wno-unknown-pragmas -Wno-unused-variable) + else() + message(STATUS "MICRAL_WARNINGS environment variable not found. No specific warning setup done. (${target})") + endif() + endif() endfunction()