2
0
Эх сурвалжийг харах

Dependency versioning so users are notified when dependency versions change

BearishSun 8 жил өмнө
parent
commit
81cbfec26f

+ 5 - 1
Source/CMake/FindPackageOrBuild.cmake

@@ -25,7 +25,8 @@ function(build_dependency DEPENDENCY_NAME BUILD_CONFIG BUILD_OPTIONS)
 endfunction()
 endfunction()
 
 
 function(find_package_or_build DEPENDENCY_NAME DEPENDENCY_INCLUDE_PATH BUILD_OPTIONS)
 function(find_package_or_build DEPENDENCY_NAME DEPENDENCY_INCLUDE_PATH BUILD_OPTIONS)
-	set(DEPENDENCY_BUILD_DIR "${CMAKE_SOURCE_DIR}/../Dependencies/Build/${DEPENDENCY_NAME}")
+	set(DEPENDENCIES_BUILD_DIR "${CMAKE_SOURCE_DIR}/../Dependencies/Build")
+	set(DEPENDENCY_BUILD_DIR "${DEPENDENCIES_BUILD_DIR}/${DEPENDENCY_NAME}")
 	set(DEPENDENCY_SOURCE_DIR "${CMAKE_SOURCE_DIR}/External/${DEPENDENCY_NAME}")
 	set(DEPENDENCY_SOURCE_DIR "${CMAKE_SOURCE_DIR}/External/${DEPENDENCY_NAME}")
 
 
 	# Look for dependency binaries
 	# Look for dependency binaries
