Pārlūkot izejas kodu

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

pull/3922/head
Benji pirms 1 gada
committed by GitHub
vecāks
revīzija
c1fd98591d
Šim parakstam datu bāzē netika atrasta zināma atslēga GPG atslēgas ID: B5690EEEBB952194
3 mainītis faili ar 22 papildinājumiem un 4 dzēšanām
  1. +4
    -1
      CMakeLists.txt
  2. +1
    -0
      CMakeOptions.txt
  3. +17
    -3
      examples/CMakeLists.txt

+ 4
- 1
CMakeLists.txt Parādīt failu

@ -59,7 +59,10 @@ if(NOT TARGET uninstall)
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
endif() endif()
if (${BUILD_EXAMPLES})
if (NOT ${BUILD_EXAMPLE} STREQUAL "")
MESSAGE(STATUS "Building example '${BUILD_EXAMPLE}'")
add_subdirectory(examples)
elseif (${BUILD_EXAMPLES})
MESSAGE(STATUS "Building examples is enabled") MESSAGE(STATUS "Building examples is enabled")
add_subdirectory(examples) add_subdirectory(examples)
endif() endif()

+ 1
- 0
CMakeOptions.txt Parādīt failu

@ -8,6 +8,7 @@ enum_option(OPENGL_VERSION "OFF;4.3;3.3;2.1;1.1;ES 2.0;ES 3.0" "Force a specific
# Configuration options # Configuration options
option(BUILD_EXAMPLES "Build the examples." ${RAYLIB_IS_MAIN}) option(BUILD_EXAMPLES "Build the examples." ${RAYLIB_IS_MAIN})
option(BUILD_EXAMPLE "Build a specific example by filename." "")
option(CUSTOMIZE_BUILD "Show options for customizing your Raylib library build." OFF) option(CUSTOMIZE_BUILD "Show options for customizing your Raylib library build." OFF)
option(ENABLE_ASAN "Enable AddressSanitizer (ASAN) for debugging (degrades performance)" OFF) option(ENABLE_ASAN "Enable AddressSanitizer (ASAN) for debugging (degrades performance)" OFF)
option(ENABLE_UBSAN "Enable UndefinedBehaviorSanitizer (UBSan) for debugging" OFF) option(ENABLE_UBSAN "Enable UndefinedBehaviorSanitizer (UBSan) for debugging" OFF)

+ 17
- 3
examples/CMakeLists.txt Parādīt failu

@ -48,10 +48,24 @@ endif ()
# into a CMake variable # into a CMake variable
set(example_sources) set(example_sources)
set(example_resources) set(example_resources)
set(example_found FALSE)
foreach (example_dir ${example_dirs}) 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 # Any any resources
file(GLOB resources ${example_dir}/resources/*) file(GLOB resources ${example_dir}/resources/*)

Notiek ielāde…
Atcelt
Saglabāt