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

as well as -DUSE_EXTERNAL_GLFW.

Nips issues like #584 in the bud.
This commit is contained in:
Ahmad Fatoum 2018-07-23 20:42:19 +02:00
parent 1d0ba96c9e
commit 2b8c9f9a17
No known key found for this signature in database
GPG key ID: C3EAC3DE9321D59B
2 changed files with 15 additions and 8 deletions

9
cmake/EnumOption.cmake Normal file
View file

@ -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()