Browse Source

Cleanup cmake; added static build and install target

master
Stefan Bühler 13 years ago
parent
commit
135d8dd7a4
  1. 8
      CMakeLists.txt
  2. 9
      cmake/LighttpdMacros.cmake
  3. 52
      src/CMakeLists.txt

8
CMakeLists.txt

@ -4,12 +4,12 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.4.0 FATAL_ERROR)
SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
SET(CPACK_PACKAGE_VERSION_MAJOR 2)
SET(CPACK_PACKAGE_VERSION_MINOR 0)
SET(CPACK_PACKAGE_VERSION_MAJOR 0)
SET(CPACK_PACKAGE_VERSION_MINOR 1)
SET(CPACK_PACKAGE_VERSION_PATCH 0)
#SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING")
#SET(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README")
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING")
SET(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README")
SET(CPACK_PACKAGE_VENDOR "lighttpd@stbuehler.de")
SET(CPACK_SOURCE_GENERATOR "TGZ")

9
cmake/LighttpdMacros.cmake

@ -5,10 +5,17 @@ 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)
ENDIF(NOT _old_properties)
SET_TARGET_PROPERTIES(${_target} PROPERTIES ${_name} "${_old_properties} ${_properties}")
ENDMACRO(ADD_TARGET_PROPERTIES)
MACRO(TARGET_USE_PACKAGE _target _ldirs _libs _lflags _cflags)
LINK_DIRECTORIES(${_ldirs})
TARGET_LINK_LIBRARIES(fcgi-debug ${_libs})
ADD_TARGET_PROPERTIES(fcgi-debug LINK_FLAGS "${_lflags}")
ADD_TARGET_PROPERTIES(fcgi-debug COMPILE_FLAGS ${_cflags})
ENDMACRO(TARGET_USE_PACKAGE)

52
src/CMakeLists.txt

@ -12,6 +12,8 @@ INCLUDE(LighttpdMacros)
FIND_PACKAGE(Ragel REQUIRED)
cmake_policy(SET CMP0005 OLD)
OPTION(BUILD_STATIC "build a static fcgi-debug")
ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGE_FILES)
# libev
@ -19,7 +21,12 @@ CHECK_INCLUDE_FILES(ev.h HAVE_EV_H)
IF(HAVE_EV_H)
CHECK_LIBRARY_EXISTS(ev ev_loop "" HAVE_LIBEV)
IF(HAVE_LIBEV)
SET(EV_LDFLAGS -lev)
SET(EV_LIBRARIES ev)
SET(EV_STATIC_LIBRARIES ev;m)
CHECK_LIBRARY_EXISTS(rt clock_gettime "" NEED_RT)
IF(NEED_RT)
SET(EV_STATIC_LIBRARIES ${EV_STATIC_LIBRARIES} rt)
ENDIF(NEED_RT)
ELSE(HAVE_LIBEV)
MESSAGE(FATAL_ERROR "Couldn't find lib ev")
ENDIF(HAVE_LIBEV)
@ -28,8 +35,7 @@ ELSE(HAVE_EV_H)
ENDIF(HAVE_EV_H)
# glib/gthread
pkg_check_modules(GTHREAD REQUIRED gthread-2.0)
#INCLUDE_DIRECTORIES(${GTHREAD_INCLUDE_DIRS})
pkg_check_modules(GLIB REQUIRED glib-2.0>=2.12)
ADD_DEFINITIONS(
-DPACKAGE_NAME="\\"${CMAKE_PROJECT_NAME}\\""
@ -56,8 +62,37 @@ ADD_EXECUTABLE(fcgi-debug
parse-fastcgi.c
)
ADD_TARGET_PROPERTIES(fcgi-debug LINK_FLAGS ${EV_LDFLAGS})
ADD_TARGET_PROPERTIES(fcgi-debug COMPILE_FLAGS ${EV_CFLAGS})
IF(BUILD_STATIC)
ADD_TARGET_PROPERTIES(fcgi-debug LINK_FLAGS -static)
TARGET_USE_PACKAGE(fcgi-debug
"${EV_STATIC_LIBARARY_DIRS}"
"${EV_STATIC_LIBRARIES}"
"${EV_STATIC_LDFLAGS_OTHERS}"
"${EV_STATIC_CFLAGS}"
)
TARGET_USE_PACKAGE(fcgi-debug
"${GLIB_STATIC_LIBARARY_DIRS}"
"${GLIB_STATIC_LIBRARIES}"
"${GLIB_STATIC_LDFLAGS_OTHERS}"
"${GLIB_STATIC_CFLAGS}"
)
ELSE(BUILD_STATIC)
TARGET_USE_PACKAGE(fcgi-debug
"${EV_LIBARARY_DIRS}"
"${EV_LIBRARIES}"
"${EV_LDFLAGS_OTHERS}"
"${EV_CFLAGS}"
)
TARGET_USE_PACKAGE(fcgi-debug
"${GLIB_LIBARARY_DIRS}"
"${GLIB_LIBRARIES}"
"${GLIB_LDFLAGS_OTHERS}"
"${GLIB_CFLAGS}"
)
ENDIF(BUILD_STATIC)
IF(CMAKE_COMPILER_IS_GNUCC)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wall -g -Wshadow -W -pedantic")
@ -67,7 +102,8 @@ IF(CMAKE_COMPILER_IS_GNUCC)
ADD_DEFINITIONS(-D_GNU_SOURCE)
ENDIF(CMAKE_COMPILER_IS_GNUCC)
ADD_TARGET_PROPERTIES(fcgi-debug LINK_FLAGS ${GTHREAD_LDFLAGS})
ADD_TARGET_PROPERTIES(fcgi-debug COMPILE_FLAGS ${GTHREAD_CFLAGS})
#SET_TARGET_PROPERTIES(fcgi-debug PROPERTIES CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
SET_TARGET_PROPERTIES(fcgi-debug PROPERTIES CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
INSTALL(TARGETS fcgi-debug
RUNTIME DESTINATION bin
)

Loading…
Cancel
Save