Am 29.10.25 um 19:09 schrieb Georg Baum:

What is the purpose of handle_warning_options? If the goal is to ignore all warnings from thirdparty-code then we should use the SYSTEM keyword for those include directories (see https://cmake.org/cmake/help/latest/ command/ target_include_directories.html#command:target_include_directories or https://cmake.org/cmake/help/latest/command/include_directories.html) rather than compiler-specific ignore lists IMHO. This works also with MSVC, not just gcc or clang (at least since a few years: https:// gitlab.kitware.com/cmake/cmake/-/issues/17904)

This would look like the attached. I also used the more specific target_* commands (to slightly modernize the CMake code). The new syntax is already supported by CMake 3.10, so no need to bump cmake_minimum_required.

Opinions?


Georg
diff --git a/3rdparty/hunspell/CMakeLists.txt b/3rdparty/hunspell/CMakeLists.txt
index 56a0c6e2bf..cda7ccf854 100644
--- a/3rdparty/hunspell/CMakeLists.txt
+++ b/3rdparty/hunspell/CMakeLists.txt
@@ -11,14 +11,10 @@ endif()
 
 project(hunspell)
 
-handle_warning_options("hunspell" "CXX" -Wno-suggest-final-types -Wno-suggest-final-methods -Wno-unused-but-set-variable -Wno-deprecated-declarations -Wno-format-nonliteral -Wno-unused-macros -Wno-sign-compare -Wno-unused-parameter)
-
 set(HUNSPELL_VERSION 1.7.2)
 
 set(SRCDIR ${CMAKE_CURRENT_SOURCE_DIR}/${HUNSPELL_VERSION}/src)
 
-include_directories(./ ${SRCDIR}/hunspell)
-
 # LIBS
 set(SRCS
     ${SRCDIR}/hunspell/affentry.cxx
@@ -32,10 +28,6 @@ set(SRCS
     ${SRCDIR}/hunspell/hunspell.cxx
     ${SRCDIR}/hunspell/replist.cxx)
 
-handle_source_option("CC" ${SRCDIR}/hunspell/affixmgr.cxx -Wno-shadow)
-foreach(_base affixmgr suggestmgr)
-  handle_source_option("CC" ${SRCDIR}/hunspell/${_base}.cxx -Wno-null-dereference)
-endforeach()
 set(HEADERS
     ${SRCDIR}/hunspell/affentry.hxx
     ${SRCDIR}/hunspell/htypes.hxx
@@ -55,8 +47,10 @@ set(HEADERS
     ${SRCDIR}/hunspell/replist.hxx
     ${SRCDIR}/hunspell/hunvisapi.h)
 
-add_definitions(-DHUNSPELL_STATIC)
 add_library(hunspell STATIC ${HEADERS} ${SRCS} ${HUNCONFIG})
+target_compile_definitions(hunspell PRIVATE -DHUNSPELL_STATIC)
+# SYSTEM because we are not interested in any warning of this thirdparty library
+target_include_directories(hunspell SYSTEM PRIVATE ./ ${SRCDIR}/hunspell)
 
 set(HUNSPELL_LIBRARY hunspell CACHE STRING "Hunspell library" FORCE)
 set(HUNSPELL_INCLUDE_DIR "${SRCDIR}/hunspell;${SRCDIR}" CACHE STRING "Hunspell include dirs" FORCE)
diff --git a/3rdparty/libiconv/CMakeLists.txt b/3rdparty/libiconv/CMakeLists.txt
index 4a16ff9744..d841e07336 100644
--- a/3rdparty/libiconv/CMakeLists.txt
+++ b/3rdparty/libiconv/CMakeLists.txt
@@ -25,8 +25,6 @@ set(LIBICONV_VERSION 1.18)
 
 set(SRCDIR ${LIBICONV_VERSION})
 
-handle_warning_options("libiconv" "CC" -Werror -Wdeprecated-non-prototype -Wstrict-prototypes -Wstatic-in-inline -Wparentheses-equality -Wundef -Wno-reserved-macro-identifier -Wno-unused-parameter -Wno-sign-compare -Wno-type-limits -Wno-implicit-fallthrough -Wno-cast-align -Wno-parentheses-equality)
-
 # Options
 option(ENABLE_EXTRA "Enable a few rarely used encodings" OFF)
 option(ENABLE_NLS "Translation of program messages to the user's native
@@ -52,14 +50,6 @@ configure_file(${SRCDIR}/srclib/uniwidth.in.h ${BINDIR}/srclib/uniwidth.h)
 configure_file(${SRCDIR}/srclib/unitypes.in.h ${BINDIR}/srclib/unitypes.h)
 configure_file(${SRCDIR}/include/iconv.h.in ${BINDIR}/include/iconv.h)
 
-# Dirty fix for MinGW
-if(MINGW)
-  add_definitions(-DELOOP=0 -DHAVE_DECL_STRERROR_R=0)
-endif ()
-
-include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR} ${BINDIR}/include ${SRCDIR}/include ${SRCDIR}/srclib)
-add_definitions(-Dset_relocation_prefix=libcharset_set_relocation_prefix -Drelocate=libcharset_relocate -DHAVE_CONFIG_H -DINSTALLPREFIX=NULL -DNO_XMALLOC -DBUILDING_LIBCHARSET -DINSTALLDIR="" -DLIBDIR="" -DENABLE_RELOCATABLE=1 -DIN_LIBRARY)
-
 # libcharset
 set(SRC_LIBCHARSET ${SRCDIR}/libcharset/lib/localcharset.c)
 
@@ -67,20 +57,20 @@ set(SRC_LIBCHARSET ${SRCDIR}/libcharset/lib/localcharset.c)
 set(SRC_LIBICONV ${SRCDIR}/lib/compat.c ${SRCDIR}/lib/genaliases2.c ${SRCDIR}/lib/genaliases.c ${SRCDIR}/lib/genflags.c ${SRCDIR}/lib/gentranslit.c ${SRCDIR}/lib/iconv.c)
 
 add_library(iconv ${SRC_LIBICONV} ${SRC_LIBCHARSET})
-set_target_properties(iconv PROPERTIES COMPILE_FLAGS -DBUILDING_LIBICONV)
+
+# Dirty fix for MinGW
+if(MINGW)
+  target_compile_definitions(iconv PRIVATE -DELOOP=0 -DHAVE_DECL_STRERROR_R=0)
+endif ()
+
+# SYSTEM because we are not interested in any warning of this thirdparty library
+target_include_directories(iconv SYSTEM BEFORE PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${BINDIR}/include ${SRCDIR}/include ${SRCDIR}/srclib)
+target_compile_definitions(iconv PRIVATE -DBUILDING_LIBICONV -Dset_relocation_prefix=libcharset_set_relocation_prefix -Drelocate=libcharset_relocate -DHAVE_CONFIG_H -DINSTALLPREFIX=NULL -DNO_XMALLOC -DBUILDING_LIBCHARSET -DINSTALLDIR="" -DLIBDIR="" -DENABLE_RELOCATABLE=1 -DIN_LIBRARY)
 
 set(ICONV_INCLUDE_DIR ${BINDIR}/include CACHE STRING "libiconv include  dir" FORCE)
 set(ICONV_LIBRARY iconv CACHE STRING "libiconv library" FORCE)
 set(ICONV_FOUND iconv CACHE STRING "libiconv found" FORCE)
 
-foreach(_base iconv genaliases2 genaliases genflags)
-  handle_source_option("CC" ${SRCDIR}/lib/${_base}.c -Wno-unused-macros)
-endforeach()
-
-handle_source_option("CC" ${SRCDIR}/lib/iconv.c -Wno-cast-align -Wno-parentheses-equality -Wno-static-in-inline -Wno-unused-parameter -Wno-sign-compare -Wno-type-limits -Wno-missing-field-initializers -Wno-redundant-decls -Wno-implicit-fallthrough -Wno-strict-prototypes)
-handle_source_option("CC" ${SRCDIR}/lib/genaliases2.c -Wno-unused-but-set-variable -Wno-unused-function)
-handle_source_option("CC" ${SRCDIR}/lib/genflags.c -Wno-pedantic)
-handle_source_option("CC" ${SRCDIR}/lib/gentranslit.c -Wno-format)
 set_target_properties(iconv PROPERTIES
 	FOLDER "3rd_party"
 	INTERPROCEDURAL_OPTIMIZATION ${LYX_IPO_SUPPORTED})
diff --git a/3rdparty/mythes/CMakeLists.txt b/3rdparty/mythes/CMakeLists.txt
index 581da20c9b..a7d94d5919 100644
--- a/3rdparty/mythes/CMakeLists.txt
+++ b/3rdparty/mythes/CMakeLists.txt
@@ -12,20 +12,16 @@ endif()
 set(VERSION "1.2.5")
 set(SRCDIR ${CMAKE_CURRENT_SOURCE_DIR}/${VERSION})
 
-handle_warning_options("mythes" "CXX" -Wno-stringop-truncation -Wno-reserved-macro-identifier)
-if (${LYX_DEBUG_SANITIZE} MATCHES UNSPECIFIED)
-  handle_source_option("CXX" ${SRCDIR}/mythes.cxx -Wno-nonnull)
-endif()
 file(GLOB support_mythes_sources ${SRCDIR}/*.cxx)
 file(GLOB support_mythes_headers ${SRCDIR}/*.hxx)
 
-include_directories(${VERSION})
-
 #============================================================================
 # lyxmytheslib
 #============================================================================
 
 add_library(mytheslibstatic STATIC ${support_mythes_sources} ${support_mythes_headers} )
+# SYSTEM because we are not interested in any warning of this thirdparty library
+target_include_directories(mytheslibstatic SYSTEM PRIVATE ${VERSION})
 
 
 set(MYTHESLIB_LIBRARY mytheslibstatic CACHE STRING "Mytheslib library" FORCE)
diff --git a/3rdparty/zlib/CMakeLists.txt b/3rdparty/zlib/CMakeLists.txt
index 6948dbcf74..15f623e51a 100644
--- a/3rdparty/zlib/CMakeLists.txt
+++ b/3rdparty/zlib/CMakeLists.txt
@@ -16,8 +16,6 @@ project(zlib C)
 set(VERSION "1.3.1")
 set(SRCDIR ${CMAKE_CURRENT_SOURCE_DIR}/${VERSION})
 
-handle_warning_options("zlib" "CC" -Wno-deprecated-non-prototype -Wno-strict-prototypes -Wnested-anon-types -Wno-implicit-fallthrough -Wno-format-nonliteral -Wno-reserved-macro-identifier -Wno-cast-align)
-
 include(CheckTypeSize)
 include(CheckFunctionExists)
 include(CheckIncludeFile)
@@ -125,7 +123,8 @@ set(ZLIB_SRCS
 )
 
 add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
-target_include_directories(zlibstatic PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${SRCDIR})
+# SYSTEM because we are not interested in any warning of this thirdparty library
+target_include_directories(zlibstatic PUBLIC SYSTEM ${CMAKE_CURRENT_BINARY_DIR} ${SRCDIR})
 
 set(ZLIB_LIBRARY zlibstatic CACHE STRING "Zlib library" FORCE)
 set(ZLIB_INCLUDE_DIR  ${SRCDIR} CACHE STRING "Zlib include dir" FORCE)
-- 
lyx-devel mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-devel

Reply via email to