[CMAKE] Some options are only supported by GCC, don't use them for clang

These are (so far):
-Wno-format-overflow
-Wno-nonnull-compare
-Wno-old-style-declaration
-Wno-unused-but-set-variable
This commit is contained in:
Victor Perevertkin 2021-04-09 03:58:19 +03:00
parent 959729f6ee
commit 74ec94e12c
35 changed files with 99 additions and 57 deletions

View file

@ -24,10 +24,15 @@ list(APPEND SOURCE
add_executable(telnet ${SOURCE} telnet.rc)
target_link_libraries(telnet cppstl)
set_target_cpp_properties(telnet WITH_EXCEPTIONS)
if (NOT MSVC)
target_compile_options(telnet PRIVATE -Wno-restrict $<$<COMPILE_LANGUAGE:CXX>:-Wno-narrowing>)
target_compile_definitions(telnet PRIVATE _CRT_NONSTDC_NO_DEPRECATE)
endif()
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_compile_options(telnet PRIVATE -Wno-restrict $<$<COMPILE_LANGUAGE:CXX>:-Wno-narrowing>)
endif()
set_module_type(telnet win32cui)
add_importlibs(telnet ws2_32 user32 msvcrt kernel32 ntdll)
add_pch(telnet precomp.h SOURCE)

View file

@ -4,6 +4,6 @@ set_module_type(tftpd win32cui)
add_importlibs(tftpd advapi32 ws2_32 iphlpapi msvcrt kernel32)
add_cd_file(TARGET tftpd DESTINATION reactos/system32 FOR all)
if(GCC OR CLANG)
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_compile_options(tftpd PRIVATE -Wno-format-overflow)
endif()

View file

@ -67,6 +67,8 @@ if(MSVC)
remove_target_compile_option(libtiff "/we4311")
# error C4312: 'type cast': conversion from 'int' to 'thandle_t' of greater size
remove_target_compile_option(libtiff "/we4312")
else()
target_compile_options(libtiff PRIVATE "-Wno-unused-but-set-variable")
endif()
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_compile_options(libtiff PRIVATE -Wno-unused-but-set-variable)
endif()

View file

@ -53,6 +53,6 @@ add_importlibs(d3dwine user32 opengl32 gdi32 advapi32 msvcrt kernel32 ntdll)
add_pch(d3dwine precomp.h SOURCE)
add_cd_file(TARGET d3dwine DESTINATION reactos/system32 FOR all)
if(NOT MSVC)
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_compile_options(d3dwine PRIVATE -Wno-format-overflow)
endif()

View file

@ -121,14 +121,18 @@ target_link_libraries(glu32 cpprt)
set_module_type(glu32 win32dll)
if(NOT MSVC)
target_compile_options(glu32 PRIVATE -Wno-write-strings -Wno-unused-but-set-variable)
# Prevent a warning when comparing 'this' against 0
set_source_files_properties(src/libnurbs/internals/arc.cc PROPERTIES COMPILE_FLAGS "-Wno-nonnull-compare")
target_compile_options(glu32 PRIVATE -Wno-write-strings)
elseif(USE_CLANG_CL)
target_compile_options(glu32 PRIVATE -Wno-self-assign -Wno-unused-function -Wno-microsoft-include)
target_compile_options(glu32 PRIVATE -Wno-deprecated-register -Wno-tautological-undefined-compare)
endif()
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_compile_options(glu32 PRIVATE -Wno-unused-but-set-variable)
# Prevent a warning when comparing 'this' against 0
set_source_files_properties(src/libnurbs/internals/arc.cc PROPERTIES COMPILE_FLAGS "-Wno-nonnull-compare")
endif()
add_importlibs(glu32 opengl32 gdi32 msvcrt kernel32 ntdll)
add_pch(glu32 precomp.h "${PCH_SKIP_SOURCE}")
add_cd_file(TARGET glu32 DESTINATION reactos/system32 FOR all)

View file

@ -53,8 +53,11 @@ add_importlibs(browseui uxtheme shlwapi shell32 comctl32 gdi32 ole32 oleaut32 us
add_pch(browseui precomp.h "${PCH_SKIP_SOURCE}")
add_cd_file(TARGET browseui DESTINATION reactos/system32 FOR all)
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_compile_options(browseui PRIVATE -Wno-unused-but-set-variable)
endif()
if(NOT MSVC)
target_compile_options(browseui PRIVATE "-Wno-unused-but-set-variable")
# Binutils linker bug
if(LTCG)
add_target_link_flags(browseui "-Wl,--allow-multiple-definition")

View file

@ -14,8 +14,8 @@ list(APPEND SOURCE
add_library(shellbars OBJECT ${SOURCE})
target_link_libraries(shellbars PRIVATE atl_classes)
if(NOT MSVC)
target_compile_options(shellbars PRIVATE "-Wno-unused-but-set-variable")
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_compile_options(shellbars PRIVATE -Wno-unused-but-set-variable)
endif()
add_pch(shellbars shellbars.h SOURCE)

View file

@ -11,8 +11,8 @@ list(APPEND SOURCE
add_library(shellfind OBJECT ${SOURCE})
target_link_libraries(shellfind PRIVATE atl_classes)
if(NOT MSVC)
target_compile_options(shellfind PRIVATE "-Wno-unused-but-set-variable")
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_compile_options(shellfind PRIVATE -Wno-unused-but-set-variable)
endif()
add_pch(shellfind shellfind.h SOURCE)

View file

@ -33,8 +33,8 @@ add_importlibs(winmm advapi32 user32 msvcrt kernel32 ntdll)
add_pch(winmm winemm.h SOURCE)
add_cd_file(TARGET winmm DESTINATION reactos/system32 FOR all)
if(NOT MSVC)
target_compile_options(winmm PRIVATE "-Wno-unused-but-set-variable")
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_compile_options(winmm PRIVATE -Wno-unused-but-set-variable)
endif()
add_subdirectory(midimap)

View file

@ -12,8 +12,8 @@ list(APPEND SOURCE
add_library(fbtusb MODULE ${SOURCE} fbtusb.rc)
if(NOT MSVC)
target_compile_options(fbtusb PRIVATE "-Wno-unused-but-set-variable")
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_compile_options(fbtusb PRIVATE -Wno-unused-but-set-variable)
endif()
set_module_type(fbtusb kernelmodedriver)

View file

@ -103,9 +103,10 @@ else()
target_compile_options(ext2fs PRIVATE
-Wno-pointer-sign -Wno-unused-function
-Wno-unused-variable -Wno-missing-braces)
if (NOT CLANG)
target_compile_options(ext2fs PRIVATE -Wno-unused-but-set-variable)
endif()
endif()
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_compile_options(ext2fs PRIVATE -Wno-unused-but-set-variable)
endif()
if(CLANG)

View file

@ -35,11 +35,13 @@ if(USE_CLANG_CL OR (NOT MSVC))
target_compile_options(ffs PRIVATE -Wno-unused-variable -Wno-missing-braces)
if(USE_CLANG_CL)
target_compile_options(ffs PRIVATE -Wno-empty-body)
else()
target_compile_options(ffs PRIVATE -Wno-unused-but-set-variable)
endif()
endif()
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_compile_options(ffs PRIVATE -Wno-unused-but-set-variable)
endif()
add_definitions(-D__KERNEL__)
set_module_type(ffs kernelmodedriver)
target_link_libraries(ffs memcmp ${PSEH_LIB})

View file

@ -82,7 +82,6 @@ if(USE_CLANG_CL OR (NOT MSVC))
target_compile_options(reiserfs PRIVATE -Wno-missing-braces -Wno-pointer-sign)
target_compile_options(reiserfs PRIVATE -Wno-unused-function -Wno-unused-variable)
if(NOT USE_CLANG_CL)
target_compile_options(reiserfs PRIVATE -Wno-unused-but-set-variable)
target_compile_definitions(reiserfs PRIVATE __GCC__)
endif()
else()
@ -92,6 +91,10 @@ else()
target_compile_options(reiserfs PRIVATE /wd4189 /wd4142 /wd4101)
endif()
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_compile_options(reiserfs PRIVATE -Wno-unused-but-set-variable)
endif()
target_link_libraries(reiserfs memcmp ${PSEH_LIB})
add_definitions(-D__KERNEL__ -D_CRT_NO_POSIX_ERROR_CODES)
set_module_type(reiserfs kernelmodedriver)

View file

@ -50,8 +50,10 @@ if(MSVC)
target_compile_options(udfs PRIVATE -Wno-tautological-unsigned-zero-compare -Wno-self-assign)
target_compile_options(udfs PRIVATE -Wno-sometimes-uninitialized -Wno-parentheses-equality)
endif()
else()
target_compile_options(udfs PRIVATE "-Wno-unused-but-set-variable")
endif()
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_compile_options(udfs PRIVATE -Wno-unused-but-set-variable)
endif()
set_module_type(udfs kernelmodedriver)

View file

@ -29,11 +29,13 @@ add_driver_inf(netkvm netkvm.inf)
if(NOT MSVC)
target_compile_options(netkvm PRIVATE
-Wno-unused-function
-Wno-old-style-declaration
-Wno-unknown-pragmas
-Wno-unused-but-set-variable
-Wno-pointer-sign
-Wno-pointer-to-int-cast
-Wno-int-to-pointer-cast
-Wno-attributes)
endif()
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_compile_options(netkvm PRIVATE -Wno-old-style-declaration -Wno-unused-but-set-variable)
endif()

View file

@ -42,7 +42,11 @@ target_compile_definitions(classpnp PRIVATE
CLASS_GLOBAL_BUFFERED_DEBUG_PRINT_BUFFERS=512)
if(GCC)
target_compile_options(classpnp PRIVATE -Wno-unused-but-set-variable -Wno-pointer-to-int-cast -Wno-switch)
target_compile_options(classpnp PRIVATE -Wno-pointer-to-int-cast -Wno-switch)
endif()
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_compile_options(classpnp PRIVATE -Wno-unused-but-set-variable)
endif()
set_module_type(classpnp kernelmodedriver)

View file

@ -21,7 +21,11 @@ if(USE_CLANG_CL OR (NOT MSVC))
endif()
if(GCC)
target_compile_options(disk PRIVATE -Wno-unused-but-set-variable -Wno-pointer-to-int-cast -Wno-switch)
target_compile_options(disk PRIVATE -Wno-pointer-to-int-cast -Wno-switch)
endif()
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_compile_options(disk PRIVATE -Wno-unused-but-set-variable)
endif()
set_module_type(disk kernelmodedriver)

View file

@ -25,11 +25,13 @@ if(USE_CLANG_CL OR (NOT MSVC))
target_compile_options(uniata PRIVATE "-Wno-narrowing")
if(USE_CLANG_CL)
target_compile_options(uniata PRIVATE "-Wno-unused-const-variable")
else()
target_compile_options(uniata PRIVATE "-Wno-unused-but-set-variable")
endif()
endif()
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_compile_options(uniata PRIVATE -Wno-unused-but-set-variable)
endif()
add_pch(uniata stdafx.h SOURCE)
set_module_type(uniata kernelmodedriver)
add_importlibs(uniata scsiport ntoskrnl hal)

View file

@ -4,7 +4,7 @@ add_executable(symdump symdump.c)
set_module_type(symdump win32cui)
target_link_libraries(symdump wine)
add_importlibs(symdump dbghelp shlwapi msvcrt kernel32 ntdll)
if(NOT MSVC)
target_compile_options(symdump PRIVATE "-Wno-unused-but-set-variable")
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_compile_options(symdump PRIVATE -Wno-unused-but-set-variable)
endif()
add_cd_file(TARGET symdump DESTINATION reactos/system32 FOR all)

View file

@ -71,7 +71,7 @@ list(APPEND SOURCE
add_executable(ncftp ${SOURCE} ncftp.rc)
set_module_type(ncftp win32cui)
target_compile_definitions(ncftp PRIVATE HAVE_UTIME_H HAVE_UNISTD_H)
if(NOT MSVC)
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_compile_options(ncftp PRIVATE -Wno-unused-but-set-variable)
endif()
add_importlibs(ncftp advapi32 user32 ws2_32 msvcrt kernel32)

View file

@ -1,8 +1,8 @@
add_executable(logevent logevent.c logevent.rc)
set_module_type(logevent win32cui)
if(NOT MSVC)
target_compile_options(logevent PRIVATE "-Wno-unused-but-set-variable")
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_compile_options(logevent PRIVATE -Wno-unused-but-set-variable)
endif()
add_importlibs(logevent advapi32 msvcrt kernel32)
add_cd_file(TARGET logevent DESTINATION reactos/system32 FOR all)

View file

@ -1,8 +1,8 @@
add_executable(pedump pedump.c pedump.rc)
set_module_type(pedump win32cui)
if(NOT MSVC)
target_compile_options(pedump PRIVATE "-Wno-unused-but-set-variable")
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_compile_options(pedump PRIVATE -Wno-unused-but-set-variable)
endif()
add_importlibs(pedump msvcrt kernel32 ntdll)
add_cd_file(TARGET pedump DESTINATION reactos/system32 FOR all)

View file

@ -11,8 +11,8 @@ list(APPEND SOURCE
add_executable(rosperf ${SOURCE} rosperf.rc)
set_module_type(rosperf win32cui UNICODE)
if(NOT MSVC)
target_compile_options(rosperf PRIVATE "-Wno-unused-but-set-variable")
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_compile_options(rosperf PRIVATE -Wno-unused-but-set-variable)
endif()
add_importlibs(rosperf version msimg32 gdi32 shell32 advapi32 user32 ntdll msvcrt kernel32)
add_cd_file(TARGET rosperf DESTINATION reactos/system32 FOR all)

View file

@ -9,8 +9,8 @@ list(APPEND SOURCE
add_executable(template_dialog ${SOURCE} dialog.rc)
set_module_type(template_dialog win32cui)
if(NOT MSVC)
target_compile_options(template_dialog PRIVATE "-Wno-unused-but-set-variable")
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_compile_options(template_dialog PRIVATE -Wno-unused-but-set-variable)
endif()
add_importlibs(template_dialog user32 gdi32 comctl32 msvcrt kernel32 ntdll)
add_cd_file(TARGET template_dialog DESTINATION reactos/system32 FOR all)

View file

@ -9,7 +9,7 @@ add_executable(advpack_winetest ${SOURCE})
target_compile_definitions(advpack_winetest PRIVATE USE_WINE_TODOS)
if (NOT MSVC)
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_compile_options(advpack_winetest PRIVATE -Wno-format-overflow)
endif()

View file

@ -10,7 +10,7 @@ add_executable(fusion_winetest ${SOURCE})
target_compile_definitions(fusion_winetest PRIVATE USE_WINE_TODOS)
if (NOT MSVC)
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_compile_options(fusion_winetest PRIVATE -Wno-format-overflow)
endif()

View file

@ -32,7 +32,7 @@ add_executable(msi_winetest
target_compile_definitions(msi_winetest PRIVATE __WINESRC__ USE_WINE_TODOS)
if (NOT MSVC)
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_compile_options(msi_winetest PRIVATE -Wno-format-overflow)
endif()

View file

@ -30,7 +30,9 @@ add_importlibs(ole32_winetest oleaut32 ole32 user32 gdi32 advapi32 msvcrt kernel
if(MSVC)
add_importlibs(ole32_winetest ntdll)
else()
endif()
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_compile_options(ole32_winetest PRIVATE -Wno-format-overflow)
endif()

View file

@ -4,6 +4,6 @@ set_module_type(services_winetest win32cui)
add_importlibs(services_winetest user32 advapi32 msvcrt kernel32)
add_rostests_file(TARGET services_winetest)
if (NOT MSVC)
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_compile_options(services_winetest PRIVATE -Wno-format-overflow)
endif()

View file

@ -17,6 +17,6 @@ target_link_libraries(setupapi_winetest uuid)
add_importlibs(setupapi_winetest advapi32 setupapi user32 shell32 msvcrt kernel32 ntdll)
add_rostests_file(TARGET setupapi_winetest)
if (NOT MSVC)
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_compile_options(setupapi_winetest PRIVATE -Wno-format-overflow)
endif()

View file

@ -38,7 +38,9 @@ add_importlibs(shell32_winetest shell32 shlwapi ole32 oleaut32 user32 gdi32 adva
if(MSVC)
add_importlibs(shell32_winetest ntdll)
else()
endif()
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_compile_options(shell32_winetest PRIVATE -Wno-format-overflow)
endif()

View file

@ -40,7 +40,9 @@ add_executable(user32_winetest
if(MSVC)
# Disable warning C4477 (printf format warnings)
remove_target_compile_option(user32_winetest "/we4477")
elseif(GCC)
endif()
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_compile_options(user32_winetest PRIVATE -Wno-format-overflow)
endif()

View file

@ -10,10 +10,12 @@ add_importlibs(version_winetest shell32 version msvcrt kernel32)
target_compile_definitions(version_winetest PRIVATE USE_WINE_TODOS)
if (NOT MSVC)
target_compile_options(version_winetest PRIVATE -Wno-format-overflow)
else()
if(MSVC)
add_importlibs(version_winetest ntdll)
endif()
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_compile_options(version_winetest PRIVATE -Wno-format-overflow)
endif()
add_rostests_file(TARGET version_winetest)

View file

@ -24,8 +24,8 @@ list(APPEND SOURCE
add_library(adns ${SOURCE})
if(NOT MSVC)
target_compile_options(adns PRIVATE "-Wno-unused-but-set-variable")
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_compile_options(adns PRIVATE -Wno-unused-but-set-variable)
endif()
add_dependencies(adns psdk)

View file

@ -18,8 +18,8 @@ add_library(cardlib STATIC ${SOURCE})
target_link_libraries(cardlib PRIVATE cpprt)
target_include_directories(cardlib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
if(NOT MSVC)
target_compile_options(cardlib PRIVATE "-Wno-unused-but-set-variable")
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_compile_options(cardlib PRIVATE -Wno-unused-but-set-variable)
endif()
add_dependencies(cardlib psdk)