cmake: Enable GCC compiler warnings

This commit is contained in:
Nick Wellnhofer 2022-09-01 06:52:02 +02:00
parent 81621b1fe4
commit 202b8e1954
2 changed files with 9 additions and 4 deletions

View File

@ -73,7 +73,7 @@ clang:msan:
.cmake:linux:
image: registry.gitlab.gnome.org/gnome/libxml2
script:
- cmake -DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS -DCMAKE_INSTALL_PREFIX=libxml2-install -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLIBXML2_XMLCONF_WORKING_DIR=/tests -S . -B libxml2-build
- cmake -DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS -DCMAKE_INSTALL_PREFIX=libxml2-install -DCMAKE_C_FLAGS='-Werror' -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLIBXML2_XMLCONF_WORKING_DIR=/tests -S . -B libxml2-build
- cmake --build libxml2-build --target install
- mkdir -p libxml2-install/share/libxml2
- cp Copyright libxml2-install/share/libxml2
@ -147,7 +147,7 @@ cmake:linux:clang:static:
.\7za.exe x xmlts20080827.tar.gz -olibxml2-build
}
script:
- cmake -G Ninja -DBUILD_SHARED_LIBS="$Env:BUILD_SHARED_LIBS" -DCMAKE_INSTALL_PREFIX=libxml2-install -DCMAKE_BUILD_TYPE=RelWithDebInfo -S . -B libxml2-build
- cmake -G Ninja -DBUILD_SHARED_LIBS="$Env:BUILD_SHARED_LIBS" -DCMAKE_INSTALL_PREFIX=libxml2-install -DCMAKE_C_FLAGS='-Werror' -DCMAKE_BUILD_TYPE=RelWithDebInfo -S . -B libxml2-build
- cmake --build libxml2-build --target install
- New-Item -ItemType Directory libxml2-install\share\libxml2
- Copy-Item Copyright libxml2-install\share\libxml2

View File

@ -359,8 +359,13 @@ if(NOT BUILD_SHARED_LIBS)
set(XML_CFLAGS "-DLIBXML_STATIC")
endif()
if(BUILD_SHARED_LIBS AND UNIX AND NOT APPLE)
if(CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID STREQUAL "GNU")
if(CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID STREQUAL "GNU")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -Wall -Wextra -Wshadow \
-Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return \
-Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline \
-Wredundant-decls -Wno-long-long -Wno-format-extra-args")
if(BUILD_SHARED_LIBS AND UNIX AND NOT APPLE)
target_link_options(LibXml2 PRIVATE "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libxml2.syms")
endif()
endif()