Forks and watches multiple instances of a program in the same context (environment + fds) https://redmine.lighttpd.net/projects/multiwatch
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.

97 lines
3.4 KiB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
  1. CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0 FATAL_ERROR)
  2. cmake_policy(VERSION 2.6.0)
  3. INCLUDE(CheckIncludeFiles)
  4. INCLUDE(CheckLibraryExists)
  5. INCLUDE(FindPkgConfig)
  6. MACRO(ADD_TARGET_PROPERTIES _target _name _properties)
  7. SET(_properties ${ARGV})
  8. LIST(REMOVE_AT _properties 0)
  9. LIST(REMOVE_AT _properties 0)
  10. GET_TARGET_PROPERTY(_old_properties ${_target} ${_name})
  11. #MESSAGE("adding property to ${_target} ${_name}: ${_properties}")
  12. IF(NOT _old_properties)
  13. # in case it's NOTFOUND
  14. SET(_old_properties)
  15. ELSE(NOT _old_properties)
  16. SET(_old_properties "${_old_properties} ")
  17. ENDIF(NOT _old_properties)
  18. SET_TARGET_PROPERTIES(${_target} PROPERTIES ${_name} "${_old_properties}${_properties}")
  19. ENDMACRO(ADD_TARGET_PROPERTIES)
  20. PROJECT(multiwatch)
  21. SET(PACKAGE_VERSION 1.0.0)
  22. IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
  23. 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)
  24. ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
  25. OPTION(BUILD_EXTRA_WARNINGS "extra warnings")
  26. # default to ON
  27. set(CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL "Default value for ``POSITION_INDEPENDENT_CODE`` of targets.")
  28. IF(BUILD_EXTRA_WARNINGS)
  29. 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")
  30. SET(WARN_LDFLAGS "-g -O2 -g2 -Wall -Wl,--as-needed -Wl,--no-undefined")
  31. # -Wl,--as-needed
  32. # -Werror -Wbad-function-cast -Wmissing-prototypes
  33. ELSE(BUILD_EXTRA_WARNINGS)
  34. SET(WARN_CFLAGS "")
  35. SET(WARN_LDFLAGS "")
  36. ENDIF(BUILD_EXTRA_WARNINGS)
  37. # libev
  38. CHECK_INCLUDE_FILES(ev.h HAVE_EV_H)
  39. IF(HAVE_EV_H)
  40. CHECK_LIBRARY_EXISTS(ev ev_time "" HAVE_LIBEV)
  41. IF(HAVE_LIBEV)
  42. SET(EV_LIBRARIES ev)
  43. SET(EV_STATIC_LIBRARIES ev;m)
  44. CHECK_LIBRARY_EXISTS(rt clock_gettime "" NEED_RT)
  45. IF(NEED_RT)
  46. SET(EV_STATIC_LIBRARIES ${EV_STATIC_LIBRARIES} rt)
  47. ENDIF(NEED_RT)
  48. ELSE(HAVE_LIBEV)
  49. MESSAGE(FATAL_ERROR "Couldn't find lib ev")
  50. ENDIF(HAVE_LIBEV)
  51. ELSE(HAVE_EV_H)
  52. MESSAGE(FATAL_ERROR "Couldn't find <ev.h>")
  53. ENDIF(HAVE_EV_H)
  54. # GLIB 2
  55. pkg_check_modules (GLIB2 REQUIRED glib-2.0)
  56. SET(GLIB_INCLUDES ${GLIB2_INCLUDE_DIRS} ${GLIB2_INCLUDE_DIRS}/glib-2.0/ ${GLIB2_INCLUDE_DIRS}/glib-2.0/include/)
  57. INCLUDE_DIRECTORIES(${GLIB_INCLUDES})
  58. SET(MAIN_SOURCE multiwatch.c)
  59. SET(PACKAGE_NAME ${CMAKE_PROJECT_NAME})
  60. SET(PACKAGE_VERSION ${PACKAGE_VERSION})
  61. CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_BINARY_DIR}/config.h ESCAPE_QUOTES)
  62. ADD_DEFINITIONS(-DHAVE_CONFIG_H)
  63. INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
  64. add_executable(multiwatch ${MAIN_SOURCE})
  65. IF(CMAKE_COMPILER_IS_GNUCC)
  66. SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wall -g -Wshadow -W -pedantic")
  67. SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O2")
  68. SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0")
  69. SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_WITHDEBINFO} -O2")
  70. ADD_DEFINITIONS(-D_GNU_SOURCE)
  71. ENDIF(CMAKE_COMPILER_IS_GNUCC)
  72. ADD_TARGET_PROPERTIES(multiwatch COMPILE_FLAGS "${WARN_CFLAGS}")
  73. TARGET_LINK_LIBRARIES(multiwatch ${WARN_LDFLAGS})
  74. # libev
  75. TARGET_LINK_LIBRARIES(multiwatch "${EV_LIBRARIES}")
  76. # GLIB 2
  77. TARGET_LINK_LIBRARIES(multiwatch "${GLIB2_LDFLAGS}")
  78. ADD_TARGET_PROPERTIES(multiwatch COMPILE_FLAGS "${GLIB2_CFLAGS_OTHER}")
  79. INSTALL(TARGETS multiwatch DESTINATION bin)