Bläddra i källkod

CMake: Fail when -D{PLATFORM,OPENGL_VERSION}=INVALID_VALUE

as well as -DUSE_EXTERNAL_GLFW.

Nips issues like #584 in the bud.
pull/589/head
Ahmad Fatoum 6 år sedan
förälder
incheckning
2b8c9f9a17
Ingen känd nyckel hittad för denna signaturen i databasen GPG-nyckel ID: C3EAC3DE9321D59B
2 ändrade filer med 15 tillägg och 8 borttagningar
  1. +9
    -0
      cmake/EnumOption.cmake
  2. +6
    -8
      src/CMakeOptions.txt

+ 9
- 0
cmake/EnumOption.cmake Visa fil

@ -0,0 +1,9 @@
macro(enum_option var values description)
set(${var}_VALUES ${values})
list(GET ${var}_VALUES 0 default)
set(${var} "${default}" CACHE STRING "${description}")
set_property(CACHE ${var} PROPERTY STRINGS ${${var}_VALUES})
if (NOT ";${${var}_VALUES};" MATCHES ";${${var}};")
message(FATAL_ERROR "Unknown value ${${var}}. Only -D${var}=${${var}_VALUES} allowed.")
endif()
endmacro()

+ 6
- 8
src/CMakeOptions.txt Visa fil

@ -1,11 +1,10 @@
### Config options ###
include(CMakeDependentOption)
include(EnumOption)
set(PLATFORM "Desktop" CACHE STRING "Platform to build for.")
set_property(CACHE PLATFORM PROPERTY STRINGS "Desktop" "Web" "Android" "Raspberry Pi")
enum_option(PLATFORM "Desktop;Web;Android;Raspberry Pi" "Platform to build for.")
set(OPENGL_VERSION "3.3" CACHE STRING "OpenGL Version to build raylib with")
set_property(CACHE OPENGL_VERSION PROPERTY STRINGS "3.3" "2.1" "1.1" "ES 2.0")
enum_option(OPENGL_VERSION "3.3;2.1;1.1;ES 2.0" "OpenGL Version to build raylib with")
# Shared library is always PIC. Static library should be PIC too if linked into a shared library
option(WITH_PIC "Compile static library as position-independent code" OFF)
@ -19,10 +18,9 @@ else()
cmake_dependent_option(USE_OPENAL_BACKEND "Link raylib with openAL instead of mini-al" OFF "USE_AUDIO" OFF)
endif()
set(USE_EXTERNAL_GLFW OFF CACHE STRING "Link raylib against system GLFW instead of embedded one")
set_property(CACHE USE_EXTERNAL_GLFW PROPERTY STRINGS ON OFF IF_POSSIBLE)
enum_option(USE_EXTERNAL_GLFW "OFF;IF_POSSIBLE;ON" "Link raylib against system GLFW instead of embedded one")
if(UNIX AND NOT APPLE)
option(USE_WAYLAND "Use Wayland for window creation" OFF)
option(USE_WAYLAND "Use Wayland for window creation" OFF)
endif()
@ -49,7 +47,7 @@ option(SUPPORT_FILEFORMAT_PNG "Support loading PNG as textures" ON)
option(SUPPORT_FILEFORMAT_DDS "Support loading DDS as textures" ON)
option(SUPPORT_FILEFORMAT_HDR "Support loading HDR as textures" ON)
option(SUPPORT_FILEFORMAT_KTX "Support loading KTX as textures" ON)
option(SUPPORT_FILEFORMAT_ASTC "Support loading ASTC as textures" ON)
option(SUPPORT_FILEFORMAT_ASTC "Support loading ASTC as textures" ON)
option(SUPPORT_FILEFORMAT_BMP "Support loading BMP as textures" OFF)
option(SUPPORT_FILEFORMAT_TGA "Support loading TGA as textures" OFF)
option(SUPPORT_FILEFORMAT_JPG "Support loading JPG as textures" OFF)

Laddar…
Avbryt
Spara