summaryrefslogtreecommitdiff
path: root/CMake
diff options
context:
space:
mode:
authorJosJuice <josjuice@gmail.com>2026-10-18 12:12:01 +0200
committerGitHub <noreply@github.com>2026-10-18 12:12:01 +0200
commitb869a2ab2035f0ff0c0ca71becb4e33131ebb1b7 (patch)
tree2b1375af3b855773ade1b193ec54749552b06540 /CMake
parent38d619b07691231f54e6f037fcf30a3b64fdd5a5 (diff)
parent89660f5beae0a3f307ac1587c016e93a4efaed63 (diff)
Merge pull request #14793 from JoshuaVandaele/auto-off-warns
CMake: Automatically disable warnings for Externals
Diffstat (limited to 'CMake')
-rw-r--r--CMake/DolphinDisableWarnings.cmake17
-rw-r--r--CMake/DolphinDisableWarningsMSVC.cmake20
-rw-r--r--CMake/DolphinLibraryTools.cmake30
3 files changed, 43 insertions, 24 deletions
diff --git a/CMake/DolphinDisableWarnings.cmake b/CMake/DolphinDisableWarnings.cmake
new file mode 100644
index 0000000000..72539ef10d
--- /dev/null
+++ b/CMake/DolphinDisableWarnings.cmake
@@ -0,0 +1,17 @@
+function(dolphin_disable_warnings target)
+ get_target_property(target_flags ${target} COMPILE_OPTIONS)
+ set(new_flags)
+ foreach(flag IN LISTS target_flags)
+ # all warning flags start with "/W" or "/w" or "-W" or "-w"
+ if (NOT flag MATCHES "^[-/][Ww]")
+ list(APPEND new_flags "${flag}")
+ endif()
+ endforeach()
+ set_target_properties(${target} PROPERTIES COMPILE_OPTIONS "${new_flags}")
+
+ if (MSVC)
+ target_compile_options(${target} PRIVATE "/W0")
+ elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
+ target_compile_options(${target} PRIVATE "-w")
+ endif()
+endfunction()
diff --git a/CMake/DolphinDisableWarningsMSVC.cmake b/CMake/DolphinDisableWarningsMSVC.cmake
deleted file mode 100644
index dbd3553762..0000000000
--- a/CMake/DolphinDisableWarningsMSVC.cmake
+++ /dev/null
@@ -1,20 +0,0 @@
-include(RemoveCompileFlag)
-
-macro(dolphin_disable_warnings _target)
- get_target_property(_target_cxx_flags ${_target} COMPILE_OPTIONS)
- if (_target_cxx_flags)
- set(new_flags "")
- foreach(flag IN LISTS _target_cxx_flags)
- # all warning flags start with "/W" or "/w" or "-W" or "-w"
- if (NOT "${flag}" MATCHES "^[-/][Ww]")
- list(APPEND new_flags "${flag}")
- endif()
- endforeach()
- set_target_properties(${_target} PROPERTIES COMPILE_OPTIONS "${new_flags}")
- endif()
- if (MSVC)
- target_compile_options(${_target} PRIVATE "/W0")
- elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
- target_compile_options(${_target} PRIVATE "-w")
- endif()
-endmacro()
diff --git a/CMake/DolphinLibraryTools.cmake b/CMake/DolphinLibraryTools.cmake
index 99f5f7f8f4..7b99dec1e3 100644
--- a/CMake/DolphinLibraryTools.cmake
+++ b/CMake/DolphinLibraryTools.cmake
@@ -41,8 +41,21 @@ function(dolphin_optional_system_library out_use_system library)
endif()
endfunction()
-function(dolphin_add_bundled_library library use_system bundled_path)
- if (${use_system} STREQUAL "AUTO")
+function(dolphin_find_directory_targets dir result)
+ get_directory_property(targets DIRECTORY ${dir} BUILDSYSTEM_TARGETS)
+
+ get_property(subdirs DIRECTORY ${dir} PROPERTY SUBDIRECTORIES)
+ foreach(subdir IN LISTS subdirs)
+ dolphin_find_directory_targets(${subdir} sub_targets)
+ list(APPEND targets ${sub_targets})
+ endforeach()
+
+ set(${result} "${targets}" PARENT_SCOPE)
+endfunction()
+
+function(dolphin_add_bundled_library library bundled_path)
+ set(use_system "${ARGV2}")
+ if (use_system STREQUAL "AUTO")
message(STATUS "No system ${library} was found. Using static ${library} from Externals.")
else()
message(STATUS "Using static ${library} from Externals")
@@ -51,6 +64,15 @@ function(dolphin_add_bundled_library library use_system bundled_path)
message(FATAL_ERROR "No bundled ${library} was found. Did you forget to checkout submodules?")
endif()
add_subdirectory(${bundled_path} EXCLUDE_FROM_ALL)
+ dolphin_find_directory_targets(${bundled_path} bundled_targets)
+ foreach(target IN LISTS bundled_targets)
+ get_target_property(type ${target} TYPE)
+ get_target_property(imported ${target} IMPORTED)
+ if(imported OR type STREQUAL "INTERFACE_LIBRARY" OR type STREQUAL "UTILITY")
+ continue()
+ endif()
+ dolphin_disable_warnings(${target})
+ endforeach()
endfunction()
function(dolphin_set_library_type library type)
@@ -119,7 +141,7 @@ function(dolphin_find_optional_system_library library bundled_path)
message(STATUS "Using system ${library}")
else()
dolphin_set_library_type(${library} "Bundled")
- dolphin_add_bundled_library(${library} ${use_system} ${bundled_path})
+ dolphin_add_bundled_library(${library} ${bundled_path} ${use_system})
endif()
endfunction()
@@ -138,7 +160,7 @@ function(dolphin_find_optional_system_library_pkgconfig library search alias bun
dolphin_alias_library(${alias} PkgConfig::${library})
else()
dolphin_set_library_type(${library} "Bundled")
- dolphin_add_bundled_library(${library} ${use_system} ${bundled_path})
+ dolphin_add_bundled_library(${library} ${bundled_path} ${use_system})
endif()
endfunction()