[CMAKE] Elimitate the use of GCC and CLANG variables

This commit is contained in:
Victor Perevertkin 2022-05-26 01:37:23 +03:00
parent 6f4be52a1c
commit f155b9377f
No known key found for this signature in database
GPG key ID: C750B7222E9C7830
32 changed files with 78 additions and 116 deletions

View file

@ -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. # 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}) 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") if (NOT MSVC AND (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang"))
OR ((CMAKE_C_COMPILER_ID STREQUAL "Clang") AND (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "10.0.0"))))
# Thankfully, GCC has this # Thankfully, GCC has this
add_compile_options(-ffile-prefix-map=${REACTOS_SOURCE_DIR}=) add_compile_options(-ffile-prefix-map=${REACTOS_SOURCE_DIR}=)
add_compile_options(-ffile-prefix-map=${_PATH_PREFIX}=) 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).") message(WARNING "-- Disabling precompiled headers support (ccache).")
option(PCH "Whether to use precompiled headers" OFF) option(PCH "Whether to use precompiled headers" OFF)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) 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.") message(WARNING "-- Disabling precompiled headers on GCC by default CORE-17108.")
option(PCH "Whether to use precompiled headers" OFF) option(PCH "Whether to use precompiled headers" OFF)
else() else()

View file

@ -48,7 +48,7 @@ list(APPEND SOURCE
add_executable(nfsd ${SOURCE} nfsd.rc) 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) # Disable warning C4477 (printf format warnings)
target_compile_options(nfsd PRIVATE /wd4477) target_compile_options(nfsd PRIVATE /wd4477)
else() else()

View file

@ -7,7 +7,7 @@ add_definitions(
set(NTOS_RTL_SOURCE_DIR "${REACTOS_SOURCE_DIR}/sdk/lib/rtl") set(NTOS_RTL_SOURCE_DIR "${REACTOS_SOURCE_DIR}/sdk/lib/rtl")
include_directories(${NTOS_RTL_SOURCE_DIR}) 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 # Enable this again. CORE-17637
add_compile_options(-Wunused-result) add_compile_options(-Wunused-result)
endif() endif()

View file

@ -43,7 +43,7 @@ if(MSVC)
add_importlibs(libxslt ntdll) add_importlibs(libxslt ntdll)
endif() endif()
if(GCC OR CLANG) if(NOT MSVC)
target_compile_options(libxslt PRIVATE -Wno-misleading-indentation -Wno-pointer-sign -Wno-unused-function) target_compile_options(libxslt PRIVATE -Wno-misleading-indentation -Wno-pointer-sign -Wno-unused-function)
endif() endif()

View file

@ -102,6 +102,8 @@ add_cd_file(TARGET mbedtls DESTINATION reactos/system32 FOR all)
if(NOT MSVC) if(NOT MSVC)
target_compile_options(mbedtls PRIVATE -Wno-pointer-sign -Wno-unused-function) 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) target_compile_options(mbedtls PRIVATE -Wno-tautological-constant-compare)
endif() endif()

View file

@ -120,19 +120,19 @@ target_link_libraries(glu32 cpprt)
set_module_type(glu32 win32dll) 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") 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) target_compile_options(glu32 PRIVATE -Wno-unused-but-set-variable)
# Prevent a warning when comparing 'this' against 0 # Prevent a warning when comparing 'this' against 0
set_source_files_properties(src/libnurbs/internals/arc.cc PROPERTIES COMPILE_FLAGS "-Wno-nonnull-compare") set_source_files_properties(src/libnurbs/internals/arc.cc PROPERTIES COMPILE_FLAGS "-Wno-nonnull-compare")
endif() 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_importlibs(glu32 opengl32 gdi32 msvcrt kernel32 ntdll)
add_pch(glu32 precomp.h "${PCH_SKIP_SOURCE}") add_pch(glu32 precomp.h "${PCH_SKIP_SOURCE}")
add_cd_file(TARGET glu32 DESTINATION reactos/system32 FOR all) add_cd_file(TARGET glu32 DESTINATION reactos/system32 FOR all)

View file