@@ -48,6 +49,9 @@ function(find_package_or_build DEPENDENCY_NAME DEPENDENCY_INCLUDE_PATH BUILD_OPT
 		build_dependency(${DEPENDENCY_NAME} Release ${BUILD_OPTIONS})
 		build_dependency(${DEPENDENCY_NAME} Release ${BUILD_OPTIONS})
 		build_dependency(${DEPENDENCY_NAME} Debug ${BUILD_OPTIONS})
 		build_dependency(${DEPENDENCY_NAME} Debug ${BUILD_OPTIONS})
 		
 		
+		# Update the dependencies version
+		file(WRITE ${DEPENDENCIES_BUILD_DIR}/.version ${BS_DEPENDENCIES_VERSION})
+		
 		# Now try finding the package again, this time it's required
 		# Now try finding the package again, this time it's required
 		find_package(${DEPENDENCY_NAME} REQUIRED)
 		find_package(${DEPENDENCY_NAME} REQUIRED)
 		
 		

+ 5 - 0
Source/CMake/Modules/FindXShaderCompiler.cmake

@@ -26,6 +26,11 @@ list(APPEND XShaderCompiler_LIBRARY_DEBUG_SEARCH_DIRS "${XShaderCompiler_BUILD_D
 
 
 message(STATUS "Looking for XShaderCompiler installation...")
 message(STATUS "Looking for XShaderCompiler installation...")
 	
 	
+# Force the system to always look for files, instead of reading cached entries
+unset(XShaderCompiler_INCLUDE_DIR CACHE)
+unset(XShaderCompiler_LIBRARY_RELEASE CACHE)
+unset(XShaderCompiler_LIBRARY_DEBUG CACHE)
+	
 find_path(XShaderCompiler_INCLUDE_DIR Xsc/Xsc.h PATHS ${XShaderCompiler_INCLUDE_SEARCH_DIRS})
 find_path(XShaderCompiler_INCLUDE_DIR Xsc/Xsc.h PATHS ${XShaderCompiler_INCLUDE_SEARCH_DIRS})
 find_library(XShaderCompiler_LIBRARY_RELEASE NAMES xsc_core PATHS ${XShaderCompiler_LIBRARY_RELEASE_SEARCH_DIRS})
 find_library(XShaderCompiler_LIBRARY_RELEASE NAMES xsc_core PATHS ${XShaderCompiler_LIBRARY_RELEASE_SEARCH_DIRS})
 find_library(XShaderCompiler_LIBRARY_DEBUG NAMES xsc_core PATHS ${XShaderCompiler_LIBRARY_DEBUG_SEARCH_DIRS})
 find_library(XShaderCompiler_LIBRARY_DEBUG NAMES xsc_core PATHS ${XShaderCompiler_LIBRARY_DEBUG_SEARCH_DIRS})

+ 32 - 1
Source/CMakeLists.txt

@@ -5,6 +5,8 @@ project (Banshee)
 set (BS_VERSION_MAJOR 0)
 set (BS_VERSION_MAJOR 0)
 set (BS_VERSION_MINOR 4)
 set (BS_VERSION_MINOR 4)
 
 
+set (BS_DEPENDENCIES_VERSION 1)
+
 # Configuration types
 # Configuration types
 if(CMAKE_CONFIGURATION_TYPES) # Multiconfig generator?
 if(CMAKE_CONFIGURATION_TYPES) # Multiconfig generator?
 	set(CMAKE_CONFIGURATION_TYPES "Debug;OptimizedDebug;Release;" CACHE INTERNAL "") 
 	set(CMAKE_CONFIGURATION_TYPES "Debug;OptimizedDebug;Release;" CACHE INTERNAL "") 
@@ -58,7 +60,35 @@ endif()
 
 
 mark_as_advanced(CMAKE_INSTALL_PREFIX)
 mark_as_advanced(CMAKE_INSTALL_PREFIX)
 
 
-# External code
+# Ensure dependencies are up to date
+## Check prebuilt dependencies that user downloads in a .zip
+set(BUILTIN_DEP_VERSION_FILE ${PROJECT_SOURCE_DIR}/../Dependencies/.version)
+if(NOT EXISTS ${BUILTIN_DEP_VERSION_FILE})
+	message(FATAL_ERROR "Precompiled dependencies package is missing our out of date. Re-run setup or manually re-download and extract dependencies.")
+else()
+	file (STRINGS ${BUILTIN_DEP_VERSION_FILE} CURRENT_BUILTIN_DEP_VERSION)
+	if(${BS_DEPENDENCIES_VERSION} GREATER ${CURRENT_BUILTIN_DEP_VERSION})
+		message(FATAL_ERROR "Your precomiled dependencies package is out of date. Re-run setup or manually re-download and extract dependencies.")
+	endif()
+endif()
+	
+## Check dependencies built from source
+set(SOURCE_DEP_BUILD_DIR ${PROJECT_SOURCE_DIR}/../Dependencies/Build)
+set(SOURCE_DEP_BUILD_VERSION_FILE ${SOURCE_DEP_BUILD_DIR}/.version)
+if(EXISTS ${SOURCE_DEP_BUILD_VERSION_FILE})
+	file (STRINGS ${SOURCE_DEP_BUILD_VERSION_FILE} CURRENT_SOURCE_DEP_VERSION)
+	if(${BS_DEPENDENCIES_VERSION} GREATER ${CURRENT_SOURCE_DEP_VERSION})
+		message(STATUS "Built dependencies are out of date, forcing recompile.")
+		execute_process(COMMAND "${CMAKE_COMMAND}" 
+			-E remove_directory "${SOURCE_DEP_BUILD_DIR}")	
+	endif()
+else()
+	message(STATUS "Built dependencies are out of date, forcing recompile.")
+	execute_process(COMMAND "${CMAKE_COMMAND}" 
+		-E remove_directory "${SOURCE_DEP_BUILD_DIR}")	
+endif()
+
+# Includes required for various find_package calls
 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMake/Modules/")
 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMake/Modules/")
 
 
 # Global compile & linker flags
 # Global compile & linker flags
@@ -157,6 +187,7 @@ else()
 	set(BS_LIBRARY_EXTENSION ".a")
 	set(BS_LIBRARY_EXTENSION ".a")
 endif()
 endif()
 
 
+# Helper functions
 function(add_library_per_config target_name lib_name release_name debug_name)
 function(add_library_per_config target_name lib_name release_name debug_name)
 	add_library(${lib_name} STATIC IMPORTED)
 	add_library(${lib_name} STATIC IMPORTED)
 	set_target_properties(${lib_name} PROPERTIES IMPORTED_LOCATION_DEBUG ${PROJECT_SOURCE_DIR}/../Dependencies/${lib_name}/lib/${BS_OUTPUT_DIR_PREFIX}/${debug_name}${BS_LIBRARY_EXTENSION})
 	set_target_properties(${lib_name} PROPERTIES IMPORTED_LOCATION_DEBUG ${PROJECT_SOURCE_DIR}/../Dependencies/${lib_name}/lib/${BS_OUTPUT_DIR_PREFIX}/${debug_name}${BS_LIBRARY_EXTENSION})