Skip to content

Commit

Permalink
Adds -Wold-style-cast to the CMake strict flags.
Browse files Browse the repository at this point in the history
  • Loading branch information
mordante committed Feb 14, 2014
1 parent 0504f6c commit 8a1ff1e
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 17 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Expand Up @@ -303,6 +303,12 @@ if(NOT CMAKE_COMPILER_IS_GNUCXX)
)
endif(NOT CMAKE_COMPILER_IS_GNUCXX)

check_compiler_has_flag(
CXX_FLAGS_STRICT_COMPILATION
"-Wold-style-cast"
HAS_COMPILER_FLAG_WOLD_STYLE_CAST
)

check_compiler_has_flag(
CXX_FLAGS_STRICT_COMPILATION
"-Wdeprecated-register"
Expand Down
1 change: 1 addition & 0 deletions changelog
Expand Up @@ -26,6 +26,7 @@ Version 1.11.9+dev:
condition that always yields true or false, respectively.
* Miscellaneous and bug fixes:
* Fixed: A compilation warning with DEBUG_WINDOW_LAYOUT_GRAPHS.
* Added -Wold-style-cast to the CMake strict flags.

Version 1.11.9:
* Add-ons client:
Expand Down
50 changes: 33 additions & 17 deletions src/CMakeLists.txt
Expand Up @@ -316,25 +316,41 @@ add_library(wesnoth-lua ${LIBRARY_TYPE} EXCLUDE_FROM_ALL ${libwesnoth-lua_STAT_S

# Disable the setting of -Wold-style-cast on some targets.
# old style casts are not wanted by our coding style but some C based code
# uses it. Force the flag off for these files. (We don't enable it in our
# generic compiler flags, but allows people to do it.)
if(CMAKE_COMPILER_IS_GNUCXX)
set_target_properties(wesnoth-lua
PROPERTIES COMPILE_FLAGS
"-Wno-old-style-cast -Wno-useless-cast"
)
set_source_files_properties(
clipboard.cpp
network.cpp
network_worker.cpp
PROPERTIES
COMPILE_FLAGS "-Wno-old-style-cast")
# uses it. Force the flag off for these files.
if(HAS_COMPILER_FLAG_WOLD_STYLE_CAST)
set(CXX_FLAG_NO_OLD_STYLE_CAST "-Wno-old-style-cast")
endif()

if(HAS_COMPILER_FLAG_WUSELESS_CAST)
set(CXX_FLAG_NO_USELESS_CAST "-Wno-useless-cast")
endif()

set_target_properties(wesnoth-lua
PROPERTIES
COMPILE_FLAGS
"${CXX_FLAG_NO_OLD_STYLE_CAST} ${CXX_FLAG_NO_USELESS_CAST}"
)
set_source_files_properties(
clipboard.cpp
network.cpp
network_worker.cpp
PROPERTIES
COMPILE_FLAGS "${CXX_FLAG_NO_OLD_STYLE_CAST}"
)
set_source_files_properties(
desktop_util.cpp
text.cpp
PROPERTIES
COMPILE_FLAGS
"${CXX_FLAG_NO_OLD_STYLE_CAST} ${CXX_FLAG_NO_USELESS_CAST}"
)
if(LIBDBUS_FOUND)
set_source_files_properties(
desktop_util.cpp
text.cpp
game_display.cpp
PROPERTIES
COMPILE_FLAGS "-Wno-old-style-cast -Wno-useless-cast")
endif(CMAKE_COMPILER_IS_GNUCXX)
COMPILE_FLAGS "${CXX_FLAG_NO_OLD_STYLE_CAST}"
)
endif()

########### Helper libraries ###############

Expand Down

0 comments on commit 8a1ff1e

Please sign in to comment.