aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Bühler <stbuehler@web.de>2019-08-25 12:20:30 +0200
committerStefan Bühler <stbuehler@web.de>2019-08-25 12:20:30 +0200
commit24bc87c7da3c1733686b9dac6952cbd98b77528c (patch)
tree72a69f72b7f423ce0bad38e15f59a08ea58d2e46
parentdd4b50c303fddea3414dc72ad93136f0323acd69 (diff)
downloadfcgi-cgi-master.tar.gz
fcgi-cgi-master.zip
[build] improve (warning) compile flagsHEADmaster
-rw-r--r--CMakeLists.txt27
-rw-r--r--cmake/AddTargetProperties.cmake2
-rw-r--r--configure.ac8
3 files changed, 29 insertions, 8 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a6be0a0..8e18ba9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,6 +1,6 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0 FATAL_ERROR)
-cmake_policy(VERSION 2.6.0)
+CMAKE_POLICY(VERSION 2.6.0)
SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
@@ -17,6 +17,26 @@ IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." FORCE)
ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+OPTION(BUILD_EXTRA_WARNINGS "extra warnings")
+
+# default to ON
+set(CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL "Default value for ``POSITION_INDEPENDENT_CODE`` of targets.")
+
+# handle BUILD_EXTRA_WARNINGS option
+IF(BUILD_EXTRA_WARNINGS)
+ SET(WARN_CFLAGS "-g -O2 -g2 -Wall -Wmissing-declarations -Wdeclaration-after-statement -Wcast-align -Wsign-compare -Wnested-externs -Wpointer-arith -Wmissing-prototypes -Wshadow -Wno-pointer-sign -Wformat-security")
+ SET(WARN_LDFLAGS "-g -O2 -g2 -Wall -Wl,--as-needed -Wl,--no-undefined")
+ELSE(BUILD_EXTRA_WARNINGS)
+ SET(WARN_CFLAGS "")
+ SET(WARN_LDFLAGS "")
+ENDIF(BUILD_EXTRA_WARNINGS)
+
+IF(CMAKE_COMPILER_IS_GNUCC)
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wall -g -Wshadow -W -pedantic")
+ SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O2")
+ SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0")
+ SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_WITHDEBINFO} -O2")
+ENDIF(CMAKE_COMPILER_IS_GNUCC)
# libev
FIND_PACKAGE(LibEV REQUIRED)
@@ -33,9 +53,10 @@ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_BINARY_DIR}/co
ADD_DEFINITIONS(-DHAVE_CONFIG_H)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
-add_executable(fcgi-cgi ${MAIN_SOURCE})
+ADD_EXECUTABLE(fcgi-cgi ${MAIN_SOURCE})
-ADD_TARGET_PROPERTIES(fcgi-cgi COMPILE_FLAGS "-std=gnu99 -Wall -g -Wshadow -W -pedantic -fPIC")
+TARGET_LINK_LIBRARIES(fcgi-cgi ${WARN_LDFLAGS})
+ADD_TARGET_PROPERTIES(fcgi-cgi COMPILE_FLAGS ${WARN_CFLAGS})
# libev
TARGET_LINK_LIBRARIES(fcgi-cgi ${LIBEV_LDFLAGS})
diff --git a/cmake/AddTargetProperties.cmake b/cmake/AddTargetProperties.cmake
index 17ee774..3860a0b 100644
--- a/cmake/AddTargetProperties.cmake
+++ b/cmake/AddTargetProperties.cmake
@@ -4,7 +4,7 @@ MACRO(ADD_TARGET_PROPERTIES _target _name)
SET(_properties "${_properties} ${_prop}")
ENDFOREACH(_prop)
GET_TARGET_PROPERTY(_old_properties ${_target} ${_name})
- MESSAGE(STATUS "adding property to ${_target} ${_name}:" ${_properties})
+ # MESSAGE(STATUS "adding property to ${_target} ${_name}:" ${_properties})
IF(NOT _old_properties)
# in case it's NOTFOUND
SET(_old_properties)
diff --git a/configure.ac b/configure.ac
index 57a4036..2ed48f0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -42,16 +42,16 @@ if test "${GCC}" = "yes"; then
CFLAGS="${CFLAGS} -Wall -W -Wshadow -pedantic -std=gnu99"
fi
-AC_ARG_ENABLE(extra-warnings,
- AC_HELP_STRING([--enable-extra-warnings],[enable extra warnings (gcc specific)]),
+AC_ARG_ENABLE([extra-warnings],
+ [AS_HELP_STRING([--enable-extra-warnings],[enable extra warnings (gcc specific)])],
[case "${enableval}" in
yes) extrawarnings=true ;;
no) extrawarnings=false ;;
- *) AC_MSG_ERROR(bad value ${enableval} for --enable-extra-warnings) ;;
+ *) AC_MSG_ERROR([bad value ${enableval} for --enable-extra-warnings]) ;;
esac],[extrawarnings=false])
if test x$extrawarnings = xtrue; then
- CFLAGS="${CFLAGS} -g -O2 -g2 -Wall -Wmissing-declarations -Wdeclaration-after-statement -Wno-pointer-sign -Wcast-align -Winline -Wsign-compare -Wnested-externs -Wpointer-arith -Wl,--as-needed -Wformat-security"
+ CFLAGS="${CFLAGS} -g -O2 -g2 -Wall -Wmissing-declarations -Wdeclaration-after-statement -Wcast-align -Wsign-compare -Wnested-externs -Wpointer-arith -Wmissing-prototypes -Wshadow -Wno-pointer-sign -Wformat-security -Wl,--as-needed -Wl,--no-undefined"
fi
AC_CONFIG_FILES([Makefile])