@@ -363,114 +363,3 @@ However, by default CMake builds static libraries as non-relocatable.
363
363
Configuring SDL with `-DCMAKE_POSITION_INDEPENDENT_CODE=ON` will result in a static `libSDL3.a` library
364
364
which you can link against to create a shared library.
365
365
366
- ## Help, it doesn' t work!
367
-
368
- Below, a SDL3 CMake project can be found that builds 99.9% of time (assuming you have internet connectivity).
369
- When you have a problem with building or using SDL, please modify it until it reproduces your issue.
370
-
371
- ` ` ` cmake
372
- cmake_minimum_required(VERSION 3.16)
373
- project(sdl_issue)
374
-
375
- # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
376
- # !!!!!! !!!!!!
377
- # !!!!!! This CMake script is not using "CMake best practices". !!!!!!
378
- # !!!!!! Don't use it in your project. !!!!!!
379
- # !!!!!! !!!!!!
380
- # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
381
-
382
- # 1. Try system SDL3 package first
383
- find_package(SDL3 QUIET)
384
- if(SDL3_FOUND)
385
- message(STATUS " Using SDL3 via find_package" )
386
- endif ()
387
-
388
- # 2. Try using a vendored SDL library
389
- if(NOT SDL3_FOUND AND EXISTS " ${CMAKE_CURRENT_LIST_DIR} /SDL/CMakeLists.txt" )
390
- add_subdirectory(SDL EXCLUDE_FROM_ALL)
391
- message(STATUS " Using SDL3 via add_subdirectory" )
392
- set(SDL3_FOUND TRUE)
393
- endif ()
394
-
395
- # 3. Download SDL, and use that.
396
- if(NOT SDL3_FOUND)
397
- include(FetchContent)
398
- set(SDL_SHARED TRUE CACHE BOOL " Build a SDL shared library (if available)" )
399
- set(SDL_STATIC TRUE CACHE BOOL " Build a SDL static library (if available)" )
400
- FetchContent_Declare(
401
- SDL
402
- GIT_REPOSITORY https://github.com/libsdl-org/SDL.git
403
- GIT_TAG main # Replace this with a particular git tag or git hash
404
- GIT_SHALLOW TRUE
405
- GIT_PROGRESS TRUE
406
- )
407
- message(STATUS " Using SDL3 via FetchContent" )
408
- FetchContent_MakeAvailable(SDL)
409
- set_property(DIRECTORY " ${CMAKE_CURRENT_BINARY_DIR} /_deps/sdl-src" PROPERTY EXCLUDE_FROM_ALL TRUE)
410
- endif ()
411
-
412
- file(WRITE main.c [=========================================== [
413
- /**
414
- * Modify this source such that it reproduces your problem.
415
- * /
416
-
417
- /* START of source modifications * /
418
-
419
- # include <SDL3/SDL.h>
420
- /*
421
- * SDL3/SDL_main.h is explicitly not included such that a terminal window would appear on Windows.
422
- * /
423
-
424
- int main(int argc, char * argv[]) {
425
- (void)argc;
426
- (void)argv;
427
-
428
- if (! SDL_Init(SDL_INIT_VIDEO)) {
429
- SDL_Log(" SDL_Init failed (%s)" , SDL_GetError ());
430
- return 1;
431
- }
432
-
433
- SDL_Window * window = NULL;
434
- SDL_Renderer * renderer = NULL;
435
-
436
- if (! SDL_CreateWindowAndRenderer(" SDL issue" , 640, 480, 0, & window, & renderer)) {
437
- SDL_Log(" SDL_CreateWindowAndRenderer failed (%s)" , SDL_GetError ());
438
- SDL_Quit ();
439
- return 1;
440
- }
441
-
442
- while (1) {
443
- int finished = 0;
444
- SDL_Event event;
445
- while (SDL_PollEvent(& event)) {
446
- if (event.type == SDL_EVENT_QUIT) {
447
- finished = 1;
448
- break ;
449
- }
450
- }
451
- if (finished) {
452
- break ;
453
- }
454
-
455
- SDL_SetRenderDrawColor(renderer, 80, 80, 80, SDL_ALPHA_OPAQUE);
456
- SDL_RenderClear(renderer);
457
- SDL_RenderPresent(renderer);
458
- }
459
-
460
- SDL_DestroyRenderer(renderer);
461
- SDL_DestroyWindow(window);
462
-
463
- SDL_Quit ();
464
- return 0;
465
- }
466
-
467
- /* END of source modifications * /
468
-
469
- ]===========================================])
470
-
471
- add_executable(sdl_issue main.c)
472
-
473
- target_link_libraries(sdl_issue PRIVATE SDL3::SDL3)
474
- # target_link_libraries(sdl_issue PRIVATE SDL3::SDL3-shared)
475
- # target_link_libraries(sdl_issue PRIVATE SDL3::SDL3-static)
476
- ` ` `
0 commit comments