adding a switch to link against glibc/dl for static compilation

This commit is contained in:
kakwa 2017-01-29 17:33:31 +01:00
parent 01ec7b5a74
commit 2caed98049
2 changed files with 12 additions and 0 deletions

View File

@ -9,6 +9,7 @@ option(DEBUG "compile with debug symbol" OFF)
option(BUNDLE_CIVETWEB "bundle civetweb with uts-server" OFF)
option(STATIC "static linked binary" OFF)
option(LINKDL "dynamicaly link dl" OFF)
IF(STATIC)
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
@ -19,6 +20,10 @@ IF(STATIC)
set(CIVETWEB_USE_STATIC_LIBS ON)
ENDIF(STATIC)
IF(LINK_DL)
set(DL_LIBRARIES 'dl')
ENDIF(LINK_DL)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=700")
if(DEBUG)
@ -98,6 +103,7 @@ target_link_libraries(uts-server
${OPENSSL_LIBRARIES}
${LIBCIVETWEB_LIBRARIES}
${ARGP_LIBRARIES}
${DL_LIBRARIES}
)
INSTALL(TARGETS uts-server

View File

@ -40,3 +40,9 @@ uts-server is compiled using cmake:
# Compile statically
$ cmake . -DSTATIC=ON
$ make
# Sometimes it might be necessary to link against glibc/dl.
# In that case, the resulting binary is only partially static,
# but it's not possible to do better than that.
$ cmake . -DSTATIC=ON -DLINK_DL=ON
$ make