summaryrefslogtreecommitdiff
path: root/CMake
diff options
context:
space:
mode:
authorJoshua Vandaƫle <joshua@vandaele.software>2025-12-24 03:59:15 +0100
committerJoshua Vandaƫle <joshua@vandaele.software>2026-02-25 07:25:29 +0100
commit11065e99114e95bab4b617fa9b50ceb43019adee (patch)
treebb7e64ac252ba6c867971891d0699897f4632750 /CMake
parent2a3078b833fe3d7b199b833fb4dfc08111d44dd7 (diff)
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.
Diffstat (limited to 'CMake')
-rw-r--r--CMake/DolphinLibraryTools.cmake19
1 files 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()