From 839c76c814a01e3852f5da1c4e294e8668e13c4f Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Tue, 23 Feb 2016 15:09:58 +0100 Subject: build: Require usage of C89 This requires the usage of the C89 standard for all source files. It also fixes a wrong check for the compiler flags (was checking this for CXX compiler instead of the C compiler). --- CMakeLists.txt | 15 +++++++++------ cmake/CompilerUtils.cmake | 10 +++++----- include/ouroboros/common.h | 1 + src/lib/bitmap.c | 2 +- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ca05c95..c3495e6a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.1.0) set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") #set(CMAKE_VERBOSE_MAKEFILE ON) -project(ouroboros) +project(ouroboros C) include(GitVersionGen) GIT_VERSION_GEN() @@ -27,13 +27,16 @@ message(STATUS "Package URL is: ${PACKAGE_URL}") message(STATUS "Package bug-report address: ${PACKAGE_BUGREPORT}") message(STATUS "Package install prefix: ${CMAKE_INSTALL_PREFIX}") +# Enable C89 standard +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c89") + include(FindPkgConfig) include(CompilerUtils) -test_and_set_cxx_compiler_flag_global(-Wall) -test_and_set_cxx_compiler_flag_global(-Werror) -test_and_set_cxx_compiler_flag_global(-Wundef) -test_and_set_cxx_compiler_flag_global(-fmax-errors=1) +test_and_set_c_compiler_flag_global(-Wall) +test_and_set_c_compiler_flag_global(-Werror) +test_and_set_c_compiler_flag_global(-Wundef) +test_and_set_c_compiler_flag_global(-fmax-errors=1) configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/ouroboros.pc.in" @@ -46,7 +49,7 @@ add_subdirectory(include) add_subdirectory(src) add_subdirectory(tests) -# We may have to move this to the subdirs +# FIXME: We may have to move this to the subdirs include(MacroAddCompileFlags) if (CMAKE_BUILD_TYPE MATCHES Debug) MACRO_ADD_COMPILE_FLAGS(ipcpd -DCONFIG_OUROBOROS_DEBUG) diff --git a/cmake/CompilerUtils.cmake b/cmake/CompilerUtils.cmake index 99d9b662..5cea44b6 100644 --- a/cmake/CompilerUtils.cmake +++ b/cmake/CompilerUtils.cmake @@ -1,15 +1,15 @@ -include(CheckCXXCompilerFlag) +include(CheckCCompilerFlag) -function(test_and_set_cxx_compiler_flag_global _flag) +function(test_and_set_c_compiler_flag_global _flag) string(REGEX REPLACE "-" "_" _sflag ${_flag}) - check_cxx_compiler_flag(${_flag} COMPILER_SUPPORTS_FLAG_${_sflag}) + check_c_compiler_flag(${_flag} COMPILER_SUPPORTS_FLAG_${_sflag}) if(COMPILER_SUPPORTS_FLAG_${_sflag}) message(STATUS "Compiler supports flag ${_flag}, added globally") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_flag}" PARENT_SCOPE) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_flag}" PARENT_SCOPE) else(${_retval}) message(STATUS "Compiler does not support flag ${_flag}, discarded") endif() -endfunction(test_and_set_cxx_compiler_flag_global) +endfunction(test_and_set_c_compiler_flag_global) diff --git a/include/ouroboros/common.h b/include/ouroboros/common.h index 90431208..09900a1f 100644 --- a/include/ouroboros/common.h +++ b/include/ouroboros/common.h @@ -26,6 +26,7 @@ #include #include #include +#include typedef uint32_t port_id_t; diff --git a/src/lib/bitmap.c b/src/lib/bitmap.c index cb414e7f..3aaa422c 100644 --- a/src/lib/bitmap.c +++ b/src/lib/bitmap.c @@ -187,7 +187,7 @@ int rbmp_release(struct rbmp * b, rid = id - b->offset; - bitmap_clear(b->bitmap, id); + bitmap_clear(b->bitmap, rid); return 0; } -- cgit v1.2.3 From 61670a5b3d37ee8bb611c5d08cc216f4b6d9570b Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Tue, 23 Feb 2016 15:54:40 +0100 Subject: build: Fix check for C89 The flag for the C89 standard was added without checking if the compiler supports it. This has been fixed. Also, the feature summary has been (temporarily) disabled. --- CMakeLists.txt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c3495e6a..8da3ee54 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,12 +27,10 @@ message(STATUS "Package URL is: ${PACKAGE_URL}") message(STATUS "Package bug-report address: ${PACKAGE_BUGREPORT}") message(STATUS "Package install prefix: ${CMAKE_INSTALL_PREFIX}") -# Enable C89 standard -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c89") - include(FindPkgConfig) include(CompilerUtils) +test_and_set_c_compiler_flag_global(-std=c89) test_and_set_c_compiler_flag_global(-Wall) test_and_set_c_compiler_flag_global(-Werror) test_and_set_c_compiler_flag_global(-Wundef) @@ -58,8 +56,8 @@ if (CMAKE_BUILD_TYPE MATCHES Debug) MACRO_ADD_COMPILE_FLAGS(irm -DCONFIG_OUROBOROS_DEBUG) endif (CMAKE_BUILD_TYPE MATCHES Debug) -include(FeatureSummary) -print_enabled_features() +#include(FeatureSummary) +#print_enabled_features() # Uninstall target configure_file( -- cgit v1.2.3