Added -Wextra and -Werror option for gcc and clang.

Reformatted and untabified configure.in.
This commit is contained in:
Takatoshi Kondo 2015-05-19 16:03:58 +09:00
parent 432c9cc542
commit aee537099d
3 changed files with 53 additions and 53 deletions

View File

@ -196,8 +196,8 @@ IF (MSGPACK_BUILD_TESTS)
ENDIF () ENDIF ()
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
SET_PROPERTY (TARGET msgpack APPEND_STRING PROPERTY COMPILE_FLAGS "-Wall -g -O3 -DPIC") SET_PROPERTY (TARGET msgpack APPEND_STRING PROPERTY COMPILE_FLAGS "-Wall -Wextra -Werror -g -O3 -DPIC")
SET_PROPERTY (TARGET msgpack-static APPEND_STRING PROPERTY COMPILE_FLAGS "-Wall -g -O3" ) SET_PROPERTY (TARGET msgpack-static APPEND_STRING PROPERTY COMPILE_FLAGS "-Wall -Wextra -Werror -g -O3" )
ENDIF () ENDIF ()
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
IF (CMAKE_CXX_FLAGS MATCHES "/W[0-4]") IF (CMAKE_CXX_FLAGS MATCHES "/W[0-4]")

View File

@ -3,10 +3,10 @@ AC_CONFIG_AUX_DIR(ac)
AM_INIT_AUTOMAKE AM_INIT_AUTOMAKE
AC_CONFIG_HEADER(config.h) AC_CONFIG_HEADER(config.h)
AC_SUBST(CFLAGS) AC_SUBST(CFLAGS)
CFLAGS="-O3 -Wall $CFLAGS" CFLAGS="-O3 -Wall -Wextra -Werror $CFLAGS"
AC_SUBST(CXXFLAGS) AC_SUBST(CXXFLAGS)
CXXFLAGS="-O3 -Wall $CXXFLAGS" CXXFLAGS="-O3 -Wall -Wextra -Werror $CXXFLAGS"
AC_PROG_CC AC_PROG_CC
@ -14,12 +14,12 @@ AC_PROG_CC
AC_MSG_CHECKING([if C++ API is enabled]) AC_MSG_CHECKING([if C++ API is enabled])
AC_ARG_ENABLE(cxx, AC_ARG_ENABLE(cxx,
AS_HELP_STRING([--disable-cxx], AS_HELP_STRING([--disable-cxx],
[don't build C++ API]) ) #' [don't build C++ API]) ) #'
AC_MSG_RESULT([$enable_cxx]) AC_MSG_RESULT([$enable_cxx])
if test "$enable_cxx" != "no"; then if test "$enable_cxx" != "no"; then
AC_PROG_CXX AC_PROG_CXX
AM_PROG_CC_C_O AM_PROG_CC_C_O
fi fi
AM_CONDITIONAL(ENABLE_CXX, test "$enable_cxx" != "no") AM_CONDITIONAL(ENABLE_CXX, test "$enable_cxx" != "no")
@ -30,56 +30,56 @@ AM_PROG_AS
AC_MSG_CHECKING([if debug option is enabled]) AC_MSG_CHECKING([if debug option is enabled])
AC_ARG_ENABLE(debug, AC_ARG_ENABLE(debug,
AS_HELP_STRING([--disable-debug], AS_HELP_STRING([--disable-debug],
[disable assert macros and omit -g option]) ) [disable assert macros and omit -g option]) )
AC_MSG_RESULT([$enable_debug]) AC_MSG_RESULT([$enable_debug])
if test "$enable_debug" != "no"; then if test "$enable_debug" != "no"; then
CXXFLAGS="$CXXFLAGS -g" CXXFLAGS="$CXXFLAGS -g"
CFLAGS="$CFLAGS -g" CFLAGS="$CFLAGS -g"
else else
CXXFLAGS="$CXXFLAGS -DNDEBUG" CXXFLAGS="$CXXFLAGS -DNDEBUG"
CFLAGS="$CFLAGS -DNDEBUG" CFLAGS="$CFLAGS -DNDEBUG"
fi fi
AC_CACHE_CHECK([for __sync_* atomic operations], msgpack_cv_atomic_ops, [ AC_CACHE_CHECK([for __sync_* atomic operations], msgpack_cv_atomic_ops, [
AC_TRY_LINK([ AC_TRY_LINK([
int atomic_sub(int i) { return __sync_sub_and_fetch(&i, 1); } int atomic_sub(int i) { return __sync_sub_and_fetch(&i, 1); }
int atomic_add(int i) { return __sync_add_and_fetch(&i, 1); } int atomic_add(int i) { return __sync_add_and_fetch(&i, 1); }
], [atomic_sub(1); atomic_add(1);], msgpack_cv_atomic_ops="yes") ], [atomic_sub(1); atomic_add(1);], msgpack_cv_atomic_ops="yes")
])
if test "$msgpack_cv_atomic_ops" != "yes"; then
if test "$enable_cxx" = "no"; then
AC_MSG_ERROR([__sync_* atomic operations are not found. Try to enable C++ support.
If you are using gcc >= 4.1 and the default target CPU architecture is "i386", try to
add CFLAGS="-march=i686" and CXXFLAGS="-march=i686" options to ./configure as follows:
$ ./configure CFLAGS="-march=i686" CXXFLAGS="-march=i686"
])
fi
AC_LANG_PUSH([C++])
AC_CACHE_CHECK([for __gnu_cxx::__exchange_and_add], msgpack_cv_gcc_cxx_atomic_ops, [
AC_TRY_LINK([
#include <bits/atomicity.h>
int atomic_sub(int i) { return __gnu_cxx::__exchange_and_add(&i, -1) - 1; }
int atomic_add(int i) { return __gnu_cxx::__exchange_and_add(&i, 1) + 1; }
], [atomic_sub(1); atomic_add(1);], msgpack_cv_gcc_cxx_atomic_ops="yes")
])
AC_LANG_POP([C++])
if test "$msgpack_cv_gcc_cxx_atomic_ops" != "yes"; then
AC_MSG_ERROR([__sync_* atomic operations nor __gnu_cxx::__exchange_and_add are not found.
If you are using gcc >= 4.1 and the default target CPU architecture is "i386", try to
add CFLAGS="-march=i686" and CXXFLAGS="-march=i686" options to ./configure as follows:
$ ./configure CFLAGS="-march=i686" CXXFLAGS="-march=i686"
]) ])
if test "$msgpack_cv_atomic_ops" != "yes"; then
if test "$enable_cxx" = "no"; then
AC_MSG_ERROR([__sync_* atomic operations are not found. Try to enable C++ support.
If you are using gcc >= 4.1 and the default target CPU architecture is "i386", try to
add CFLAGS="-march=i686" and CXXFLAGS="-march=i686" options to ./configure as follows:
else $ ./configure CFLAGS="-march=i686" CXXFLAGS="-march=i686"
enable_gcc_cxx_atomic=yes ])
fi fi
AC_LANG_PUSH([C++])
AC_CACHE_CHECK([for __gnu_cxx::__exchange_and_add], msgpack_cv_gcc_cxx_atomic_ops, [
AC_TRY_LINK([
#include <bits/atomicity.h>
int atomic_sub(int i) { return __gnu_cxx::__exchange_and_add(&i, -1) - 1; }
int atomic_add(int i) { return __gnu_cxx::__exchange_and_add(&i, 1) + 1; }
], [atomic_sub(1); atomic_add(1);], msgpack_cv_gcc_cxx_atomic_ops="yes")
])
AC_LANG_POP([C++])
if test "$msgpack_cv_gcc_cxx_atomic_ops" != "yes"; then
AC_MSG_ERROR([__sync_* atomic operations nor __gnu_cxx::__exchange_and_add are not found.
If you are using gcc >= 4.1 and the default target CPU architecture is "i386", try to
add CFLAGS="-march=i686" and CXXFLAGS="-march=i686" options to ./configure as follows:
$ ./configure CFLAGS="-march=i686" CXXFLAGS="-march=i686"
])
else
enable_gcc_cxx_atomic=yes
fi
fi fi
AM_CONDITIONAL(ENABLE_GCC_CXX_ATOMIC, test "$enable_gcc_cxx_atomic" = "yes") AM_CONDITIONAL(ENABLE_GCC_CXX_ATOMIC, test "$enable_gcc_cxx_atomic" = "yes")
@ -93,6 +93,6 @@ AC_SUBST(VERSION_REVISION, $revision)
AC_OUTPUT([Makefile AC_OUTPUT([Makefile
msgpack.pc msgpack.pc
src/Makefile src/Makefile
test/Makefile]) test/Makefile])

View File

@ -61,7 +61,7 @@ FOREACH (source_file ${check_PROGRAMS})
) )
ADD_TEST (${source_file_we} ${source_file_we}) ADD_TEST (${source_file_we} ${source_file_we})
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS "-Wall -g -O3") SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS "-Wall -Wextra -Werror -g -O3")
ENDIF () ENDIF ()
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
IF (CMAKE_CXX_FLAGS MATCHES "/W[0-4]") IF (CMAKE_CXX_FLAGS MATCHES "/W[0-4]")