Skip to content

Commit

Permalink
Update CMake with default Warning settings.
Browse files Browse the repository at this point in the history
Build workflow is also updated.
  • Loading branch information
Mokona committed Feb 28, 2023
1 parent ffc4d26 commit 28cafe3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 9 additions & 7 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down Expand Up @@ -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:

Expand Down Expand Up @@ -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
Expand Down
11 changes: 10 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit 28cafe3

Please sign in to comment.