mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-22 09:39:43 +01:00
CMake: Scope C99/C++98 flags to VVVVVV only
Due to a confluence of weird factors, it turns out that PhysFS is compiling with implicit function definitions due to function definitions that get hidden with -std=c99, but not with -std=gnu99 (or the default GCC value of -std=gnu17). Also, due to a recent GCC update (GCC 14), implicit function declarations are actually prohibited with -std=c99 as the C99 standard proscribes. This meant that people started getting build errors in PhysFS code on default settings, which wasn't ideal. To fix this, we will make our -std= flags apply only to VVVVVV source files. In CMake 2.8.12, this can be done with set_source_files_properties. Additionally the flags to disable exceptions and RTTI are scoped down too. Thanks to leo60228 for helping debug and solve this issue. Fixes #1167.
This commit is contained in:
parent
7d01c6bdb0
commit
ff611a56ff
1 changed files with 13 additions and 9 deletions
|
@ -65,7 +65,7 @@ if(NOT WIN32)
|
|||
endif()
|
||||
|
||||
# Source Lists
|
||||
set(VVV_SRC
|
||||
set(VVV_CXX_SRC
|
||||
src/BinaryBlob.cpp
|
||||
src/BlockV.cpp
|
||||
src/ButtonGlyphs.cpp
|
||||
|
@ -108,6 +108,8 @@ set(VVV_SRC
|
|||
src/WarpClass.cpp
|
||||
src/XMLUtils.cpp
|
||||
src/main.cpp
|
||||
)
|
||||
set(VVV_C_SRC
|
||||
src/DeferCallbacks.c
|
||||
src/GlitchrunnerMode.c
|
||||
src/Network.c
|
||||
|
@ -120,12 +122,14 @@ set(VVV_SRC
|
|||
../third_party/physfs/extras/physfsrwops.c
|
||||
)
|
||||
if(STEAM)
|
||||
list(APPEND VVV_SRC src/SteamNetwork.c)
|
||||
list(APPEND VVV_C_SRC src/SteamNetwork.c)
|
||||
endif()
|
||||
if(GOG)
|
||||
list(APPEND VVV_SRC src/GOGNetwork.c)
|
||||
list(APPEND VVV_C_SRC src/GOGNetwork.c)
|
||||
endif()
|
||||
|
||||
set(VVV_SRC ${VVV_CXX_SRC} ${VVV_C_SRC})
|
||||
|
||||
# Executable information
|
||||
if(WIN32)
|
||||
add_executable(VVVVVV WIN32 ${VVV_SRC} icon.rc)
|
||||
|
@ -290,11 +294,11 @@ if(MSVC)
|
|||
# MSVC does not officially support disabling exceptions,
|
||||
# so this is as far as we are willing to go to disable them.
|
||||
string(REGEX REPLACE "/EH[a-z]+" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
|
||||
set_source_files_properties(${VVV_CXX_SRC} PROPERTIES COMPILE_FLAGS /EHsc)
|
||||
|
||||
# Disable RTTI
|
||||
string(REPLACE "/GR" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")
|
||||
set_source_files_properties(${VVV_CXX_SRC} PROPERTIES COMPILE_FLAGS /GR-)
|
||||
|
||||
if(MSVC_VERSION GREATER 1900)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8")
|
||||
|
@ -302,18 +306,18 @@ if(MSVC)
|
|||
endif()
|
||||
else()
|
||||
string(REGEX REPLACE "-std=[a-z0-9]+" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
|
||||
set_source_files_properties(${VVV_C_SRC} PROPERTIES COMPILE_FLAGS -std=c99)
|
||||
|
||||
string(REGEX REPLACE "-std=[a-z0-9+]+" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++98")
|
||||
set_source_files_properties(${VVV_CXX_SRC} PROPERTIES COMPILE_FLAGS -std=c++98)
|
||||
|
||||
# Disable exceptions
|
||||
string(REPLACE "-fexceptions" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
|
||||
set_source_files_properties(${VVV_CXX_SRC} PROPERTIES COMPILE_FLAGS -fno-exceptions)
|
||||
|
||||
# Disable RTTI
|
||||
string(REPLACE "-frtti" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
|
||||
set_source_files_properties(${VVV_CXX_SRC} PROPERTIES COMPILE_FLAGS -fno-rtti)
|
||||
endif()
|
||||
|
||||
# Unfortunately, it doesn't seem like distros package LodePNG
|
||||
|
|
Loading…
Reference in a new issue