From: Victor Perevertkin Date: Wed, 25 May 2022 22:37:23 +0000 (+0300) Subject: [CMAKE] Elimitate the use of GCC and CLANG variables X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=f155b9377f4e8b32d93787a27924e0860e57dbf8 [CMAKE] Elimitate the use of GCC and CLANG variables --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 2168dcb2422..40adc041d20 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -76,8 +76,7 @@ add_definitions( # There doesn't seem to be a standard for __FILE__ being relative or absolute, so detect it at runtime. file(RELATIVE_PATH _PATH_PREFIX ${REACTOS_BINARY_DIR} ${REACTOS_SOURCE_DIR}) -if (GCC AND ((CMAKE_C_COMPILER_ID STREQUAL "GNU") AND (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "8.0.0") - OR ((CMAKE_C_COMPILER_ID STREQUAL "Clang") AND (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "10.0.0")))) +if (NOT MSVC AND (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")) # Thankfully, GCC has this add_compile_options(-ffile-prefix-map=${REACTOS_SOURCE_DIR}=) add_compile_options(-ffile-prefix-map=${_PATH_PREFIX}=) @@ -229,7 +228,7 @@ Enable this if the module uses typeid or dynamic_cast. You will probably need to message(WARNING "-- Disabling precompiled headers support (ccache).") option(PCH "Whether to use precompiled headers" OFF) set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) - elseif(GCC) + elseif(CMAKE_C_COMPILER_ID STREQUAL "GNU") message(WARNING "-- Disabling precompiled headers on GCC by default CORE-17108.") option(PCH "Whether to use precompiled headers" OFF) else() diff --git a/base/services/nfsd/CMakeLists.txt b/base/services/nfsd/CMakeLists.txt index 6a96dd66c80..9d079e00c46 100644 --- a/base/services/nfsd/CMakeLists.txt +++ b/base/services/nfsd/CMakeLists.txt @@ -48,7 +48,7 @@ list(APPEND SOURCE add_executable(nfsd ${SOURCE} nfsd.rc) -if(MSVC AND (NOT USE_CLANG_CL)) +if(CMAKE_C_COMPILER_ID STREQUAL "MSVC") # Disable warning C4477 (printf format warnings) target_compile_options(nfsd PRIVATE /wd4477) else() diff --git a/boot/rtl/blrtl.cmake b/boot/rtl/blrtl.cmake index 692727892b0..7f65e76343b 100644 --- a/boot/rtl/blrtl.cmake +++ b/boot/rtl/blrtl.cmake @@ -7,7 +7,7 @@ add_definitions( set(NTOS_RTL_SOURCE_DIR "${REACTOS_SOURCE_DIR}/sdk/lib/rtl") include_directories(${NTOS_RTL_SOURCE_DIR}) -if (GCC) +if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang") # Enable this again. CORE-17637 add_compile_options(-Wunused-result) endif() diff --git a/dll/3rdparty/libxslt/CMakeLists.txt b/dll/3rdparty/libxslt/CMakeLists.txt index 5a4910b6f3d..86af9b2003e 100644 --- a/dll/3rdparty/libxslt/CMakeLists.txt +++ b/dll/3rdparty/libxslt/CMakeLists.txt @@ -43,7 +43,7 @@ if(MSVC) add_importlibs(libxslt ntdll) endif() -if(GCC OR CLANG) +if(NOT MSVC) target_compile_options(libxslt PRIVATE -Wno-misleading-indentation -Wno-pointer-sign -Wno-unused-function) endif() diff --git a/dll/3rdparty/mbedtls/CMakeLists.txt b/dll/3rdparty/mbedtls/CMakeLists.txt index e43e1e8b732..a3cc7ab97a8 100644 --- a/dll/3rdparty/mbedtls/CMakeLists.txt +++ b/dll/3rdparty/mbedtls/CMakeLists.txt @@ -102,6 +102,8 @@ add_cd_file(TARGET mbedtls DESTINATION reactos/system32 FOR all) if(NOT MSVC) target_compile_options(mbedtls PRIVATE -Wno-pointer-sign -Wno-unused-function) -elseif(USE_CLANG_CL) +endif() + +if(CMAKE_C_COMPILER_ID STREQUAL "Clang") target_compile_options(mbedtls PRIVATE -Wno-tautological-constant-compare) endif() diff --git a/dll/opengl/glu32/CMakeLists.txt b/dll/opengl/glu32/CMakeLists.txt index ffa8a540818..76ace8871bf 100644 --- a/dll/opengl/glu32/CMakeLists.txt +++ b/dll/opengl/glu32/CMakeLists.txt @@ -120,19 +120,19 @@ target_link_libraries(glu32 cpprt) set_module_type(glu32 win32dll) -if(NOT MSVC) - 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-write-strings) 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() +if(CMAKE_C_COMPILER_ID STREQUAL "Clang") + target_compile_options(glu32 PRIVATE -Wno-write-strings) + 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() + 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) diff --git a/drivers/filesystems/ext2/CMakeLists.txt b/drivers/filesystems/ext2/CMakeLists.txt index e07135b419d..4a79c51e139 100644 --- a/drivers/filesystems/ext2/CMakeLists.txt +++ b/drivers/filesystems/ext2/CMakeLists.txt @@ -88,26 +88,21 @@ list(APPEND SOURCE add_library(ext2fs MODULE ${SOURCE} ext2fs.rc) -if(MSVC) - if (NOT CLANG) - # Disable warning C4101: 'i': unreferenced local variable - # Disable warning C4189: 'sbi': local variable is initialized but not referenced - # Disable warning C4267: '=': conversion from 'size_t' to 'USHORT', possible loss of data - target_compile_options(ext2fs PRIVATE /wd4101 /wd4189 /wd4267) - endif() -else() - target_compile_options(ext2fs PRIVATE - -Wno-pointer-sign -Wno-unused-function - -Wno-unused-variable -Wno-missing-braces) +if(CMAKE_C_COMPILER_ID STREQUAL "MSVC") + # Disable warning C4101: 'i': unreferenced local variable + # Disable warning C4189: 'sbi': local variable is initialized but not referenced + # Disable warning C4267: '=': conversion from 'size_t' to 'USHORT', possible loss of data + target_compile_options(ext2fs PRIVATE /wd4101 /wd4189 /wd4267) endif() -if(CMAKE_C_COMPILER_ID STREQUAL "GNU") - target_compile_options(ext2fs PRIVATE -Wno-unused-but-set-variable) +if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang") + target_compile_options(ext2fs PRIVATE + -Wno-pointer-sign -Wno-unused-function -Wno-unused-variable -Wno-missing-braces -Wno-unused-but-set-variable) endif() -if(CLANG) +if(CMAKE_C_COMPILER_ID STREQUAL "Clang") target_compile_options(ext2fs PRIVATE - -Wno-unused-value -Wno-parentheses-equality + -Wno-parentheses-equality -Wno-incompatible-pointer-types-discards-qualifiers "-Wno-#pragma-messages;-Wno-cast-calling-convention") endif() diff --git a/drivers/filesystems/fastfat_new/CMakeLists.txt b/drivers/filesystems/fastfat_new/CMakeLists.txt index c425ff0ad3e..d00e6eca900 100644 --- a/drivers/filesystems/fastfat_new/CMakeLists.txt +++ b/drivers/filesystems/fastfat_new/CMakeLists.txt @@ -38,7 +38,7 @@ list(APPEND SOURCE add_library(fastfat MODULE ${SOURCE} fastfat.rc) set_module_type(fastfat kernelmodedriver) target_link_libraries(fastfat ${PSEH_LIB} memcmp) -if(GDB AND NOT CLANG) +if(GDB AND NOT CMAKE_C_COMPILER_ID STREQUAL "Clang") target_compile_options(fastfat PRIVATE -O0) endif() add_importlibs(fastfat ntoskrnl hal) diff --git a/drivers/filesystems/nfs/CMakeLists.txt b/drivers/filesystems/nfs/CMakeLists.txt index 10b71000757..9eb45900649 100644 --- a/drivers/filesystems/nfs/CMakeLists.txt +++ b/drivers/filesystems/nfs/CMakeLists.txt @@ -14,12 +14,14 @@ set_module_type(nfs41_driver kernelmodedriver) target_link_libraries(nfs41_driver ntoskrnl_vista rdbsslib rxce copysup memcmp ${PSEH_LIB}) add_importlibs(nfs41_driver ntoskrnl hal) -if(GCC OR CLANG) +if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang") target_compile_options(nfs41_driver PRIVATE "-Wno-switch") - if(CLANG) - target_compile_options(nfs41_driver PRIVATE "-Wno-unused-value") - endif() endif() + +if(CMAKE_C_COMPILER_ID STREQUAL "Clang") + target_compile_options(nfs41_driver PRIVATE "-Wno-unused-value") +endif() + set_property(TARGET nfs41_driver PROPERTY C_STANDARD 90) add_cd_file(TARGET nfs41_driver DESTINATION reactos/system32/drivers FOR all) diff --git a/drivers/filesystems/udfs/CMakeLists.txt b/drivers/filesystems/udfs/CMakeLists.txt index 1c4a396b879..b1bfdd9db84 100644 --- a/drivers/filesystems/udfs/CMakeLists.txt +++ b/drivers/filesystems/udfs/CMakeLists.txt @@ -41,19 +41,17 @@ list(APPEND SOURCE add_library(udfs MODULE ${SOURCE} udffs.rc) -if(MSVC) - if(USE_CLANG_CL) - target_compile_options(udfs PRIVATE -Wno-extern-c-compat -Wno-unused-value) - target_compile_options(udfs PRIVATE -Wno-tautological-constant-out-of-range-compare) - 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() -endif() - if(CMAKE_C_COMPILER_ID STREQUAL "GNU") target_compile_options(udfs PRIVATE -Wno-unused-but-set-variable) endif() +if(CMAKE_C_COMPILER_ID STREQUAL "Clang") + target_compile_options(udfs PRIVATE -Wno-extern-c-compat -Wno-unused-value) + target_compile_options(udfs PRIVATE -Wno-tautological-constant-out-of-range-compare) + 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() + set_module_type(udfs kernelmodedriver) target_link_libraries(udfs ${PSEH_LIB}) add_importlibs(udfs ntoskrnl hal) diff --git a/drivers/storage/class/cdrom/CMakeLists.txt b/drivers/storage/class/cdrom/CMakeLists.txt index d4bd2dd924c..fc04713730b 100644 --- a/drivers/storage/class/cdrom/CMakeLists.txt +++ b/drivers/storage/class/cdrom/CMakeLists.txt @@ -20,15 +20,12 @@ list(APPEND SOURCE add_library(cdrom MODULE ${SOURCE} cdrom.rc) set_module_type(cdrom kernelmodedriver) -if(GCC OR CLANG) +if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang") target_compile_options(cdrom PRIVATE -Wno-format -Wno-unused-variable -Wno-pointer-sign) -endif() - -if(GCC) target_compile_options(cdrom PRIVATE -Wno-unknown-pragmas -Wno-incompatible-pointer-types -Wno-switch) endif() -if(CLANG) +if(CMAKE_C_COMPILER_ID STREQUAL "Clang") target_compile_options(cdrom PRIVATE -Wno-enum-conversion -Wno-tautological-constant-compare) endif() diff --git a/drivers/storage/class/classpnp/CMakeLists.txt b/drivers/storage/class/classpnp/CMakeLists.txt index a1cee352784..fadc6ff48c7 100644 --- a/drivers/storage/class/classpnp/CMakeLists.txt +++ b/drivers/storage/class/classpnp/CMakeLists.txt @@ -41,7 +41,7 @@ target_compile_definitions(classpnp PRIVATE CLASS_GLOBAL_BUFFERED_DEBUG_PRINT_BUFFER_SIZE=512 CLASS_GLOBAL_BUFFERED_DEBUG_PRINT_BUFFERS=512) -if(GCC) +if(NOT MSVC) target_compile_options(classpnp PRIVATE -Wno-pointer-to-int-cast -Wno-switch) endif() diff --git a/drivers/storage/class/disk/CMakeLists.txt b/drivers/storage/class/disk/CMakeLists.txt index 68407eafe56..5250b8cdec3 100644 --- a/drivers/storage/class/disk/CMakeLists.txt +++ b/drivers/storage/class/disk/CMakeLists.txt @@ -16,11 +16,8 @@ target_compile_definitions(disk PUBLIC _WIN32_WINNT=0x602 NTDDI_VERSION=0x06020000) # NTDDI_WIN8 -if(USE_CLANG_CL OR (NOT MSVC)) +if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang") target_compile_options(disk PRIVATE -Wno-format -Wno-pointer-sign) -endif() - -if(GCC) target_compile_options(disk PRIVATE -Wno-pointer-to-int-cast -Wno-switch) endif() diff --git a/drivers/storage/ide/uniata/CMakeLists.txt b/drivers/storage/ide/uniata/CMakeLists.txt index 6b9cdcff5e9..4a78222a28b 100644 --- a/drivers/storage/ide/uniata/CMakeLists.txt +++ b/drivers/storage/ide/uniata/CMakeLists.txt @@ -21,21 +21,18 @@ list(APPEND SOURCE add_library(uniata MODULE ${SOURCE} idedma.rc) -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") - endif() -endif() - if(MSVC) # Disable warning C4267: '=': conversion from 'size_t' to 'USHORT', possible loss of data # Disable warning C4838: conversion from 'int' to 'ULONG' requires a narrowing conversion target_compile_options(uniata PRIVATE /wd4267 /wd4838) endif() -if(CMAKE_C_COMPILER_ID STREQUAL "GNU") - target_compile_options(uniata PRIVATE -Wno-unused-but-set-variable) +if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang") + target_compile_options(uniata PRIVATE -Wno-narrowing -Wno-unused-but-set-variable) +endif() + +if(CMAKE_C_COMPILER_ID STREQUAL "Clang") + target_compile_options(uniata PRIVATE -Wno-unused-const-variable) endif() add_pch(uniata stdafx.h SOURCE) diff --git a/drivers/wdm/audio/drivers/CMIDriver/CMakeLists.txt b/drivers/wdm/audio/drivers/CMIDriver/CMakeLists.txt index eda3493b308..609babac1f4 100644 --- a/drivers/wdm/audio/drivers/CMIDriver/CMakeLists.txt +++ b/drivers/wdm/audio/drivers/CMIDriver/CMakeLists.txt @@ -26,7 +26,7 @@ target_link_libraries(cmipci stdunk libcntpr uuid) set_module_type(cmipci wdmdriver UNICODE) add_importlibs(cmipci portcls hal ntoskrnl) -if(USE_CLANG_CL OR (NOT MSVC)) +if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang") target_compile_options(cmipci PRIVATE -Wno-write-strings -Wno-switch) endif() diff --git a/modules/rostests/apitests/compiler/CMakeLists.txt b/modules/rostests/apitests/compiler/CMakeLists.txt index 1d98f54ddf6..163a0220c03 100644 --- a/modules/rostests/apitests/compiler/CMakeLists.txt +++ b/modules/rostests/apitests/compiler/CMakeLists.txt @@ -1,5 +1,5 @@ -if (NOT (GCC AND (ARCH STREQUAL "amd64"))) +if (MSVC OR ARCH STREQUAL "i386") #FIXME _setjmp definitions in CRT headers is wrong add_subdirectory(ms) list(APPEND SOURCE ms_seh.c) @@ -12,7 +12,7 @@ list(APPEND SOURCE testlist.c) add_executable(compiler_apitest ${SOURCE}) -if (NOT (GCC AND (ARCH STREQUAL "amd64"))) +if (MSVC OR ARCH STREQUAL "i386") target_link_libraries(compiler_apitest ms_seh_test) endif() target_link_libraries(compiler_apitest wine ${PSEH_LIB}) diff --git a/modules/rostests/apitests/crt/CMakeLists.txt b/modules/rostests/apitests/crt/CMakeLists.txt index 7af9e3a2463..6220856065e 100644 --- a/modules/rostests/apitests/crt/CMakeLists.txt +++ b/modules/rostests/apitests/crt/CMakeLists.txt @@ -1,5 +1,5 @@ -if (GCC) +if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang") add_compile_options(-fno-builtin) endif() diff --git a/modules/rostests/winetests/advapi32/CMakeLists.txt b/modules/rostests/winetests/advapi32/CMakeLists.txt index 34a3055167b..c6b8953189a 100644 --- a/modules/rostests/winetests/advapi32/CMakeLists.txt +++ b/modules/rostests/winetests/advapi32/CMakeLists.txt @@ -21,7 +21,7 @@ add_executable(advapi32_winetest ${SOURCE} ${PCH_SKIP_SOURCE}) -if(USE_CLANG_CL OR (NOT MSVC)) +if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang") target_compile_options(advapi32_winetest PRIVATE "-Wno-format") endif() diff --git a/modules/rostests/winetests/kernel32/CMakeLists.txt b/modules/rostests/winetests/kernel32/CMakeLists.txt index 44c24f653fb..862aaed9076 100644 --- a/modules/rostests/winetests/kernel32/CMakeLists.txt +++ b/modules/rostests/winetests/kernel32/CMakeLists.txt @@ -56,7 +56,7 @@ if(MSVC) endif() endif() -if(USE_CLANG_CL OR (NOT MSVC)) +if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang") target_compile_options(kernel32_winetest PRIVATE "-Wno-format") endif() diff --git a/modules/rostests/winetests/msvcrt/CMakeLists.txt b/modules/rostests/winetests/msvcrt/CMakeLists.txt index f05f14bd28a..44f4b3bf9cb 100644 --- a/modules/rostests/winetests/msvcrt/CMakeLists.txt +++ b/modules/rostests/winetests/msvcrt/CMakeLists.txt @@ -27,11 +27,8 @@ target_compile_definitions(msvcrt_winetest PRIVATE _CRT_NONSTDC_NO_DEPRECATE __msvcrt_ulong=ULONG) -if ((NOT MSVC) OR USE_CLANG_CL) - if (NOT USE_CLANG_CL) - target_compile_options(msvcrt_winetest PRIVATE -Wno-stringop-truncation) - endif() - target_compile_options(msvcrt_winetest PRIVATE -Wno-format) +if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang") + target_compile_options(msvcrt_winetest PRIVATE -Wno-format -Wno-stringop-truncation) endif() set_module_type(msvcrt_winetest win32cui) diff --git a/modules/rostests/winetests/ntdll/CMakeLists.txt b/modules/rostests/winetests/ntdll/CMakeLists.txt index b835ed34331..c5a886481e7 100644 --- a/modules/rostests/winetests/ntdll/CMakeLists.txt +++ b/modules/rostests/winetests/ntdll/CMakeLists.txt @@ -40,7 +40,7 @@ if(MSVC AND ARCH STREQUAL "amd64") target_compile_options(ntdll_winetest PRIVATE /wd4334) endif() -if(USE_CLANG_CL OR (NOT MSVC)) +if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang") target_compile_options(ntdll_winetest PRIVATE "-Wno-format") endif() diff --git a/modules/rostests/winetests/rpcrt4/CMakeLists.txt b/modules/rostests/winetests/rpcrt4/CMakeLists.txt index f764a4b89c7..753de69ef8b 100644 --- a/modules/rostests/winetests/rpcrt4/CMakeLists.txt +++ b/modules/rostests/winetests/rpcrt4/CMakeLists.txt @@ -40,11 +40,12 @@ endif() add_executable(rpcrt4_winetest ${SOURCE}) -if(USE_CLANG_CL OR (NOT MSVC)) +if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang") target_compile_options(rpcrt4_winetest PRIVATE "-Wno-format") - if(USE_CLANG_CL) - target_compile_options(rpcrt4_winetest PRIVATE "-Wno-cast-calling-convention") - endif() +endif() + +if(CMAKE_C_COMPILER_ID STREQUAL "Clang") + target_compile_options(rpcrt4_winetest PRIVATE "-Wno-cast-calling-convention") endif() target_link_libraries(rpcrt4_winetest uuid wine ${PSEH_LIB}) diff --git a/modules/rostests/winetests/winmm/CMakeLists.txt b/modules/rostests/winetests/winmm/CMakeLists.txt index c30a6b2a565..0d502f4f14a 100644 --- a/modules/rostests/winetests/winmm/CMakeLists.txt +++ b/modules/rostests/winetests/winmm/CMakeLists.txt @@ -14,7 +14,7 @@ list(APPEND SOURCE add_executable(winmm_winetest ${SOURCE}) -if(USE_CLANG_CL OR (NOT MSVC)) +if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang") target_compile_options(winmm_winetest PRIVATE "-Wno-format") endif() diff --git a/modules/rostests/winetests/ws2_32/CMakeLists.txt b/modules/rostests/winetests/ws2_32/CMakeLists.txt index 2229f5787aa..092a51e63ed 100644 --- a/modules/rostests/winetests/ws2_32/CMakeLists.txt +++ b/modules/rostests/winetests/ws2_32/CMakeLists.txt @@ -3,7 +3,7 @@ include_directories(BEFORE ${REACTOS_SOURCE_DIR}/sdk/include/reactos/wine) add_executable(ws2_32_winetest protocol.c sock.c testlist.c) -if(USE_CLANG_CL OR (NOT MSVC)) +if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang") target_compile_options(ws2_32_winetest PRIVATE "-Wno-format") endif() diff --git a/ntoskrnl/CMakeLists.txt b/ntoskrnl/CMakeLists.txt index 9109a7bc3c7..b9c51ab0c4a 100644 --- a/ntoskrnl/CMakeLists.txt +++ b/ntoskrnl/CMakeLists.txt @@ -1,18 +1,13 @@ PROJECT(NTOS) -if (GCC) +if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang") # Enable this again. CORE-17637 add_compile_options(-Wunused-result) endif() include(ntos.cmake) -if(NOT MSVC) - # Make sure we don't duplicate some symbols - add_compile_options(-fno-common) -endif() - set(NTOSKRNL_SOURCE ${SOURCE}) set(NTOSKRNL_ASM_SOURCE ${ASM_SOURCE}) diff --git a/sdk/cmake/config.cmake b/sdk/cmake/config.cmake index 020f0c7eda4..5e6243dd35a 100644 --- a/sdk/cmake/config.cmake +++ b/sdk/cmake/config.cmake @@ -75,25 +75,6 @@ else() "Whether to compile for debugging.") endif() -if(CMAKE_C_COMPILER_ID STREQUAL "GNU") - set(GCC TRUE CACHE BOOL "The compiler is GCC") - set(CLANG FALSE CACHE BOOL "The compiler is LLVM Clang") -elseif(CMAKE_C_COMPILER_ID STREQUAL "Clang") - # We can use LLVM Clang mimicking CL or GCC. Account for this - if (MSVC) - set(GCC FALSE CACHE BOOL "The compiler is GCC") - else() - set(GCC TRUE CACHE BOOL "The compiler is GCC") - endif() - set(CLANG TRUE CACHE BOOL "The compiler is LLVM Clang") -elseif(MSVC) # aka CMAKE_C_COMPILER_ID STREQUAL "MSVC" - set(GCC FALSE CACHE BOOL "The compiler is GCC") - set(CLANG FALSE CACHE BOOL "The compiler is LLVM Clang") - # MSVC variable is already set by cmake -else() - message("WARNING: the compiler has not been recognized") -endif() - if(MSVC) set(KDBG FALSE CACHE BOOL "Whether to compile in the integrated kernel debugger.") @@ -102,7 +83,6 @@ if(MSVC) else() set(_WINKD_ TRUE CACHE BOOL "Whether to compile with the KD protocol.") endif() - else() if(CMAKE_BUILD_TYPE STREQUAL "Release") set(KDBG FALSE CACHE BOOL "Whether to compile in the integrated kernel debugger.") @@ -120,7 +100,7 @@ cmake_dependent_option(ISAPNP_ENABLE "Whether to enable the ISA PnP support." ON set(GENERATE_DEPENDENCY_GRAPH FALSE CACHE BOOL "Whether to create a GraphML dependency graph of DLLs.") -if(MSVC) +if(CMAKE_C_COMPILER_ID STREQUAL "MSVC") option(_PREFAST_ "Whether to enable PREFAST while compiling." OFF) option(_VS_ANALYZE_ "Whether to enable static analysis while compiling." OFF) # RTC are incompatible with compiler optimizations. @@ -128,7 +108,7 @@ if(MSVC) "CMAKE_BUILD_TYPE STREQUAL Debug" OFF) endif() -if(GCC) +if(CMAKE_C_COMPILER_ID STREQUAL "GNU") option(STACK_PROTECTOR "Whether to enable the GCC stack checker while compiling" OFF) endif() diff --git a/sdk/cmake/gcc.cmake b/sdk/cmake/gcc.cmake index 076a9fc5731..5a37db32dea 100644 --- a/sdk/cmake/gcc.cmake +++ b/sdk/cmake/gcc.cmake @@ -485,12 +485,12 @@ add_compile_options("$<$:$:$>,-fexceptions,-fno-exceptions>>") # G++ shipped with ROSBE uses sjlj exceptions on i386. Tell Clang it is so -if (CLANG AND (ARCH STREQUAL "i386")) +if(CMAKE_C_COMPILER_ID STREQUAL "Clang" AND ARCH STREQUAL "i386") add_compile_options("$<$,$>>:-fsjlj-exceptions>") endif() # Find default G++ libraries -if (CLANG) +if(CMAKE_C_COMPILER_ID STREQUAL "Clang") set(GXX_EXECUTABLE ${CMAKE_CXX_COMPILER_TARGET}-g++) else() set(GXX_EXECUTABLE ${CMAKE_CXX_COMPILER}) diff --git a/sdk/lib/3rdparty/freetype/CMakeLists.txt b/sdk/lib/3rdparty/freetype/CMakeLists.txt index bac1f0bb249..e714504f97c 100644 --- a/sdk/lib/3rdparty/freetype/CMakeLists.txt +++ b/sdk/lib/3rdparty/freetype/CMakeLists.txt @@ -58,6 +58,8 @@ add_library(freetype ${SOURCE}) if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" AND ARCH STREQUAL "amd64") # error C4312: 'type cast': conversion from 'unsigned long' to 'void *' of greater size remove_target_compile_option(freetype "/we4312") -elseif(GCC) +endif() + +if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang") target_compile_options(freetype PRIVATE -fno-builtin-malloc) endif() diff --git a/sdk/lib/3rdparty/libxml2/CMakeLists.txt b/sdk/lib/3rdparty/libxml2/CMakeLists.txt index 5d7186e69b4..e56e434d3e8 100644 --- a/sdk/lib/3rdparty/libxml2/CMakeLists.txt +++ b/sdk/lib/3rdparty/libxml2/CMakeLists.txt @@ -64,7 +64,7 @@ list(APPEND SOURCE add_library(libxml2 ${SOURCE}) -if(MSVC AND (NOT USE_CLANG_CL)) +if(CMAKE_C_COMPILER_ID STREQUAL "MSVC") # Unreferenced local variable remove_target_compile_option(libxml2 "/we4101") target_compile_options(libxml2 PRIVATE "/wd4101") diff --git a/sdk/lib/crt/msvcrtex.cmake b/sdk/lib/crt/msvcrtex.cmake index 8f159a6b968..e8acbd7e2ca 100644 --- a/sdk/lib/crt/msvcrtex.cmake +++ b/sdk/lib/crt/msvcrtex.cmake @@ -26,7 +26,7 @@ if(ARCH STREQUAL "i386") math/i386/alldiv_asm.s math/i386/aulldiv_asm.s ) - if (GCC AND CLANG) + if (CMAKE_C_COMPILER_ID STREQUAL "Clang" AND NOT MSVC) list(APPEND MSVCRTEX_ASM_SOURCE math/i386/ceilf.S math/i386/floorf.S) @@ -77,7 +77,7 @@ if(MSVC AND (ARCH STREQUAL "i386")) endif() -if(GCC OR CLANG) +if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang") target_compile_options(msvcrtex PRIVATE $<$:-Wno-main>) if(LTCG) target_compile_options(msvcrtex PRIVATE -fno-lto) diff --git a/sdk/lib/drivers/wdf/CMakeLists.txt b/sdk/lib/drivers/wdf/CMakeLists.txt index 1210764d036..206d70031ef 100644 --- a/sdk/lib/drivers/wdf/CMakeLists.txt +++ b/sdk/lib/drivers/wdf/CMakeLists.txt @@ -210,7 +210,7 @@ target_include_directories(wdf01000 target_link_libraries(wdf01000 aux_klib ntoskrnl_vista ${PSEH_LIB}) -if(GCC) +if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang") target_compile_options(wdf01000 PRIVATE -Wno-write-strings -Wno-unknown-pragmas -Wno-switch PRIVATE $<$:-Wno-reorder -Wno-invalid-offsetof -Wno-delete-non-virtual-dtor>) diff --git a/sdk/lib/rtl/CMakeLists.txt b/sdk/lib/rtl/CMakeLists.txt index 042e51e4e4a..a8d2fdbe348 100644 --- a/sdk/lib/rtl/CMakeLists.txt +++ b/sdk/lib/rtl/CMakeLists.txt @@ -5,7 +5,7 @@ add_definitions( -D_NTSYSTEM_ -D_NTDLLBUILD_) -if (GCC) +if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang") # Enable this again. CORE-17637 add_compile_options(-Wunused-result) endif()