diff options
author | Maciek Borzecki <maciek.borzecki@gmail.com> | 2015-05-12 22:03:52 +0200 |
---|---|---|
committer | Alan Antonuk <alan.antonuk@gmail.com> | 2015-05-19 22:49:04 -0700 |
commit | da49600a13e47e6922ef58ad704f3c6a94fdffeb (patch) | |
tree | 7f001eef4c2fa11445453fa4b5c1a19a5037a059 | |
parent | abbefd49e1388b0f6970a86bcb57803e78a8a259 (diff) | |
download | rabbitmq-c-pr267.tar.gz |
CMake: build with -std=c90 or -std=gnu90 if possiblepr267
Autotools build uses c90/gnu90. Add similar functionality for cmake
build. This will work for gcc and clang, while for other compilers the
checks will just fail and no additional flags will be added.
-rw-r--r-- | CMakeLists.txt | 11 | ||||
-rw-r--r-- | configure.ac | 6 |
2 files changed, 14 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index bef5262..3be7535 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,6 +59,17 @@ include(CheckSymbolExists) include(CheckLibraryExists) include(CMakePushCheckState) include(GNUInstallDirs) +include(CheckCCompilerFlag) + +CHECK_C_COMPILER_FLAG("-std=gnu90" HAVE_GNU90) +if (HAVE_GNU90) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu90") +else() + CHECK_C_COMPILER_FLAG("-std=c90" HAVE_C90) + if (HAVE_C90) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c90") + endif() +endif() # Detect if we need to link against a socket library: cmake_push_check_state() diff --git a/configure.ac b/configure.ac index 0029533..3b34d9b 100644 --- a/configure.ac +++ b/configure.ac @@ -30,10 +30,10 @@ LT_PREREQ([2.2]) LT_INIT([disable-static win32-dll]) # Program checks -m4_ifdef([AC_PROG_CC_C99], [AC_PROG_CC_C99], - [AC_MSG_WARN([Attempt c99 workaround for old versions of autoconf]) +m4_ifdef([AC_PROG_CC_89], [AC_PROG_CC_89], + [AC_MSG_WARN([Attempt c89 workaround for old versions of autoconf]) AC_PROG_CC - AX_TRY_CFLAGS([-std=c99], [AX_CFLAGS([-std=c99])])]) + AX_TRY_CFLAGS([-std=gnu90], [AX_CFLAGS([-std=gnu90])])]) PKG_PROG_PKG_CONFIG([0.17]) # Environment setup |