1
0
mirror of https://github.com/kakwa/uts-server synced 2024-11-10 11:38:54 +01:00
uts-server/CMakeLists.txt

100 lines
2.9 KiB
CMake
Raw Normal View History

2015-12-16 23:11:08 +01:00
cmake_minimum_required (VERSION 2.6)
project (uts-server)
include(ExternalProject)
2015-12-16 23:11:08 +01:00
2017-01-27 00:36:46 +01:00
set(VERSION 0.1.3)
2015-12-16 23:11:08 +01:00
option(DEBUG "compile with debug symbol" OFF)
option(BUNDLE_CIVETWEB "bundle civetweb with uts-server" OFF)
2016-11-02 18:57:26 +01:00
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=700")
if(DEBUG)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -g")
set(CMAKE_BUILD_TYPE Debug)
endif(DEBUG)
2015-12-16 23:11:08 +01:00
add_custom_target(tag
git tag -a "${VERSION}" -m "version ${VERSION}" &&
git push origin ${VERSION}
)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUTS_VERSION='\"${VERSION}\"'")
2015-12-16 23:11:08 +01:00
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")
find_package(OpenSSL REQUIRED)
MESSAGE(STATUS "OpenSSL include dir: ${OPENSSL_INCLUDE_DIR}")
MESSAGE(STATUS "OpenSSL libraries: ${OPENSSL_LIBRARIES}")
MESSAGE(STATUS "OpenSSL version: ${OPENSSL_VERSION}")
2017-01-26 23:26:39 +01:00
if(${OPENSSL_VERSION} VERSION_GREATER 1.0.99)
set(OPENSSL_API_1_1 ON)
else()
set(OPENSSL_API_1_1 OFF)
endif()
IF(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
set(SED_FREEBSD "*.c")
2017-01-27 00:28:46 +01:00
find_package(argp REQUIRED)
2017-01-27 00:35:58 +01:00
add_definitions(-DBSD)
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
if(BUNDLE_CIVETWEB)
ExternalProject_Add( civetweb
GIT_REPOSITORY https://github.com/kakwa/civetweb
PATCH_COMMAND sed -i ${SED_FREEBSD} s/__DATE__/"110973"/ src/main.c src/civetweb.c
INSTALL_DIR /usr/local
CMAKE_ARGS .. -DCMAKE_INSTALL_PREFIX=/usr
-DCIVETWEB_DISABLE_CGI=ON
-DCIVETWEB_ENABLE_CXX=OFF
-DBUILD_SHARED_LIBS=OFF
-DCIVETWEB_DISABLE_CGI=ON
-DCIVETWEB_SERVE_NO_FILES=ON
-DCIVETWEB_ENABLE_IPV6=ON
-DCIVETWEB_DISABLE_CACHING=ON
-DBUILD_TESTING=OFF
-DCIVETWEB_SSL_OPENSSL_API_1_1=${OPENSSL_API_1_1}
-DCIVETWEB_ENABLE_SSL_DYNAMIC_LOADING=OFF
INSTALL_COMMAND make install DESTDIR=${CMAKE_CURRENT_SOURCE_DIR}/vendor/
)
set(LIBCIVETWEB_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/vendor/usr/include")
set(LIBCIVETWEB_LIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/vendor/usr/lib/libcivetweb.a")
2017-01-27 00:28:46 +01:00
set (CMAKE_C_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -lpthread -lrt")
else(BUNDLE_CIVETWEB)
find_package(libcivetweb REQUIRED)
endif(BUNDLE_CIVETWEB)
2015-12-16 23:11:08 +01:00
MESSAGE( STATUS "Find Header Directory for libcivetweb: " ${LIBCIVETWEB_INCLUDE_DIR})
MESSAGE( STATUS "Find Dynamic Library for libcivetweb: " ${LIBCIVETWEB_LIBRARIES})
2015-12-16 23:11:08 +01:00
include_directories(
2015-12-17 21:47:41 +01:00
./inc/
2016-08-19 00:04:13 +02:00
${LIBCIVETWEB_INCLUDE_DIR}
2015-12-17 14:09:09 +01:00
${OPENSSL_INCLUDE_DIR}
2017-01-27 00:28:46 +01:00
${ARGP_INCLUDE_DIR}
2015-12-16 23:11:08 +01:00
)
2015-12-17 21:47:41 +01:00
add_executable(uts-server
src/cmd/uts-server.c
src/lib/rfc3161.c
src/lib/http.c
2015-12-17 21:47:41 +01:00
src/lib/utils.c
)
2015-12-16 23:11:08 +01:00
2015-12-17 14:09:09 +01:00
target_link_libraries(uts-server
${OPENSSL_LIBRARIES}
${LIBCIVETWEB_LIBRARIES}
2017-01-27 00:28:46 +01:00
${ARGP_LIBRARIES}
2015-12-17 14:09:09 +01:00
)
2015-12-16 23:11:08 +01:00
INSTALL(TARGETS uts-server
RUNTIME DESTINATION bin
)
if(BUNDLE_CIVETWEB)
add_dependencies(uts-server civetweb)
endif(BUNDLE_CIVETWEB)