aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Bühler <stbuehler@web.de>2019-08-25 12:31:09 +0200
committerStefan Bühler <stbuehler@web.de>2019-08-25 12:31:09 +0200
commit31d2f3e28d6eaff164ac6e50f9346066b6fdf107 (patch)
treef82f22b32c14f71a5d37ee53ec207ac9c499276b
parent4ae65b02e7c624184bd3551a17898bedc58df44b (diff)
downloadfcgi-debug-31d2f3e28d6eaff164ac6e50f9346066b6fdf107.tar.gz
fcgi-debug-31d2f3e28d6eaff164ac6e50f9346066b6fdf107.zip
[cmake] improve (warning) compile flagsHEADmaster
-rw-r--r--CMakeLists.txt2
-rw-r--r--cmake/LighttpdMacros.cmake2
-rw-r--r--src/CMakeLists.txt42
3 files changed, 25 insertions, 21 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7842024..7966cf0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,6 +1,6 @@
PROJECT(fcgi-debug C)
-CMAKE_MINIMUM_REQUIRED(VERSION 2.4.0 FATAL_ERROR)
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8.2 FATAL_ERROR)
SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
diff --git a/cmake/LighttpdMacros.cmake b/cmake/LighttpdMacros.cmake
index 45ee552..3e91421 100644
--- a/cmake/LighttpdMacros.cmake
+++ b/cmake/LighttpdMacros.cmake
@@ -5,7 +5,7 @@ MACRO(ADD_TARGET_PROPERTIES _target _name)
SET(_properties "${_properties} ${_prop}")
ENDFOREACH(_prop)
GET_TARGET_PROPERTY(_old_properties ${_target} ${_name})
-# MESSAGE("adding property to ${_target} ${_name}:" ${_properties})
+ #MESSAGE("adding property to ${_target} ${_name}:" ${_properties})
IF(NOT _old_properties)
# in case it's NOTFOUND
SET(_old_properties)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index dc77272..0002fe4 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -9,22 +9,32 @@ INCLUDE(CPack)
INCLUDE(FindPkgConfig)
INCLUDE(LighttpdMacros)
-cmake_policy(SET CMP0005 OLD)
OPTION(BUILD_STATIC "build a static fcgi-debug")
IF(CMAKE_COMPILER_IS_GNUCC)
- OPTION(BUILD_EXTRA_WARNINGS "extra warnings")
-
- IF(BUILD_EXTRA_WARNINGS)
- SET(WARN_FLAGS "-g -O2 -g2 -Wall -Wmissing-declarations -Wdeclaration-after-statement -Wcast-align -Winline -Wsign-compare -Wnested-externs -Wpointer-arith -Wformat-security")
- # -Wl,--as-needed
- # -Werror -Wbad-function-cast -Wmissing-prototypes
- ELSE(BUILD_EXTRA_WARNINGS)
- SET(WARN_FLAGS "")
- ENDIF(BUILD_EXTRA_WARNINGS)
+ 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")
+ ADD_DEFINITIONS(-D_GNU_SOURCE)
ENDIF(CMAKE_COMPILER_IS_GNUCC)
+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.")
+
+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")
+ # -Wl,--as-needed
+ # -Werror -Wbad-function-cast -Wmissing-prototypes
+ELSE(BUILD_EXTRA_WARNINGS)
+ SET(WARN_CFLAGS "")
+ SET(WARN_LDFLAGS "")
+ENDIF(BUILD_EXTRA_WARNINGS)
+
ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGE_FILES)
# libev
@@ -66,6 +76,8 @@ ADD_EXECUTABLE(fcgi-debug
parse-fastcgi.c
)
+TARGET_USE_PACKAGE(fcgi-debug "" "" "${WARN_LDFLAGS}" "${WARN_CFLAGS}")
+
IF(BUILD_STATIC)
ADD_TARGET_PROPERTIES(fcgi-debug LINK_FLAGS -static)
@@ -98,16 +110,8 @@ ELSE(BUILD_STATIC)
)
ENDIF(BUILD_STATIC)
-IF(CMAKE_COMPILER_IS_GNUCC)
- SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wall -g -Wshadow -W -pedantic ${WARN_FLAGS}")
- 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")
- ADD_DEFINITIONS(-D_GNU_SOURCE)
-ENDIF(CMAKE_COMPILER_IS_GNUCC)
-
#SET_TARGET_PROPERTIES(fcgi-debug PROPERTIES CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
INSTALL(TARGETS fcgi-debug
RUNTIME DESTINATION bin
- )
+)