2015-12-16 23:11:08 +01:00
|
|
|
cmake_minimum_required (VERSION 2.6)
|
|
|
|
project (uts-server)
|
2016-09-07 20:59:10 +02:00
|
|
|
include(ExternalProject)
|
|
|
|
|
2017-07-24 23:53:14 +02:00
|
|
|
if (CMAKE_VERSION VERSION_LESS "3.1")
|
|
|
|
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
|
|
|
set (CMAKE_C_FLAGS "--std=gnu99 ${CMAKE_C_FLAGS}")
|
|
|
|
endif ()
|
|
|
|
else ()
|
|
|
|
set (CMAKE_C_STANDARD 99)
|
|
|
|
endif ()
|
|
|
|
|
2017-11-04 13:13:37 +01:00
|
|
|
set(VERSION 0.1.10)
|
2015-12-16 23:11:08 +01:00
|
|
|
|
2017-01-30 08:29:17 +01:00
|
|
|
option(DEBUG "compile with debug symbol" OFF)
|
|
|
|
option(BUNDLE_CIVETWEB "bundle civetweb with uts-server" OFF)
|
|
|
|
option(STATIC "static linked binary" OFF)
|
2017-01-31 01:26:51 +01:00
|
|
|
option(LINK_DL "link dl" OFF)
|
|
|
|
option(LINK_GCC_S "link gcc_s" OFF)
|
2017-01-30 08:29:17 +01:00
|
|
|
option(CIVETWEB_CUST_ARGS "Custom args for civetweb (if civetweb is bundled)" "")
|
2017-01-31 01:26:51 +01:00
|
|
|
option(LINK_PTHREAD "link pthread" OFF)
|
2017-01-29 16:31:03 +01:00
|
|
|
|
2017-04-27 21:47:36 +02:00
|
|
|
IF("$ENV{CIVETWEB_GITURL}" STREQUAL "")
|
2017-11-04 13:11:33 +01:00
|
|
|
set(CIVETWEB_GITURL "https://github.com/civetweb/civetweb")
|
2017-04-27 21:47:36 +02:00
|
|
|
ELSE()
|
|
|
|
set(CIVETWEB_GITURL "$ENV{CIVETWEB_GITURL}")
|
|
|
|
ENDIF()
|
|
|
|
|
2017-11-04 13:11:33 +01:00
|
|
|
IF("$ENV{CIVETWEB_GITTAG}" STREQUAL "")
|
|
|
|
set(CIVETWEB_GITTAG "v1.10")
|
|
|
|
ELSE()
|
|
|
|
set(CIVETWEB_GITTAG "$ENV{CIVETWEB_GITTAG}")
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-01-29 16:31:03 +01:00
|
|
|
IF(STATIC)
|
|
|
|
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
|
2017-01-31 01:21:13 +01:00
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
|
2017-01-29 16:31:03 +01:00
|
|
|
set(OPENSSL_USE_STATIC_LIBS ON)
|
|
|
|
set(ARGP_USE_STATIC_LIBS ON)
|
|
|
|
set(CIVETWEB_USE_STATIC_LIBS ON)
|
|
|
|
ENDIF(STATIC)
|
|
|
|
|
2017-11-04 14:10:41 +01:00
|
|
|
IF(BUNDLE_CIVETWEB)
|
2017-11-04 14:22:25 +01:00
|
|
|
IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
|
|
|
set(DL_LIBRARIES 'dl')
|
|
|
|
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
2017-11-04 14:10:41 +01:00
|
|
|
ENDIF(BUNDLE_CIVETWEB)
|
|
|
|
|
2017-01-29 17:33:31 +01:00
|
|
|
IF(LINK_DL)
|
|
|
|
set(DL_LIBRARIES 'dl')
|
|
|
|
ENDIF(LINK_DL)
|
|
|
|
|
2017-01-29 17:44:45 +01:00
|
|
|
IF(LINK_GCC_S)
|
|
|
|
set(GCC_S_LIBRARIES 'gcc_s')
|
|
|
|
ENDIF(LINK_GCC_S)
|
|
|
|
|
2017-01-31 01:21:13 +01:00
|
|
|
IF(LINK_PTHREAD)
|
|
|
|
set(PTHREAD_LIBRARIES 'pthread')
|
|
|
|
ENDIF(LINK_PTHREAD)
|
|
|
|
|
2017-04-22 02:22:55 +02:00
|
|
|
set (CMAKE_C_STANDARD 11)
|
|
|
|
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=700")
|
2016-09-14 20:08:21 +02:00
|
|
|
|
2016-08-26 19:28:12 +02:00
|
|
|
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}
|
|
|
|
)
|
|
|
|
|
2016-09-14 20:08:21 +02:00
|
|
|
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/")
|
|
|
|
|
2016-12-22 03:12:49 +01:00
|
|
|
find_package(OpenSSL REQUIRED)
|
2017-04-21 09:01:17 +02:00
|
|
|
find_package(LibreSSL)
|
|
|
|
|
2016-12-22 03:12:49 +01:00
|
|
|
MESSAGE(STATUS "OpenSSL include dir: ${OPENSSL_INCLUDE_DIR}")
|
|
|
|
MESSAGE(STATUS "OpenSSL libraries: ${OPENSSL_LIBRARIES}")
|
|
|
|
MESSAGE(STATUS "OpenSSL version: ${OPENSSL_VERSION}")
|
2017-04-21 09:01:17 +02:00
|
|
|
MESSAGE(STATUS "LibreSSL Detected: ${IS_LIBRESSL}")
|
2017-04-21 02:07:28 +02:00
|
|
|
MESSAGE(STATUS "OS Detected: ${CMAKE_SYSTEM_NAME}")
|
2016-12-22 03:12:49 +01:00
|
|
|
|
2017-04-21 08:52:25 +02:00
|
|
|
|
2017-04-21 02:07:28 +02:00
|
|
|
if(NOT(DEFINED OPENSSL_API_1_1))
|
2017-04-21 08:59:20 +02:00
|
|
|
if(${OPENSSL_VERSION} VERSION_GREATER 1.0.99 AND NOT(IS_LIBRESSL))
|
2017-04-21 08:52:25 +02:00
|
|
|
set(OPENSSL_API_1_1 ON)
|
|
|
|
else()
|
|
|
|
set(OPENSSL_API_1_1 OFF)
|
|
|
|
endif()
|
2017-04-21 02:07:28 +02:00
|
|
|
endif()
|
2016-09-07 20:59:10 +02:00
|
|
|
|
2017-04-21 02:25:03 +02:00
|
|
|
|
2017-01-26 19:54:03 +01:00
|
|
|
IF(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
2017-01-27 10:15:38 +01:00
|
|
|
set(SED_FREEBSD "*.c.bak")
|
2017-01-27 00:28:46 +01:00
|
|
|
find_package(argp REQUIRED)
|
2017-01-27 00:35:58 +01:00
|
|
|
add_definitions(-DBSD)
|
2017-01-26 19:54:03 +01:00
|
|
|
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
|
|
|
|
2017-04-21 02:07:28 +02:00
|
|
|
IF(${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
|
|
|
|
find_package(argp REQUIRED)
|
|
|
|
add_definitions(-DBSD)
|
|
|
|
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
|
|
|
|
|
|
|
|
|
2016-09-07 20:59:10 +02:00
|
|
|
if(BUNDLE_CIVETWEB)
|
2017-04-27 21:47:36 +02:00
|
|
|
MESSAGE(STATUS "Building Civetweb From: ${CIVETWEB_GITURL}")
|
2016-09-07 20:59:10 +02:00
|
|
|
ExternalProject_Add( civetweb
|
2017-04-27 21:30:57 +02:00
|
|
|
GIT_REPOSITORY ${CIVETWEB_GITURL}
|
2017-11-04 13:11:33 +01:00
|
|
|
GIT_TAG ${CIVETWEB_GITTAG}
|
2017-01-26 19:54:03 +01:00
|
|
|
PATCH_COMMAND sed -i ${SED_FREEBSD} s/__DATE__/"110973"/ src/main.c src/civetweb.c
|
2016-09-07 20:59:10 +02:00
|
|
|
INSTALL_DIR /usr/local
|
|
|
|
CMAKE_ARGS .. -DCMAKE_INSTALL_PREFIX=/usr
|
2017-11-04 13:11:33 +01:00
|
|
|
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
|
|
|
|
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
|
2016-09-07 20:59:10 +02:00
|
|
|
-DCIVETWEB_ENABLE_CXX=OFF
|
|
|
|
-DBUILD_SHARED_LIBS=OFF
|
|
|
|
-DCIVETWEB_DISABLE_CGI=ON
|
|
|
|
-DCIVETWEB_SERVE_NO_FILES=ON
|
2016-12-22 03:12:49 +01:00
|
|
|
-DCIVETWEB_ENABLE_IPV6=ON
|
|
|
|
-DCIVETWEB_DISABLE_CACHING=ON
|
2016-09-07 20:59:10 +02:00
|
|
|
-DBUILD_TESTING=OFF
|
2016-12-22 03:12:49 +01:00
|
|
|
-DCIVETWEB_SSL_OPENSSL_API_1_1=${OPENSSL_API_1_1}
|
2017-01-30 08:29:17 +01:00
|
|
|
-DOPENSSL_USE_STATIC_LIBS=${OPENSSL_USE_STATIC_LIBS}
|
2017-11-04 14:10:41 +01:00
|
|
|
-DCIVETWEB_ENABLE_SSL_DYNAMIC_LOADING=ON
|
2017-11-04 13:11:33 +01:00
|
|
|
-DCIVETWEB_ALLOW_WARNINGS=ON
|
2017-01-30 08:29:17 +01:00
|
|
|
${CIVETWEB_CUST_ARGS}
|
2016-09-07 20:59:10 +02:00
|
|
|
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-04-21 02:34:07 +02:00
|
|
|
IF(${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
|
|
|
|
set (CMAKE_C_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -lpthread")
|
|
|
|
ELSE(${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
|
|
|
|
set (CMAKE_C_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -lpthread -lrt")
|
|
|
|
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
|
2016-09-07 20:59:10 +02:00
|
|
|
else(BUNDLE_CIVETWEB)
|
|
|
|
find_package(libcivetweb REQUIRED)
|
|
|
|
endif(BUNDLE_CIVETWEB)
|
2015-12-16 23:11:08 +01:00
|
|
|
|
2016-09-07 20:59:10 +02: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
|
2016-08-24 22:13:11 +02:00
|
|
|
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}
|
2016-09-07 20:59:10 +02:00
|
|
|
${LIBCIVETWEB_LIBRARIES}
|
2017-01-27 00:28:46 +01:00
|
|
|
${ARGP_LIBRARIES}
|
2017-01-29 17:33:31 +01:00
|
|
|
${DL_LIBRARIES}
|
2017-01-29 17:44:45 +01:00
|
|
|
${GCC_S_LIBRARIES}
|
2017-01-31 01:21:13 +01:00
|
|
|
${PTHREAD_LIBRARIES}
|
2015-12-17 14:09:09 +01:00
|
|
|
)
|
2015-12-16 23:11:08 +01:00
|
|
|
|
|
|
|
INSTALL(TARGETS uts-server
|
|
|
|
RUNTIME DESTINATION bin
|
|
|
|
)
|
2016-12-04 15:08:46 +01:00
|
|
|
|
|
|
|
if(BUNDLE_CIVETWEB)
|
|
|
|
add_dependencies(uts-server civetweb)
|
|
|
|
endif(BUNDLE_CIVETWEB)
|