error if mod target geode version does not match the sdk version

This commit is contained in:
altalk23 2024-04-12 23:02:28 +03:00
parent 2db4834fff
commit 2c559f8c5c
2 changed files with 11 additions and 0 deletions

View file

@ -18,6 +18,7 @@ option(GEODE_USE_BREAKPAD "Enables the use of the Breakpad library for crash dum
# Read version
file(READ VERSION GEODE_VERSION)
string(STRIP "${GEODE_VERSION}" GEODE_VERSION)
set(GEODE_VERSION "${GEODE_VERSION}" CACHE INTERNAL "Geode version")
# Check if version has a tag like v1.0.0-alpha
string(FIND ${GEODE_VERSION} "-" GEODE_VERSION_HAS_TAG)

View file

@ -86,9 +86,19 @@ function(setup_geode_mod proname)
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/mod.json" MOD_JSON)
string(JSON MOD_ID GET "${MOD_JSON}" "id")
string(JSON MOD_VERSION GET "${MOD_JSON}" "version")
string(JSON TARGET_GEODE_VERSION GET "${MOD_JSON}" "geode")
string(JSON MOD_HAS_API ERROR_VARIABLE MOD_DOESNT_HAVE_API GET "${MOD_JSON}" "api")
string(JSON MOD_HAS_DEPS ERROR_VARIABLE MOD_DOESNT_HAVE_DEPS GET "${MOD_JSON}" "dependencies")
if ("${TARGET_GEODE_VERSION}" STREQUAL "${GEODE_VERSION}")
message(STATUS "Mod ${MOD_ID} is compiling for Geode version ${GEODE_VERSION}")
else()
message(FATAL_ERROR
"Mod ${MOD_ID} is not compatible with Geode version ${GEODE_VERSION} - "
"it was made for version ${TARGET_GEODE_VERSION}"
)
endif()
# Add this mod to the list of known externals mods
list(APPEND GEODE_MODS_BEING_BUILT "${MOD_ID}:${MOD_VERSION}")
# Ensure that the list of mods being built is global (persists between setup_geode_mod calls)