CMake: Fix C standard selection
Vicki Pfau vi@endrift.com
Tue, 26 May 2020 22:09:43 -0700
1 files changed,
8 insertions(+),
5 deletions(-)
jump to
M
CMakeLists.txt
→
CMakeLists.txt
@@ -9,14 +9,17 @@ cmake_policy(SET CMP0072 NEW)
endif() project(mGBA) set(BINARY_NAME mgba CACHE INTERNAL "Name of output binaries") +set(CMAKE_C_STANDARD 99) if(NOT MSVC) - set(GCC_STD "c99") + set(CMAKE_C_STANDARD_REQUIRED ON) + set(CMAKE_C_EXTENSIONS OFF) if(SWITCH) - set(GCC_STD "gnu11") - elseif(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_COMPILER_VERSION VERSION_LESS "4.3") - set(GCC_STD "gnu99") + set(CMAKE_C_STANDARD 11) + set(CMAKE_C_EXTENSIONS ON) + elseif(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS "4.3") + set(CMAKE_C_EXTENSIONS ON) 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() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS /wd4003 /wd4244 /wd4146") endif()