From 50b7df5b241a3f62a2dcdcfa6ab9bf36c15fe2fe Mon Sep 17 00:00:00 2001 From: HarpyWar Date: Sun, 6 Jul 2014 20:37:11 +0400 Subject: [PATCH] * supress gcc variadic warnings * shorthand of format usage https://github.com/cppformat/cppformat/issues/49#issuecomment-48116104 --- CMakeLists.txt | 26 ++++++++++++++++++++++++++ files/CMakeLists.txt | 6 +----- src/bnetd/i18n.cpp | 4 +--- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ed0a373..ae27ad4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,32 @@ option(WITH_PGSQL "include PostgreSQL user accounts support" OFF) option(WITH_ODBC "include ODBC user accounts support" OFF) include(ConfigureChecks.cmake) + +if (CMAKE_COMPILER_IS_GNUCXX) + # Determine GCC version. + message("Determining GCC version.") + EXEC_PROGRAM(${CMAKE_CXX_COMPILER} + ARGS --version + OUTPUT_VARIABLE _GCC_VERSION) + STRING(REGEX REPLACE ".* ([0-9])\\.([0-9])\\.([0-9]) .*" "\\1\\2\\3" + _GCC_VERSION ${_GCC_VERSION}) + message(" GCC version is ${_GCC_VERSION}") + + # Add -Wno-longlong if the GCC version is < 4.0.0. Add -pedantic flag + # but disable warnings for variadic macros with GCC >= 4.0.0. Earlier + # versions warn because of anonymous variadic macros in pedantic mode + # but do not have a flag to disable these warnings. + if (400 GREATER _GCC_VERSION) + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-long-long") + else (400 GREATER _GCC_VERSION) + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wno-variadic-macros") + endif (400 GREATER _GCC_VERSION) + + # Pass CXX flags to flags. + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSEQAN_CXX_FLAGS_=\"${CMAKE_CXX_FLAGS}\"") +endif (CMAKE_COMPILER_IS_GNUCXX) + + subdirs(src conf man files) if(WITH_LUA) add_subdirectory(lua) diff --git a/files/CMakeLists.txt b/files/CMakeLists.txt index e95d55a..e38e96e 100644 --- a/files/CMakeLists.txt +++ b/files/CMakeLists.txt @@ -17,11 +17,7 @@ file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/var/status") install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/var/ DESTINATION ${LOCALSTATEDIR}) install(FILES ad000001.mng ad000001.smk ad000002.mng ad000003.mng - ad000004.mng ad000075.mng chathelp-war3-default.txt - chathelp-war3-enUS.txt chathelp-war3-frFR.txt chathelp-war3-ruRU.txt - chathelp-war3-zhCN.txt newaccount-default.txt newaccount-enUS.txt - newbie.save termsofservice-default.txt termsofservice-enUS.txt - tos_default.txt tos-unicode_default.txt + ad000004.mng ad000075.mng newbie.save bnserver.ini bnserver-D2DV.ini bnserver-D2XP.ini bnserver-WAR3.ini ver-ix86-1.mpq IX86ver1.mpq PMACver1.mpq XMACver1.mpq icons.bni icons_STAR.bni icons-WAR3.bni diff --git a/src/bnetd/i18n.cpp b/src/bnetd/i18n.cpp index b489685..a80f064 100644 --- a/src/bnetd/i18n.cpp +++ b/src/bnetd/i18n.cpp @@ -184,9 +184,7 @@ namespace pvpgn if (!(format = _find_string(fmt, lang))) format = fmt; - fmt::Writer out; - out.write(format, args); - output = out.str(); + output = fmt::format(format, args); } catch (const std::exception& e) {