@@ -334,7 +334,41 @@ if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
334334 install (FILES ${GSKIT_PC} DESTINATION "${INSTALL_PKGCONFIG_DIR} " )
335335endif ()
336336
337- if (NOT SKIP_BUILD_EXAMPLES)
337+ # All available examples
338+ set (GSKIT_SAMPLE_DIRS
339+ alpha
340+ atlas
341+ basic
342+ bigtex
343+ coverflow
344+ clut
345+ clutcsm
346+ cube
347+ fb
348+ fhdbg
349+ font
350+ fontm
351+ modetest
352+ modetesthires
353+ pixelperfect
354+ texstream
355+ textures
356+ vsync
357+ )
358+ set (GSKIT_SPECIAL_EXAMPLES hires linuz-texture png-texture)
359+ set (GSKIT_ALL_EXAMPLES ${GSKIT_SAMPLE_DIRS} ${GSKIT_SPECIAL_EXAMPLES} )
360+
361+ # Option to build specific examples (empty list = skip all, default = build all)
362+ set (BUILD_EXAMPLES "${GSKIT_ALL_EXAMPLES} " CACHE STRING "List of examples to build (e.g., -DBUILD_EXAMPLES='atlas;cube'). Empty list skips all examples." )
363+
364+ if (BUILD_EXAMPLES)
365+ # Validate requested examples
366+ foreach (example IN LISTS BUILD_EXAMPLES)
367+ if (NOT example IN_LIST GSKIT_ALL_EXAMPLES)
368+ message (FATAL_ERROR "Example '${example} ' not found. Available examples: ${GSKIT_ALL_EXAMPLES} " )
369+ endif ()
370+ endforeach ()
371+
338372 set (CMAKE_EXECUTABLE_SUFFIX .elf)
339373 set (GSKIT_SAMPLE_LIBS "" )
340374 list (APPEND GSKIT_SAMPLE_LIBS gskit_toolkit gskit dmakit ${GSKIT_EXTERNAL_LIBS} )
@@ -349,70 +383,70 @@ if(NOT SKIP_BUILD_EXAMPLES)
349383 file (COPY ${CMAKE_CURRENT_SOURCE_DIR} /examples/${targetname} / DESTINATION ${CMAKE_CURRENT_BINARY_DIR} FILES_MATCHING REGEX "\\ .(bmp|dat|fnt|jpg|png|ppm|raw|s|tiff)$" )
350384 endmacro (add_executable_example)
351385
352- set (GSKIT_SAMPLE_DIRS "" )
353- list (APPEND GSKIT_SAMPLE_DIRS
354- alpha
355- atlas
356- basic
357- bigtex
358- coverflow
359- clut
360- clutcsm
361- cube
362- fb
363- fhdbg
364- font
365- fontm
366- modetest
367- modetesthires
368- pixelperfect
369- texstream
370- textures
371- vsync
372- )
373-
374- foreach (arg IN ITEMS ${GSKIT_SAMPLE_DIRS} )
375- add_executable_example(${arg} )
386+ # Build standard examples from the list
387+ foreach (example IN LISTS BUILD_EXAMPLES)
388+ if (example IN_LIST GSKIT_SAMPLE_DIRS)
389+ add_executable_example(${example} )
390+ endif ()
376391 endforeach ()
377392
378- target_link_libraries (cube
379- draw
380- math3d
381- )
382- set_property (TARGET modetest APPEND PROPERTY SOURCES examples/modetest/pad.c)
383- target_link_libraries (modetest
384- pad
385- )
386- set_property (TARGET modetesthires APPEND PROPERTY SOURCES examples/modetesthires/pad.c)
387- target_link_libraries (modetesthires
388- pad
389- )
393+ # Additional configuration for specific examples
394+ if (TARGET cube)
395+ target_link_libraries (cube
396+ draw
397+ math3d
398+ )
399+ endif ()
390400
391- add_executable (hires
392- examples/hires/main.c
393- )
394- target_link_libraries (hires
395- ${GSKIT_SAMPLE_LIBS}
396- draw
397- graph
398- math3d
399- packet
400- dma
401- )
401+ if (TARGET modetest)
402+ set_property (TARGET modetest APPEND PROPERTY SOURCES examples/modetest/pad.c)
403+ target_link_libraries (modetest
404+ pad
405+ )
406+ endif ()
402407
403- add_executable (linuz-texture
404- examples/linuz-texture/sample.c
405- examples/linuz-texture/testorig.s
406- examples/linuz-texture/texture.c
407- )
408- target_link_libraries (linuz-texture
409- ${GSKIT_SAMPLE_LIBS}
410- )
408+ if (TARGET modetesthires)
409+ set_property (TARGET modetesthires APPEND PROPERTY SOURCES examples/modetesthires/pad.c)
410+ target_link_libraries (modetesthires
411+ pad
412+ )
413+ endif ()
411414
412- add_executable (png-texture
413- examples/png-texture/textures.c
414- )
415- target_link_libraries (png-texture
416- ${GSKIT_SAMPLE_LIBS}
417- )
415+ # Special examples with custom source configurations
416+ if ("hires" IN_LIST BUILD_EXAMPLES)
417+ add_executable (hires
418+ examples/hires/main.c
419+ )
420+ target_link_libraries (hires
421+ ${GSKIT_SAMPLE_LIBS}
422+ draw
423+ graph
424+ math3d
425+ packet
426+ dma
427+ )
428+ file (COPY ${CMAKE_CURRENT_SOURCE_DIR} /examples/hires/ DESTINATION ${CMAKE_CURRENT_BINARY_DIR} FILES_MATCHING REGEX "\\ .(bmp|dat|fnt|jpg|png|ppm|raw|s|tiff)$" )
429+ endif ()
430+
431+ if ("linuz-texture" IN_LIST BUILD_EXAMPLES)
432+ add_executable (linuz-texture
433+ examples/linuz-texture/sample.c
434+ examples/linuz-texture/testorig.s
435+ examples/linuz-texture/texture.c
436+ )
437+ target_link_libraries (linuz-texture
438+ ${GSKIT_SAMPLE_LIBS}
439+ )
440+ file (COPY ${CMAKE_CURRENT_SOURCE_DIR} /examples/linuz-texture/ DESTINATION ${CMAKE_CURRENT_BINARY_DIR} FILES_MATCHING REGEX "\\ .(bmp|dat|fnt|jpg|png|ppm|raw|s|tiff)$" )
441+ endif ()
442+
443+ if ("png-texture" IN_LIST BUILD_EXAMPLES)
444+ add_executable (png-texture
445+ examples/png-texture/textures.c
446+ )
447+ target_link_libraries (png-texture
448+ ${GSKIT_SAMPLE_LIBS}
449+ )
450+ file (COPY ${CMAKE_CURRENT_SOURCE_DIR} /examples/png-texture/ DESTINATION ${CMAKE_CURRENT_BINARY_DIR} FILES_MATCHING REGEX "\\ .(bmp|dat|fnt|jpg|png|ppm|raw|s|tiff)$" )
451+ endif ()
418452endif ()
0 commit comments