From 11065e99114e95bab4b617fa9b50ceb43019adee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joshua=20Vanda=C3=ABle?= Date: Wed, 24 Dec 2025 03:59:15 +0100 Subject: [PATCH] CMake: Error out when switching sources for dependencies Currently, configuring from System>Bundled doesn't work, it instead produces cryptic errors. And configuring from Bundled>System wont produce errors, but wont use the system libraries either. This change produces a clear error in both cases. --- CMake/DolphinLibraryTools.cmake | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/CMake/DolphinLibraryTools.cmake b/CMake/DolphinLibraryTools.cmake index f2305d8399..bedba9dcbd 100644 --- a/CMake/DolphinLibraryTools.cmake +++ b/CMake/DolphinLibraryTools.cmake @@ -50,6 +50,17 @@ function(dolphin_add_bundled_library library use_system bundled_path) add_subdirectory(${bundled_path} EXCLUDE_FROM_ALL) endfunction() +function(dolphin_set_library_type library type) + if(DEFINED ${library}_TYPE AND NOT ${${library}_TYPE} STREQUAL "${type}") + message(FATAL_ERROR + "The selection for ${library} changed from '${${library}_TYPE}' to '${type}' after configuration.\n" + "Please delete the build directory (or at least CMakeCache.txt) and reconfigure." + ) + endif() + + set(${library}_TYPE "${type}" CACHE INTERNAL "") +endfunction() + function(dolphin_find_optional_system_library library bundled_path) dolphin_optional_system_library(use_system ${library}) string(TOUPPER ${library} upperlib) @@ -101,11 +112,11 @@ function(dolphin_find_optional_system_library library bundled_path) endif() endif() if(${prefix}_FOUND) + dolphin_set_library_type(${library} "System") message(STATUS "Using system ${library}") - set(${prefix}_TYPE "System" PARENT_SCOPE) else() + dolphin_set_library_type(${library} "Bundled") dolphin_add_bundled_library(${library} ${use_system} ${bundled_path}) - set(${prefix}_TYPE "Bundled" PARENT_SCOPE) endif() endfunction() @@ -119,11 +130,11 @@ function(dolphin_find_optional_system_library_pkgconfig library search alias bun endif() endif() if(${library}_FOUND) + dolphin_set_library_type(${library} "System") message(STATUS "Using system ${library}") dolphin_alias_library(${alias} PkgConfig::${library}) - set(${library}_TYPE "System" PARENT_SCOPE) else() + dolphin_set_library_type(${library} "Bundled") dolphin_add_bundled_library(${library} ${use_system} ${bundled_path}) - set(${library}_TYPE "Bundled" PARENT_SCOPE) endif() endfunction()