1
0
mirror of https://github.com/kakwa/uts-server synced 2024-12-04 23:15:54 +01:00

including module to include argp

This commit is contained in:
kakwa 2017-01-27 00:28:46 +01:00
parent ad35f179c9
commit 53823817cf
3 changed files with 73 additions and 2 deletions

View File

@ -38,6 +38,7 @@ endif()
IF(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
set(SED_FREEBSD "*.c")
find_package(argp REQUIRED)
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
if(BUNDLE_CIVETWEB)
@ -60,7 +61,7 @@ if(BUNDLE_CIVETWEB)
)
set(LIBCIVETWEB_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/vendor/usr/include")
set(LIBCIVETWEB_LIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/vendor/usr/lib/libcivetweb.a")
set (CMAKE_C_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -ldl -lpthread -lrt")
set (CMAKE_C_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -lpthread -lrt")
else(BUNDLE_CIVETWEB)
find_package(libcivetweb REQUIRED)
endif(BUNDLE_CIVETWEB)
@ -71,6 +72,7 @@ include_directories(
./inc/
${LIBCIVETWEB_INCLUDE_DIR}
${OPENSSL_INCLUDE_DIR}
${ARGP_INCLUDE_DIR}
)
add_executable(uts-server
@ -83,6 +85,7 @@ add_executable(uts-server
target_link_libraries(uts-server
${OPENSSL_LIBRARIES}
${LIBCIVETWEB_LIBRARIES}
${ARGP_LIBRARIES}
)
INSTALL(TARGETS uts-server

61
cmake/Findargp.cmake Normal file
View File

@ -0,0 +1,61 @@
# This file is part of CMake-argp.
#
# CMake-argp is free software: you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License along
# with this program. If not, see
#
# http://www.gnu.org/licenses/
#
#
# Copyright (c)
# 2016 Alexander Haase <ahaase@alexhaase.de>
#
include(FindPackageHandleStandardArgs)
include(CheckFunctionExists)
# Check if argp is included in libc:
set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET})
set(CMAKE_REQUIRED_QUIET TRUE)
check_function_exists("argp_parse" ARGP_IN_LIBC)
if (ARGP_IN_LIBC)
set(ARGP_LIBRARIES "c" CACHE STRING "ARGP libraries.")
elseif (NOT ARGP_IN_LIBC)
unset(ARGP_IN_LIBC CACHE)
find_library(ARGP_LIB "argp")
find_path(ARGP_INCLUDE_DIR argp.h PATH_SUFFIXES include)
mark_as_advanced(ARGP_LIB)
if (ARGP_LIB)
set(CMAKE_REQUIRED_LIBRARIES "${ARGP_LIB}")
check_function_exists("argp_parse" ARGP_EXTERNAL)
if (ARGP_EXTERNAL)
set(ARGP_LIBRARIES "${ARGP_LIB}" CACHE STRING "ARGP libraries.")
endif ()
endif ()
endif ()
set(CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE})
find_package_handle_standard_args(argp
FOUND_VAR ARGP_FOUND
REQUIRED_VARS ARGP_LIBRARIES
)
MESSAGE(STATUS "Find Header Directory for argp: " ${ARGP_INCLUDE_DIR})
MESSAGE(STATUS "Find Dynamic Library for arpg: " ${ARGP_LIBRARIES})

View File

@ -4,7 +4,11 @@
#include <getopt.h>
#include <libgen.h>
#include <limits.h>
#ifdef BSD
#include <sys/syslimits.h>
#else
#include <linux/limits.h>
#endif /* BSD */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -94,8 +98,11 @@ int main(int argc, char **argv) {
// other uts-server files (ca, certs, etc) can be declared relatively to the
// configuration file
char *conf_wd = strdup(conf_fp);
#ifdef BSD
conf_wd = dirname(conf_wd);
#else
dirname(conf_wd);
#endif /* BSD */
if (args.daemonize)
skeleton_daemon();