From 2e0d6c4c11de91d41e86fd8773dfb43586a19127 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 4 Jul 2018 14:38:58 +0200 Subject: [SERVER] cmake: Add config option for extra compiler opptions --- CMakeLists.txt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f2da9e5..ebee2cd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,11 +8,12 @@ IF (CMAKE_BUILD_TYPE STREQUAL "") SET(CMAKE_BUILD_TYPE Debug) ENDIF() -SET(CMAKE_INSTALL_PREFIX "/usr/local" CACHE FILEPATH "Path prefix for system installation") +SET(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "Path prefix for system installation") OPTION(BUILD_KERNEL_MODULE "Build the dnbd3 Linux kernel module" ON) OPTION(BUILD_FUSE_CLIENT "Build dnbd3 fuse client" ON) OPTION(BUILD_SERVER "Build dnbd3 server" ON) OPTION(BUILD_STRESSTEST "Build dnbd3 stress testing tool" OFF) +SET(EXTRA_C_FLAGS "" CACHE STRING "Additional options to pass to compiler") OPTION(SERVER_FOR_AFL "Build dnbd3-server for usage with afl-fuzz" OFF) @@ -36,12 +37,12 @@ ENDIF() if(CMAKE_C_COMPILER MATCHES "clang") message( "Using clang flags." ) - SET(CMAKE_C_FLAGS_DEBUG "-std=c11 -O1 -fno-omit-frame-pointer -g -Wall -Wextra -Wpedantic -Wno-unused-result -D_GNU_SOURCE -D_DEBUG -Wno-multichar -fno-strict-aliasing") - SET(CMAKE_C_FLAGS_RELEASE "-std=c11 -O2 -Wno-unused-result -D_GNU_SOURCE -DNDEBUG -Wno-multichar -fno-strict-aliasing") + SET(CMAKE_C_FLAGS_DEBUG "-std=c11 -O1 -fno-omit-frame-pointer -g -Wall -Wextra -Wpedantic -Wno-unused-result -D_GNU_SOURCE -D_DEBUG -Wno-multichar -fno-strict-aliasing ${EXTRA_C_FLAGS}") + SET(CMAKE_C_FLAGS_RELEASE "-std=c11 -O2 -Wno-unused-result -D_GNU_SOURCE -DNDEBUG -Wno-multichar -fno-strict-aliasing ${EXTRA_C_FLAGS}") elseif (CMAKE_C_COMPILER MATCHES "(cc-)|(cc$)") message( "Using (g)cc flags." ) - SET(CMAKE_C_FLAGS_DEBUG "-std=c11 -O0 -g -Wall -Wextra -Wpedantic -Wconversion -Wno-sign-conversion -D_GNU_SOURCE -D_DEBUG -Wno-multichar -fno-strict-aliasing") - SET(CMAKE_C_FLAGS_RELEASE "-std=c11 -O2 -Wno-unused-result -D_GNU_SOURCE -DNDEBUG -Wno-multichar -fno-strict-aliasing") + SET(CMAKE_C_FLAGS_DEBUG "-std=c11 -O0 -g -Wall -Wextra -Wpedantic -Wconversion -Wno-sign-conversion -D_GNU_SOURCE -D_DEBUG -Wno-multichar -fno-strict-aliasing ${EXTRA_C_FLAGS}") + SET(CMAKE_C_FLAGS_RELEASE "-std=c11 -O2 -Wno-unused-result -D_GNU_SOURCE -DNDEBUG -Wno-multichar -fno-strict-aliasing ${EXTRA_C_FLAGS}") else() message( FATAL_ERROR "Could not determine compiler type." ) endif() -- cgit v1.2.3-55-g7522