Build specific example using -DBUILD_EXAMPLE cmake flag (#3921)

This commit is contained in:
Benji 2024-04-17 13:26:18 -04:00 committed by GitHub
parent 112ce672e1
commit c1fd98591d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 22 additions and 4 deletions

View file

@ -48,10 +48,24 @@ endif ()
# into a CMake variable
set(example_sources)
set(example_resources)
set(example_found FALSE)
foreach (example_dir ${example_dirs})
# Get the .c files
file(GLOB sources ${example_dir}/*.c)
list(APPEND example_sources ${sources})
if (BUILD_EXAMPLE)
if (NOT example_found)
file(GLOB sources ${example_dir}/${BUILD_EXAMPLE}.c)
if (EXISTS ${sources})
list(APPEND example_sources ${sources})
set(example_found TRUE)
message("Raylib example '${BUILD_EXAMPLE}.c' found in ${example_dir}!")
else()
message("Raylib example '${BUILD_EXAMPLE}.c' not found in ${example_dir}...")
endif()
endif()
else()
# Get the .c files
file(GLOB sources ${example_dir}/*.c)
list(APPEND example_sources ${sources})
endif()
# Any any resources
file(GLOB resources ${example_dir}/resources/*)