@ -88,26 +88,21 @@ list(APPEND SOURCE
add_library(ext2fs MODULE ${SOURCE} ext2fs.rc) add_library(ext2fs MODULE ${SOURCE} ext2fs.rc)
if(MSVC) if(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
if (NOT CLANG)
# Disable warning C4101: 'i': unreferenced local variable # Disable warning C4101: 'i': unreferenced local variable
# Disable warning C4189: 'sbi': local variable is initialized but not referenced # Disable warning C4189: 'sbi': local variable is initialized but not referenced
# Disable warning C4267: '=': conversion from 'size_t' to 'USHORT', possible loss of data # Disable warning C4267: '=': conversion from 'size_t' to 'USHORT', possible loss of data
target_compile_options(ext2fs PRIVATE /wd4101 /wd4189 /wd4267) target_compile_options(ext2fs PRIVATE /wd4101 /wd4189 /wd4267)
endif() endif()
else()
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
target_compile_options(ext2fs PRIVATE target_compile_options(ext2fs PRIVATE
-Wno-pointer-sign -Wno-unused-function -Wno-pointer-sign -Wno-unused-function -Wno-unused-variable -Wno-missing-braces -Wno-unused-but-set-variable)
-Wno-unused-variable -Wno-missing-braces)
endif() endif()
if(CMAKE_C_COMPILER_ID STREQUAL "GNU") if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
target_compile_options(ext2fs PRIVATE -Wno-unused-but-set-variable)
endif()
if(CLANG)
target_compile_options(ext2fs PRIVATE target_compile_options(ext2fs PRIVATE
-Wno-unused-value -Wno-parentheses-equality -Wno-parentheses-equality
-Wno-incompatible-pointer-types-discards-qualifiers -Wno-incompatible-pointer-types-discards-qualifiers
"-Wno-#pragma-messages;-Wno-cast-calling-convention") "-Wno-#pragma-messages;-Wno-cast-calling-convention")
endif() endif()

View file

@ -38,7 +38,7 @@ list(APPEND SOURCE
add_library(fastfat MODULE ${SOURCE} fastfat.rc) add_library(fastfat MODULE ${SOURCE} fastfat.rc)
set_module_type(fastfat kernelmodedriver) set_module_type(fastfat kernelmodedriver)
target_link_libraries(fastfat ${PSEH_LIB} memcmp) 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) target_compile_options(fastfat PRIVATE -O0)
endif() endif()
add_importlibs(fastfat ntoskrnl hal) add_importlibs(fastfat ntoskrnl hal)

View file

@ -14,12 +14,14 @@ set_module_type(nfs41_driver kernelmodedriver)
target_link_libraries(nfs41_driver ntoskrnl_vista rdbsslib rxce copysup memcmp ${PSEH_LIB}) target_link_libraries(nfs41_driver ntoskrnl_vista rdbsslib rxce copysup memcmp ${PSEH_LIB})
add_importlibs(nfs41_driver ntoskrnl hal) 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") target_compile_options(nfs41_driver PRIVATE "-Wno-switch")
if(CLANG) endif()
if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
target_compile_options(nfs41_driver PRIVATE "-Wno-unused-value") target_compile_options(nfs41_driver PRIVATE "-Wno-unused-value")
endif() endif()
endif()
set_property(TARGET nfs41_driver PROPERTY C_STANDARD 90) set_property(TARGET nfs41_driver PROPERTY C_STANDARD 90)
add_cd_file(TARGET nfs41_driver DESTINATION reactos/system32/drivers FOR all) add_cd_file(TARGET nfs41_driver DESTINATION reactos/system32/drivers FOR all)

View file

@ -41,18 +41,16 @@ list(APPEND SOURCE
add_library(udfs MODULE ${SOURCE} udffs.rc) add_library(udfs MODULE ${SOURCE} udffs.rc)
if(MSVC) if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
if(USE_CLANG_CL) 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-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-constant-out-of-range-compare)
target_compile_options(udfs PRIVATE -Wno-tautological-unsigned-zero-compare -Wno-self-assign) target_compile_options(udfs PRIVATE -Wno-tautological-unsigned-zero-compare -Wno-self-assign)
target_compile_options(udfs PRIVATE -Wno-sometimes-uninitialized -Wno-parentheses-equality) target_compile_options(udfs PRIVATE -Wno-sometimes-uninitialized -Wno-parentheses-equality)
endif() endif()
endif()
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_compile_options(udfs PRIVATE -Wno-unused-but-set-variable)
endif()
set_module_type(udfs kernelmodedriver) set_module_type(udfs kernelmodedriver)
target_link_libraries(udfs ${PSEH_LIB}) target_link_libraries(udfs ${PSEH_LIB})

View file

@ -20,15 +20,12 @@ list(APPEND SOURCE
add_library(cdrom MODULE ${SOURCE} cdrom.rc) add_library(cdrom MODULE ${SOURCE} cdrom.rc)
set_module_type(cdrom kernelmodedriver) 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) 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) target_compile_options(cdrom PRIVATE -Wno-unknown-pragmas -Wno-incompatible-pointer-types -Wno-switch)
endif() endif()
if(CLANG) if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
target_compile_options(cdrom PRIVATE -Wno-enum-conversion -Wno-tautological-constant-compare) target_compile_options(cdrom PRIVATE -Wno-enum-conversion -Wno-tautological-constant-compare)
endif() endif()

View file

@ -41,7 +41,7 @@ target_compile_definitions(classpnp PRIVATE
CLASS_GLOBAL_BUFFERED_DEBUG_PRINT_BUFFER_SIZE=512 CLASS_GLOBAL_BUFFERED_DEBUG_PRINT_BUFFER_SIZE=512
CLASS_GLOBAL_BUFFERED_DEBUG_PRINT_BUFFERS=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) target_compile_options(classpnp PRIVATE -Wno-pointer-to-int-cast -Wno-switch)
endif() endif()

View file

@ -16,11 +16,8 @@ target_compile_definitions(disk PUBLIC
_WIN32_WINNT=0x602 _WIN32_WINNT=0x602
NTDDI_VERSION=0x06020000) # NTDDI_WIN8 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) 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) target_compile_options(disk PRIVATE -Wno-pointer-to-int-cast -Wno-switch)
endif() endif()

View file

@ -21,21 +21,18 @@ list(APPEND SOURCE
add_library(uniata MODULE ${SOURCE} idedma.rc) 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) if(MSVC)
# Disable warning C4267: '=': conversion from 'size_t' to 'USHORT', possible loss of data # 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 # Disable warning C4838: conversion from 'int' to 'ULONG' requires a narrowing conversion
target_compile_options(uniata PRIVATE /wd4267 /wd4838) target_compile_options(uniata PRIVATE /wd4267 /wd4838)
endif() endif()
if(CMAKE_C_COMPILER_ID STREQUAL "GNU") if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
target_compile_options(uniata PRIVATE -Wno-unused-but-set-variable) 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() endif()
add_pch(uniata stdafx.h SOURCE) add_pch(uniata stdafx.h SOURCE)

View file

@ -26,7 +26,7 @@ target_link_libraries(cmipci stdunk libcntpr uuid)
set_module_type(cmipci wdmdriver UNICODE) set_module_type(cmipci wdmdriver UNICODE)
add_importlibs(cmipci portcls hal ntoskrnl) 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) target_compile_options(cmipci PRIVATE -Wno-write-strings -Wno-switch)
endif() endif()

