From ce4dc7e7bc64239ef372e88120dd8b9619e5b5d3 Mon Sep 17 00:00:00 2001 From: Misa Date: Fri, 16 Apr 2021 16:40:08 -0700 Subject: [PATCH] Set C standard to C90 in CMake file All the C third-party dependencies are C90, and all the C files we have are also C90 (well, almost, but that's easily sorted). So we have basically no reason to not go with C90 here. The only wrinkle is, turning C extensions off for physfs-static results in linker errors because PhysFS implicitly uses alloca() without including it properly (on Linux). I am not the only one who has ran into this - see https://icculus.org/pipermail/physfs/2020-April/001293.html - and it's a bug with PhysFS. The workaround I've gone with is to enable C extensions. (There might also be some funkiness with PhysFS's use of the `inline` keyword, so enabling extensions will paper over that as well.) --- desktop_version/CMakeLists.txt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/desktop_version/CMakeLists.txt b/desktop_version/CMakeLists.txt index 7bdb96ce..0e9e5f4a 100644 --- a/desktop_version/CMakeLists.txt +++ b/desktop_version/CMakeLists.txt @@ -29,8 +29,11 @@ if(MAKEANDPLAY) endif() if(${CMAKE_VERSION} VERSION_LESS "3.1.3") - message(WARNING "Your CMake version is too old; set -std=c++98 yourself!") + message(WARNING "Your CMake version is too old; set -std=c90 -std=c++98 yourself!") else() + set(CMAKE_C_STANDARD 90) + set(CMAKE_C_EXTENSIONS OFF) + set(CMAKE_CXX_STANDARD 98) set(CMAKE_CXX_EXTENSIONS OFF) endif() @@ -256,6 +259,12 @@ if(BUNDLE_DEPENDENCIES) add_library(tinyxml2-static STATIC ${XML2_SRC}) add_library(physfs-static STATIC ${PFS_SRC} ${PFSP_SRC}) + # PhysFS needs some extensions... + if(${CMAKE_VERSION} VERSION_GREATER "3.1.3" + OR ${CMAKE_VERSION} VERSION_EQUAL "3.1.3") + set_property(TARGET physfs-static PROPERTY C_EXTENSIONS ON) + endif() + target_link_libraries(VVVVVV physfs-static tinyxml2-static lodepng-static) else() find_package(utf8cpp CONFIG)