CMake: Fix C standard selection

This commit is contained in:
Vicki Pfau 2020-05-26 22:09:43 -07:00
parent 11ccbca4ff
commit 691c202c40
1 changed files with 8 additions and 5 deletions

View File

@ -9,14 +9,17 @@ if(POLICY CMP0072)
endif() endif()
project(mGBA) project(mGBA)
set(BINARY_NAME mgba CACHE INTERNAL "Name of output binaries") set(BINARY_NAME mgba CACHE INTERNAL "Name of output binaries")
set(CMAKE_C_STANDARD 99)
if(NOT MSVC) if(NOT MSVC)
set(GCC_STD "c99") set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)
if(SWITCH) if(SWITCH)
set(GCC_STD "gnu11") set(CMAKE_C_STANDARD 11)
elseif(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_COMPILER_VERSION VERSION_LESS "4.3") set(CMAKE_C_EXTENSIONS ON)
set(GCC_STD "gnu99") elseif(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS "4.3")
set(CMAKE_C_EXTENSIONS ON)
endif() endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-missing-field-initializers -std=${GCC_STD}") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-missing-field-initializers")
else() else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS /wd4003 /wd4244 /wd4146") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS /wd4003 /wd4244 /wd4146")
endif() endif()