View file

@ -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 #FIXME _setjmp definitions in CRT headers is wrong
add_subdirectory(ms) add_subdirectory(ms)
list(APPEND SOURCE ms_seh.c) list(APPEND SOURCE ms_seh.c)
@ -12,7 +12,7 @@ list(APPEND SOURCE
testlist.c) testlist.c)
add_executable(compiler_apitest ${SOURCE}) 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) target_link_libraries(compiler_apitest ms_seh_test)
endif() endif()
target_link_libraries(compiler_apitest wine ${PSEH_LIB}) target_link_libraries(compiler_apitest wine ${PSEH_LIB})

View file

@ -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) add_compile_options(-fno-builtin)
endif() endif()

View file

@ -21,7 +21,7 @@ add_executable(advapi32_winetest
${SOURCE} ${SOURCE}
${PCH_SKIP_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") target_compile_options(advapi32_winetest PRIVATE "-Wno-format")
endif() endif()

View file

@ -56,7 +56,7 @@ if(MSVC)
endif() endif()
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") target_compile_options(kernel32_winetest PRIVATE "-Wno-format")
endif() endif()

View file

@ -27,11 +27,8 @@ target_compile_definitions(msvcrt_winetest PRIVATE
_CRT_NONSTDC_NO_DEPRECATE _CRT_NONSTDC_NO_DEPRECATE
__msvcrt_ulong=ULONG) __msvcrt_ulong=ULONG)
if ((NOT MSVC) OR USE_CLANG_CL) if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
if (NOT USE_CLANG_CL) target_compile_options(msvcrt_winetest PRIVATE -Wno-format -Wno-stringop-truncation)
target_compile_options(msvcrt_winetest PRIVATE -Wno-stringop-truncation)
endif()
target_compile_options(msvcrt_winetest PRIVATE -Wno-format)
endif() endif()
set_module_type(msvcrt_winetest win32cui) set_module_type(msvcrt_winetest win32cui)

View file

@ -40,7 +40,7 @@ if(MSVC AND ARCH STREQUAL "amd64")
target_compile_options(ntdll_winetest PRIVATE /wd4334) target_compile_options(ntdll_winetest PRIVATE /wd4334)
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(ntdll_winetest PRIVATE "-Wno-format") target_compile_options(ntdll_winetest PRIVATE "-Wno-format")
endif() endif()

View file

@ -40,11 +40,12 @@ endif()
add_executable(rpcrt4_winetest ${SOURCE}) 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") 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() endif()
target_link_libraries(rpcrt4_winetest uuid wine ${PSEH_LIB}) target_link_libraries(rpcrt4_winetest uuid wine ${PSEH_LIB})

View file

@ -14,7 +14,7 @@ list(APPEND SOURCE
add_executable(winmm_winetest ${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") target_compile_options(winmm_winetest PRIVATE "-Wno-format")
endif() endif()

View file

@ -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) 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") target_compile_options(ws2_32_winetest PRIVATE "-Wno-format")
endif() endif()

View file

@ -1,18 +1,13 @@
PROJECT(NTOS) PROJECT(NTOS)
if (GCC) if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
# Enable this again. CORE-17637 # Enable this again. CORE-17637
add_compile_options(-Wunused-result) add_compile_options(-Wunused-result)
endif() endif()
include(ntos.cmake) 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_SOURCE ${SOURCE})
set(NTOSKRNL_ASM_SOURCE ${ASM_SOURCE}) set(NTOSKRNL_ASM_SOURCE ${ASM_SOURCE})

View file

@ -75,25 +75,6 @@ else()
"Whether to compile for debugging.") "Whether to compile for debugging.")
endif() 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) if(MSVC)
set(KDBG FALSE CACHE BOOL set(KDBG FALSE CACHE BOOL
"Whether to compile in the integrated kernel debugger.") "Whether to compile in the integrated kernel debugger.")
@ -102,7 +83,6 @@ if(MSVC)
else() else()
set(_WINKD_ TRUE CACHE BOOL "Whether to compile with the KD protocol.") set(_WINKD_ TRUE CACHE BOOL "Whether to compile with the KD protocol.")
endif() endif()
else() else()
if(CMAKE_BUILD_TYPE STREQUAL "Release") if(CMAKE_BUILD_TYPE STREQUAL "Release")
set(KDBG FALSE CACHE BOOL "Whether to compile in the integrated kernel debugger.") 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 set(GENERATE_DEPENDENCY_GRAPH FALSE CACHE BOOL
"Whether to create a GraphML dependency graph of DLLs.") "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(_PREFAST_ "Whether to enable PREFAST while compiling." OFF)
option(_VS_ANALYZE_ "Whether to enable static analysis while compiling." OFF) option(_VS_ANALYZE_ "Whether to enable static analysis while compiling." OFF)
# RTC are incompatible with compiler optimizations. # RTC are incompatible with compiler optimizations.
@ -128,7 +108,7 @@ if(MSVC)
"CMAKE_BUILD_TYPE STREQUAL Debug" OFF) "CMAKE_BUILD_TYPE STREQUAL Debug" OFF)
endif() endif()
if(GCC) if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
option(STACK_PROTECTOR "Whether to enable the GCC stack checker while compiling" OFF) option(STACK_PROTECTOR "Whether to enable the GCC stack checker while compiling" OFF)
endif() endif()

