Skip to content

Commit

Permalink
Add CMake option (off by default) to treat compile warnings as errors
Browse files Browse the repository at this point in the history
git-svn-id: svn://tron.homeunix.org/simutrans/simutrans/trunk@11574 8aca7d54-2c30-db11-9de9-000461428c89
  • Loading branch information
ceeac committed Jan 4, 2025
1 parent d9f0b06 commit 7a9d0ae
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion cmake/SimutransCompileOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ if(Fontconfig_FOUND)
option(SIMUTRANS_USE_FONTCONFIG "Use Fontconfig for font autodetection" ON)
endif()

option(SIMUTRANS_WARNINGS_AS_ERRORS "Treat compiler warnings as errors" OFF)
option(SIMUTRANS_INSTALL_PAK64 "Download pak64 on install" OFF)
option(SIMUTRANS_UPDATE_LANGFILES "Update language files from the translator on install" OFF)
option(SIMUTRANS_ENABLE_PROFILING "Enable profiling code" OFF)
Expand Down Expand Up @@ -128,6 +129,10 @@ if (MSVC)
add_definitions(-DNOMINMAX)
add_definitions(-DWIN32_LEAN_AND_MEAN)

if (SIMUTRANS_WARNINGS_AS_ERRORS)
add_compile_options(/WX)
endif ()

if (CMAKE_SIZEOF_VOID_P EQUAL 4)
add_link_options(/LARGEADDRESSAWARE)
endif ()
Expand All @@ -142,7 +147,6 @@ else (MSVC) # Assume GCC/Clang
-Wcast-qual
-Wpointer-arith
-Wcast-align
-Walloca
-Wduplicated-cond
)

Expand All @@ -155,6 +159,10 @@ else (MSVC) # Assume GCC/Clang
-Wno-return-std-move # for squirrel
)

if (SIMUTRANS_WARNINGS_AS_ERRORS)
add_compile_options(-Werror)
endif ()

# only add large address linking to 32 bin windows programs
if (WIN32 AND CMAKE_SIZEOF_VOID_P EQUAL 4)
add_link_options(-Wl,--large-address-aware)
Expand Down

0 comments on commit 7a9d0ae

Please sign in to comment.