File: CLI11Warnings.cmake

package info (click to toggle)
cli11 2.4.1%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 2,120 kB
  • sloc: cpp: 23,299; python: 129; sh: 64; makefile: 11; ruby: 7
file content (37 lines) | stat: -rw-r--r-- 1,193 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Special target that adds warnings. Is not exported.
add_library(CLI11_warnings INTERFACE)

set(unix-warnings -Wall -Wextra -pedantic -Wshadow -Wsign-conversion -Wswitch-enum)

# Clang warnings
# -Wfloat-equal could be added with Catch::literals and _a usage
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  list(
    APPEND
    unix-warnings
    -Wcast-align
    -Wimplicit-atomic-properties
    -Wmissing-declarations
    -Woverlength-strings
    -Wshadow
    -Wstrict-selector-match
    -Wundeclared-selector)
  # -Wunreachable-code Doesn't work on Clang 3.4
endif()

# Buggy in GCC 4.8
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9)
  list(APPEND unix-warnings -Weffc++)
endif()

target_compile_options(
  CLI11_warnings
  INTERFACE $<$<BOOL:${CLI11_FORCE_LIBCXX}>:-stdlib=libc++>
            $<$<CXX_COMPILER_ID:MSVC>:/W4
            $<$<BOOL:${CLI11_WARNINGS_AS_ERRORS}>:/WX>>
            $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:${unix-warnings}
            $<$<BOOL:${CLI11_WARNINGS_AS_ERRORS}>:-Werror>>)

if(NOT CMAKE_VERSION VERSION_LESS 3.13)
  target_link_options(CLI11_warnings INTERFACE $<$<BOOL:${CLI11_FORCE_LIBCXX}>:-stdlib=libc++>)
endif()