View file

@ -485,12 +485,12 @@ add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:$<IF:$<BOOL:$<TARGET_PROPERTY:WIT
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:$<IF:$<BOOL:$<TARGET_PROPERTY:WITH_CXX_EXCEPTIONS>>,-fexceptions,-fno-exceptions>>") add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:$<IF:$<BOOL:$<TARGET_PROPERTY:WITH_CXX_EXCEPTIONS>>,-fexceptions,-fno-exceptions>>")
# G++ shipped with ROSBE uses sjlj exceptions on i386. Tell Clang it is so # 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("$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<BOOL:$<TARGET_PROPERTY:WITH_CXX_EXCEPTIONS>>>:-fsjlj-exceptions>") add_compile_options("$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<BOOL:$<TARGET_PROPERTY:WITH_CXX_EXCEPTIONS>>>:-fsjlj-exceptions>")
endif() endif()
# Find default G++ libraries # Find default G++ libraries
if (CLANG) if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
set(GXX_EXECUTABLE ${CMAKE_CXX_COMPILER_TARGET}-g++) set(GXX_EXECUTABLE ${CMAKE_CXX_COMPILER_TARGET}-g++)
else() else()
set(GXX_EXECUTABLE ${CMAKE_CXX_COMPILER}) set(GXX_EXECUTABLE ${CMAKE_CXX_COMPILER})

