From e6de3133c7f2a53a99c88814e96a7724f508c032 Mon Sep 17 00:00:00 2001 From: kakwa Date: Tue, 31 Jan 2017 01:21:13 +0100 Subject: [PATCH] more cleaning for static compilation --- CMakeLists.txt | 9 +++++++-- docs/install.rst | 6 +++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ae0c6f..bbeb006 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,11 +10,11 @@ option(STATIC "static linked binary" OFF) option(LINK_DL "dynamicaly link dl" OFF) option(LINK_GCC_S "dynamicaly link gcc_s" OFF) option(CIVETWEB_CUST_ARGS "Custom args for civetweb (if civetweb is bundled)" "") +option(LINK_PTHREAD "dynamicaly link pthread" OFF) IF(STATIC) set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") - set(BUILD_SHARED_LIBRARIES OFF) - set(CMAKE_EXE_LINKER_FLAGS "-static") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static") set(OPENSSL_USE_STATIC_LIBS ON) set(ARGP_USE_STATIC_LIBS ON) set(CIVETWEB_USE_STATIC_LIBS ON) @@ -28,6 +28,10 @@ IF(LINK_GCC_S) set(GCC_S_LIBRARIES 'gcc_s') ENDIF(LINK_GCC_S) +IF(LINK_PTHREAD) + set(PTHREAD_LIBRARIES 'pthread') +ENDIF(LINK_PTHREAD) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=700") if(DEBUG) @@ -111,6 +115,7 @@ target_link_libraries(uts-server ${ARGP_LIBRARIES} ${DL_LIBRARIES} ${GCC_S_LIBRARIES} + ${PTHREAD_LIBRARIES} ) INSTALL(TARGETS uts-server diff --git a/docs/install.rst b/docs/install.rst index 37a70f3..bee9177 100644 --- a/docs/install.rst +++ b/docs/install.rst @@ -41,9 +41,9 @@ uts-server is compiled using cmake: # Compile statically # (in some cases, it might be necessary to still - # link some libraries like dl or gcc_s, if necessary, - # add -DDL_LINK=ON and/or -DGCC_S_LINK=ON) - $ cmake . -DSTATIC=ON # -DDL_LINK=ON -DGCC_S_LINK=ON + # link some libraries like dl or gcc_s or pthread, if necessary, + # add -DDL_LINK=ON and/or -DGCC_S_LINK=ON -DPTHREAD_LINK=ON) + $ cmake . -DSTATIC=ON # -DDL_LINK=ON -DGCC_S_LINK=ON -DPTHREAD_LINK=ON $ make .. warning::