SCGI application to run cgi applications https://redmine.lighttpd.net/projects/scgi-cgi
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
2.6 KiB

8 years ago
CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0 FATAL_ERROR)
cmake_policy(VERSION 2.6.0)
SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
INCLUDE(CheckIncludeFiles)
INCLUDE(CheckLibraryExists)
INCLUDE(FindPkgConfig)
INCLUDE(AddTargetProperties)
PROJECT(scgi-cgi C)
8 years ago
SET(PACKAGE_VERSION 0.1.1)
8 years ago
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(GCC_LIBEVENT_STATIC "link libevent static")
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")
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")
ADD_DEFINITIONS(-D_GNU_SOURCE)
ENDIF(CMAKE_COMPILER_IS_GNUCC)
8 years ago
# libevent
pkg_check_modules (LIBEVENT REQUIRED libevent>=2.0)
IF(GCC_LIBEVENT_STATIC)
SET(MYLIBEVENT_LDFLAGS -Wl,-Bstatic ${LIBEVENT_LDFLAGS} -Wl,-Bdynamic)
ELSE(GCC_LIBEVENT_STATIC)
SET(MYLIBEVENT_LDFLAGS ${LIBEVENT_LDFLAGS})
ENDIF(GCC_LIBEVENT_STATIC)
SET(MAIN_SOURCE scgi-cgi.c)
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(scgi-cgi ${MAIN_SOURCE})
ADD_TARGET_PROPERTIES(scgi-cgi COMPILE_FLAGS "${WARN_FLAGS}")
TARGET_LINK_LIBRARIES(scgi-cgi ${WARN_LDFLAGS})
8 years ago
# libev
TARGET_LINK_LIBRARIES(scgi-cgi ${MYLIBEVENT_LDFLAGS})
ADD_TARGET_PROPERTIES(scgi-cgi COMPILE_FLAGS ${LIBEVENT_CFLAGS})
INSTALL(TARGETS scgi-cgi DESTINATION bin)
# man page
SET(CMAKE_MAN_DIR "share/man" CACHE STRING
"Install location for man pages (relative to prefix).")
MARK_AS_ADVANCED(CMAKE_MAN_DIR)
INSTALL(FILES scgi-cgi.1 DESTINATION ${CMAKE_MAN_DIR}/man1)