[cmake] enable clang-cl and WoA builds #348

Merged
crueter merged 31 commits from liz-clang-cl-cmake into master 2025-09-09 20:47:51 +02:00
7 changed files with 37 additions and 26 deletions
Showing only changes of commit f18c354fb6 - Show all commits

View file

@ -11,16 +11,3 @@ index d49f2ec..a9bdb80 100644
}; };
diff --git a/libs/context/CMakeLists.txt b/libs/context/CMakeLists.txt
index 5870537..f8c3e61 100644
--- a/libs/context/CMakeLists.txt
+++ b/libs/context/CMakeLists.txt
@@ -189,7 +189,7 @@ if(BOOST_CONTEXT_IMPLEMENTATION STREQUAL "fcontext")
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set_property(SOURCE ${ASM_SOURCES} APPEND PROPERTY COMPILE_OPTIONS "-x" "assembler-with-cpp")
- elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT MSVC)
set_property(SOURCE ${ASM_SOURCES} APPEND PROPERTY COMPILE_OPTIONS "-Wno-unused-command-line-argument")
endif()

View file

@ -15,6 +15,10 @@ elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set(PLATFORM_LINUX ON) set(PLATFORM_LINUX ON)
endif() endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CXX_CLANG ON)
endif()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules") list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/externals/cmake-modules") list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/externals/cmake-modules")
if (PLATFORM_SUN) if (PLATFORM_SUN)
@ -29,6 +33,19 @@ if (PLATFORM_SUN)
endif() endif()
endif() endif()
# clang-cl prints literally 10000+ warnings without this
if (MSVC AND CXX_CLANG)
add_compile_options(
-Wno-unused-command-line-argument
-Wno-unsafe-buffer-usage
-Wno-unused-value
-Wno-extra-semi-stmt
-Wno-sign-conversion
-Wno-reserved-identifier
-Wno-deprecated-declarations
)
endif()
set(CPM_SOURCE_CACHE ${CMAKE_SOURCE_DIR}/.cache/cpm) set(CPM_SOURCE_CACHE ${CMAKE_SOURCE_DIR}/.cache/cpm)
include(DownloadExternals) include(DownloadExternals)
@ -36,7 +53,7 @@ include(CMakeDependentOption)
include(CTest) include(CTest)
# Disable Warnings as Errors for MSVC # Disable Warnings as Errors for MSVC
if (MSVC) if (MSVC AND NOT CXX_CLANG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3 /WX-") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3 /WX-")
endif() endif()
@ -274,7 +291,7 @@ if (YUZU_ROOM)
endif() endif()
# Build/optimization presets # Build/optimization presets
if (PLATFORM_LINUX) if (PLATFORM_LINUX OR CXX_CLANG)
if (ARCHITECTURE_x86_64) if (ARCHITECTURE_x86_64)
set(YUZU_BUILD_PRESET "custom" CACHE STRING "Build preset to use. One of: custom, generic, v3, zen2, zen4, native") set(YUZU_BUILD_PRESET "custom" CACHE STRING "Build preset to use. One of: custom, generic, v3, zen2, zen4, native")
if (${YUZU_BUILD_PRESET} STREQUAL "generic") if (${YUZU_BUILD_PRESET} STREQUAL "generic")
@ -749,7 +766,7 @@ if (MSVC AND CMAKE_GENERATOR STREQUAL "Ninja")
endif() endif()
# Adjustments for clang-cl # Adjustments for clang-cl
if (MSVC AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang") if (MSVC AND CXX_CLANG)
if (ARCHITECTURE_x86_64) if (ARCHITECTURE_x86_64)
set(FILE_ARCH x86_64) set(FILE_ARCH x86_64)
elseif (ARCHITECTURE_arm64) elseif (ARCHITECTURE_arm64)
@ -763,7 +780,7 @@ if (MSVC AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
add_library(llvm-mingw-runtime STATIC IMPORTED) add_library(llvm-mingw-runtime STATIC IMPORTED)
set_target_properties(llvm-mingw-runtime PROPERTIES set_target_properties(llvm-mingw-runtime PROPERTIES
IMPORTED_LOCATION "${EXTRACTED_LIB}" IMPORTED_LOCATION "${LIB_PATH}"
) )
link_libraries(llvm-mingw-runtime) link_libraries(llvm-mingw-runtime)

View file

@ -108,8 +108,8 @@
}, },
"boost_headers": { "boost_headers": {
"repo": "boostorg/headers", "repo": "boostorg/headers",
"sha": "0456900fad", "sha": "95930ca8f5",
"hash": "50cd75dcdfc5f082225cdace058f47b4fb114a47585f7aee1d22236a910a80b667186254c214fa2fcebac67ae6d37ba4b6e695e1faea8affd6fd42a03cf996e3", "hash": "d1dece16f3b209109de02123c537bfe1adf07a62b16c166367e7e5d62e0f7c323bf804c89b3192dd6871bc58a9d879d25a1cc3f7b9da0e497cf266f165816e2a",
"bundled": true "bundled": true
}, },
"discord-rpc": { "discord-rpc": {

View file

@ -63,7 +63,8 @@ if (mbedtls_ADDED)
if (NOT MSVC) if (NOT MSVC)
target_compile_options(mbedcrypto PRIVATE target_compile_options(mbedcrypto PRIVATE
-Wno-unused-but-set-variable -Wno-unused-but-set-variable
-Wno-string-concatenation) -Wno-string-concatenation
)
endif() endif()
endif() endif()
@ -84,6 +85,8 @@ if(MSVC AND USE_CCACHE AND sirit_ADDED)
list(FILTER _opts EXCLUDE REGEX "/Zi") list(FILTER _opts EXCLUDE REGEX "/Zi")
list(APPEND _opts "/Z7") list(APPEND _opts "/Z7")
set_target_properties(sirit PROPERTIES COMPILE_OPTIONS "${_opts}") set_target_properties(sirit PROPERTIES COMPILE_OPTIONS "${_opts}")
elseif(MSVC AND CXX_CLANG)
target_compile_options(sirit PRIVATE -Wno-error=unused-command-line-argument)
endif() endif()
# httplib # httplib

View file

@ -69,10 +69,6 @@ if (MSVC)
/external:anglebrackets # Treats all headers included by #include <header>, where the header file is enclosed in angle brackets (< >), as external headers /external:anglebrackets # Treats all headers included by #include <header>, where the header file is enclosed in angle brackets (< >), as external headers
/external:W0 # Sets the default warning level to 0 for external headers, effectively disabling warnings for them. /external:W0 # Sets the default warning level to 0 for external headers, effectively disabling warnings for them.
# Warnings
/W4
/WX-
/we4062 # Enumerator 'identifier' in a switch of enum 'enumeration' is not handled /we4062 # Enumerator 'identifier' in a switch of enum 'enumeration' is not handled
/we4189 # 'identifier': local variable is initialized but not referenced /we4189 # 'identifier': local variable is initialized but not referenced
/we4265 # 'class': class has virtual functions, but destructor is not virtual /we4265 # 'class': class has virtual functions, but destructor is not virtual
@ -97,6 +93,14 @@ if (MSVC)
/wd4702 # unreachable code (when used with LTO) /wd4702 # unreachable code (when used with LTO)
) )
if (NOT CXX_CLANG)
add_compile_options(
# Warnings
/W4
/WX-
)
endif()
if (USE_CCACHE OR YUZU_USE_PRECOMPILED_HEADERS) if (USE_CCACHE OR YUZU_USE_PRECOMPILED_HEADERS)
# when caching, we need to use /Z7 to downgrade debug info to use an older but more cacheable format # when caching, we need to use /Z7 to downgrade debug info to use an older but more cacheable format
# Precompiled headers are deleted if not using /Z7. See https://github.com/nanoant/CMakePCHCompiler/issues/21 # Precompiled headers are deleted if not using /Z7. See https://github.com/nanoant/CMakePCHCompiler/issues/21

View file

@ -245,7 +245,7 @@ else()
endif() endif()
endif() endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") if(CXX_CLANG)
target_compile_options(common PRIVATE -fsized-deallocation target_compile_options(common PRIVATE -fsized-deallocation
-Werror=unreachable-code-aggressive) -Werror=unreachable-code-aggressive)
target_compile_definitions( target_compile_definitions(

View file

@ -256,7 +256,7 @@ if (YUZU_CRASH_DUMPS)
target_compile_definitions(yuzu PRIVATE YUZU_CRASH_DUMPS) target_compile_definitions(yuzu PRIVATE YUZU_CRASH_DUMPS)
endif() endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") if (CXX_CLANG)
target_compile_definitions(yuzu PRIVATE target_compile_definitions(yuzu PRIVATE
$<$<VERSION_LESS:$<CXX_COMPILER_VERSION>,15>:CANNOT_EXPLICITLY_INSTANTIATE> $<$<VERSION_LESS:$<CXX_COMPILER_VERSION>,15>:CANNOT_EXPLICITLY_INSTANTIATE>
) )