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

adding code in cmake for static compilation

This commit is contained in:
kakwa 2017-01-29 16:31:03 +01:00
parent 79be3ce7a5
commit 01ec7b5a74
4 changed files with 26 additions and 3 deletions

View File

@ -8,6 +8,17 @@ set(VERSION 0.1.4)
option(DEBUG "compile with debug symbol" OFF)
option(BUNDLE_CIVETWEB "bundle civetweb with uts-server" OFF)
option(STATIC "static linked binary" OFF)
IF(STATIC)
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
set(BUILD_SHARED_LIBRARIES OFF)
set(CMAKE_EXE_LINKER_FLAGS "-static")
set(OPENSSL_USE_STATIC_LIBS ON)
set(ARGP_USE_STATIC_LIBS ON)
set(CIVETWEB_USE_STATIC_LIBS ON)
ENDIF(STATIC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=700")
if(DEBUG)

View File

@ -34,7 +34,11 @@ if (ARGP_IN_LIBC)
elseif (NOT ARGP_IN_LIBC)
unset(ARGP_IN_LIBC CACHE)
find_library(ARGP_LIB "argp")
if(ARGP_USE_STATIC_LIBS)
find_library(ARGP_LIB "libargp.a")
else(ARGP_USE_STATIC_LIBS)
find_library(ARGP_LIB "argp")
endif(ARGP_USE_STATIC_LIBS)
find_path(ARGP_INCLUDE_DIR argp.h PATH_SUFFIXES include)
mark_as_advanced(ARGP_LIB)
if (ARGP_LIB)

View File

@ -2,6 +2,10 @@ if (NOT LIBCIVETWEB_LIBRARIES)
find_path(LIBCIVETWEB_INCLUDE_DIR civetweb.h ${_LIBCIVETWEB_PATHS} PATH_SUFFIXES include include/civetweb/)
endif ()
if (NOT LIBCIVETWEB_LIBRARIES)
find_library(LIBCIVETWEB_LIBRARIES NAMES civetweb ${_LIBCIVETWEB_PATHS} PATH_SUFFIXES lib)
if (NOT LIBCIVETWE[DB_LIBRARIES)
if(LIBCIVETWEB_USE_STATIC_LIBS)
find_library(LIBCIVETWEB_LIBRARIES NAMES libcivetweb.a ${_LIBCIVETWEB_PATHS} PATH_SUFFIXES lib)
else(LIBCIVETWEB_USE_STATIC_LIBS)
find_library(LIBCIVETWEB_LIBRARIES NAMES civetweb ${_LIBCIVETWEB_PATHS} PATH_SUFFIXES lib)
endif(LIBCIVETWEB_USE_STATIC_LIBS)
endif ()

View File

@ -36,3 +36,7 @@ uts-server is compiled using cmake:
# Compile with debug flags
$ cmake . -DDEBUG=ON
$ make
# Compile statically
$ cmake . -DSTATIC=ON
$ make