View file

@ -58,6 +58,8 @@ add_library(freetype ${SOURCE})
if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" AND ARCH STREQUAL "amd64") if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" AND ARCH STREQUAL "amd64")
# error C4312: 'type cast': conversion from 'unsigned long' to 'void *' of greater size # error C4312: 'type cast': conversion from 'unsigned long' to 'void *' of greater size
remove_target_compile_option(freetype "/we4312") 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) target_compile_options(freetype PRIVATE -fno-builtin-malloc)
endif() endif()

View file

@ -64,7 +64,7 @@ list(APPEND SOURCE
add_library(libxml2 ${SOURCE}) add_library(libxml2 ${SOURCE})
if(MSVC AND (NOT USE_CLANG_CL)) if(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
# Unreferenced local variable # Unreferenced local variable
remove_target_compile_option(libxml2 "/we4101") remove_target_compile_option(libxml2 "/we4101")
target_compile_options(libxml2 PRIVATE "/wd4101") target_compile_options(libxml2 PRIVATE "/wd4101")

View file

@ -26,7 +26,7 @@ if(ARCH STREQUAL "i386")
math/i386/alldiv_asm.s math/i386/alldiv_asm.s
math/i386/aulldiv_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 list(APPEND MSVCRTEX_ASM_SOURCE
math/i386/ceilf.S math/i386/ceilf.S
math/i386/floorf.S) math/i386/floorf.S)
@ -77,7 +77,7 @@ if(MSVC AND (ARCH STREQUAL "i386"))
endif() endif()
if(GCC OR CLANG) if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
target_compile_options(msvcrtex PRIVATE $<$<COMPILE_LANGUAGE:C>:-Wno-main>) target_compile_options(msvcrtex PRIVATE $<$<COMPILE_LANGUAGE:C>:-Wno-main>)
if(LTCG) if(LTCG)
target_compile_options(msvcrtex PRIVATE -fno-lto) target_compile_options(msvcrtex PRIVATE -fno-lto)

View file

@ -210,7 +210,7 @@ target_include_directories(wdf01000
target_link_libraries(wdf01000 aux_klib ntoskrnl_vista ${PSEH_LIB}) 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 target_compile_options(wdf01000
PRIVATE -Wno-write-strings -Wno-unknown-pragmas -Wno-switch PRIVATE -Wno-write-strings -Wno-unknown-pragmas -Wno-switch
PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-Wno-reorder -Wno-invalid-offsetof -Wno-delete-non-virtual-dtor>) PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-Wno-reorder -Wno-invalid-offsetof -Wno-delete-non-virtual-dtor>)

View file

@ -5,7 +5,7 @@ add_definitions(
-D_NTSYSTEM_ -D_NTSYSTEM_
-D_NTDLLBUILD_) -D_NTDLLBUILD_)
if (GCC) if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
# Enable this again. CORE-17637 # Enable this again. CORE-17637
add_compile_options(-Wunused-result) add_compile_options(-Wunused-result)
endif() endif()