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

  1. CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0 FATAL_ERROR)
  2. cmake_policy(VERSION 2.6.0)
  3. SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
  4. INCLUDE(CheckIncludeFiles)
  5. INCLUDE(CheckLibraryExists)
  6. INCLUDE(FindPkgConfig)
  7. INCLUDE(AddTargetProperties)
  8. PROJECT(scgi-cgi C)
  9. SET(PACKAGE_VERSION 0.1.1)
  10. IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
  11. 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)
  12. ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
  13. OPTION(GCC_LIBEVENT_STATIC "link libevent static")
  14. OPTION(BUILD_EXTRA_WARNINGS "extra warnings")
  15. # default to ON
  16. SET(CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL "Default value for ``POSITION_INDEPENDENT_CODE`` of targets.")
  17. IF(BUILD_EXTRA_WARNINGS)
  18. 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")
  19. SET(WARN_LDFLAGS "-g -O2 -g2 -Wall -Wl,--as-needed -Wl,--no-undefined")
  20. ELSE(BUILD_EXTRA_WARNINGS)
  21. SET(WARN_CFLAGS "")
  22. SET(WARN_LDFLAGS "")
  23. ENDIF(BUILD_EXTRA_WARNINGS)
  24. IF(CMAKE_COMPILER_IS_GNUCC)
  25. SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wall -g -Wshadow -W -pedantic")
  26. SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O2")
  27. SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0")
  28. SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_WITHDEBINFO} -O2")
  29. ADD_DEFINITIONS(-D_GNU_SOURCE)
  30. ENDIF(CMAKE_COMPILER_IS_GNUCC)
  31. # libevent
  32. pkg_check_modules (LIBEVENT REQUIRED libevent>=2.0)
  33. IF(GCC_LIBEVENT_STATIC)
  34. SET(MYLIBEVENT_LDFLAGS -Wl,-Bstatic ${LIBEVENT_LDFLAGS} -Wl,-Bdynamic)
  35. ELSE(GCC_LIBEVENT_STATIC)
  36. SET(MYLIBEVENT_LDFLAGS ${LIBEVENT_LDFLAGS})
  37. ENDIF(GCC_LIBEVENT_STATIC)
  38. SET(MAIN_SOURCE scgi-cgi.c)
  39. SET(PACKAGE_NAME ${CMAKE_PROJECT_NAME})
  40. SET(PACKAGE_VERSION ${PACKAGE_VERSION})
  41. CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_BINARY_DIR}/config.h ESCAPE_QUOTES)
  42. ADD_DEFINITIONS(-DHAVE_CONFIG_H)
  43. INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
  44. add_executable(scgi-cgi ${MAIN_SOURCE})
  45. ADD_TARGET_PROPERTIES(scgi-cgi COMPILE_FLAGS "${WARN_FLAGS}")
  46. TARGET_LINK_LIBRARIES(scgi-cgi ${WARN_LDFLAGS})
  47. # libev
  48. TARGET_LINK_LIBRARIES(scgi-cgi ${MYLIBEVENT_LDFLAGS})
  49. ADD_TARGET_PROPERTIES(scgi-cgi COMPILE_FLAGS ${LIBEVENT_CFLAGS})
  50. INSTALL(TARGETS scgi-cgi DESTINATION bin)
  51. # man page
  52. SET(CMAKE_MAN_DIR "share/man" CACHE STRING
  53. "Install location for man pages (relative to prefix).")
  54. MARK_AS_ADVANCED(CMAKE_MAN_DIR)
  55. INSTALL(FILES scgi-cgi.1 DESTINATION ${CMAKE_MAN_DIR}/man1)