mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-17 17:51:13 +00:00
Fix scons SDL version check
0aa8dc3
converted to a runtime test and broke the scons SDL version check since
it only links which trivially makes it work for cross compilation though.
This commit is contained in:
parent
d112ca2339
commit
553b1a4511
|
@ -34,7 +34,7 @@ def CheckSDL2(context, require_version):
|
|||
else:
|
||||
if sdldir:
|
||||
env.AppendUnique(CPPPATH = [os.path.join(sdldir, "include/SDL2")], LIBPATH = [os.path.join(sdldir, "lib")])
|
||||
env.AppendUnique(CCFLAGS = ["-D_GNU_SOURCE"])
|
||||
env.AppendUnique(CCFLAGS = ["-D_GNU_SOURCE", "-DREQ_MAJOR="+major_version, "-DREQ_MINOR="+minor_version, "-DREQ_PATCH="+patchlevel])
|
||||
env.AppendUnique(LIBS = Split("mingw32 SDL2main SDL2"))
|
||||
env.AppendUnique(LINKFLAGS = ["-mwindows", "-fstack-protector"])
|
||||
|
||||
|
@ -43,7 +43,7 @@ def CheckSDL2(context, require_version):
|
|||
cpp_file = "src/conftests/sdl2.cpp"
|
||||
|
||||
with open(cpp_file, 'r') as file:
|
||||
test_program = file.read().replace("argv[1]", "\""+major_version+"\"").replace("argv[2]", "\""+minor_version+"\"").replace("argv[3]", "\""+patchlevel+"\"")
|
||||
test_program = file.read()
|
||||
|
||||
if context.TryLink(test_program, ".cpp"):
|
||||
context.Result("yes")
|
||||
|
|
|
@ -13,19 +13,17 @@
|
|||
*/
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
|
||||
#define STR(x) STR_(x)
|
||||
#define STR_(x) #x
|
||||
|
||||
#if ! SDL_VERSION_ATLEAST(REQ_MAJOR, REQ_MINOR, REQ_PATCH)
|
||||
#pragma message "SDL version " STR(SDL_MAJOR_VERSION.SDL_MINOR_VERSION.SDL_PATCHLEVEL) " is older than required version " STR(REQ_MAJOR.REQ_MINOR.REQ_PATCH)
|
||||
#error SDL is too old!
|
||||
#endif
|
||||
|
||||
int main(int, char** argv)
|
||||
{
|
||||
int major = std::stoi(argv[1]);
|
||||
int minor = std::stoi(argv[2]);
|
||||
int patchlevel = std::stoi(argv[3]);
|
||||
|
||||
if(!SDL_VERSION_ATLEAST(major, minor, patchlevel)) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
SDL_Init(0);
|
||||
SDL_Quit();
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user