aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
blob: 9ad3b959922e8fd57c15315dff379d1a2897c451 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0 FATAL_ERROR)

cmake_policy(VERSION 2.6.0)

MACRO(ADD_TARGET_PROPERTIES _target _name _properties)
  SET(_properties ${ARGV})
  LIST(REMOVE_AT _properties 0)
  LIST(REMOVE_AT _properties 0)
  GET_TARGET_PROPERTY(_old_properties ${_target} ${_name})
  #MESSAGE("adding property to ${_target} ${_name}: ${_properties}")
  IF(NOT _old_properties)
    # in case it's NOTFOUND
    SET(_old_properties)
  ELSE(NOT _old_properties)
    SET(_old_properties "${_old_properties} ")
  ENDIF(NOT _old_properties)
  SET_TARGET_PROPERTIES(${_target} PROPERTIES ${_name} "${_old_properties}${_properties}")
ENDMACRO(ADD_TARGET_PROPERTIES)

PROJECT(spawn-fcgi)
SET(PACKAGE_VERSION 2.0.0)
OPTION(USE_LIMITS "Enable /etc/security/limits.conf support" ON)
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 "")

# GLIB 2
INCLUDE(FindPkgConfig)
pkg_check_modules (GLIB2 REQUIRED glib-2.0)
SET(GLIB_INCLUDES ${GLIB2_INCLUDE_DIRS} ${GLIB2_INCLUDE_DIRS}/glib-2.0/ ${GLIB2_INCLUDE_DIRS}/glib-2.0/include/)
INCLUDE_DIRECTORIES(${GLIB_INCLUDES})

SET(MAIN_SOURCE spawn-fcgi.c)

IF(USE_LIMITS)
SET(MAIN_SOURCE ${MAIN_SOURCE} pam_limits.c)
ADD_DEFINITIONS(-DUSE_LIMITS)
ENDIF(USE_LIMITS)

SET(PACKAGE_NAME ${CMAKE_PROJECT_NAME})
SET(PACKAGE_VERSION ${PACKAGE_VERSION})
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_BINARY_DIR}/config.h ESCAPE_QUOTES)
ADD_DEFINITIONS(-DHAVE_CONFIG_H)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})

add_executable(spawn-fcgi ${MAIN_SOURCE})

ADD_TARGET_PROPERTIES(spawn-fcgi COMPILE_FLAGS "-std=gnu99 -Wall -g -Wshadow -W -pedantic -fPIC -D_GNU_SOURCE")

# GLIB 2
ADD_TARGET_PROPERTIES(spawn-fcgi LINK_FLAGS "${GLIB2_LDFLAGS}")
ADD_TARGET_PROPERTIES(spawn-fcgi COMPILE_FLAGS "${GLIB2_CFLAGS_OTHER}")

INSTALL(TARGETS spawn-fcgi DESTINATION bin)