1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-01 02:23:32 +02:00

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.)
This commit is contained in:
Misa 2021-04-16 16:40:08 -07:00 committed by Ethan Lee
parent c17ea40866
commit ce4dc7e7bc

View File

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