diff --git a/CMakeLists.txt b/CMakeLists.txt index 0e62cdb..a197c79 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/docs/install.rst b/docs/install.rst index be2650b..b82ee99 100644 --- a/docs/install.rst +++ b/docs/install.rst @@ -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