more cleaning for static compilation

This commit is contained in:
kakwa 2017-01-31 01:21:13 +01:00
parent c74187c9f9
commit e6de3133c7
2 changed files with 10 additions and 5 deletions

View File

@ -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

View File

@ -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::