Skip to content

Commit

Permalink
Add static linking option through CMAKE and enable through docker ste…
Browse files Browse the repository at this point in the history
  • Loading branch information
mvandeberg committed Aug 25, 2017
1 parent 0147618 commit 0f05bcb
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 15 deletions.
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ if( SKIP_BY_TX_ID )
SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSKIP_BY_TX_ID" )
endif()

OPTION( STEEM_STATIC_BUILD "Build steemd as a static library (ON or OFF)" OFF )
if( STEEM_STATIC_BUILD AND ( ( MSVC AND NOT MINGW ) OR APPLE ) )
MESSAGE( STATUS "Statuc build is not available on Windows or OS X" )
SET( STEEM_STATIC_BUILD OFF )
endif()
MESSAGE( STATUS "STEEM_STATIC_BUILD: ${STEEM_STATIC_BUILD}" )

IF( WIN32 )
SET(BOOST_ROOT $ENV{BOOST_ROOT})
set(Boost_USE_MULTITHREADED ON)
Expand Down
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ FROM phusion/baseimage:0.9.19

#ARG STEEMD_BLOCKCHAIN=https://example.com/steemd-blockchain.tbz2

ARG STEEM_STATIC_BUILD=OFF
ENV STEEM_STATIC_BUILD ${STEEM_STATIC_BUILD}

ENV LANG=en_US.UTF-8

RUN \
Expand Down Expand Up @@ -94,6 +97,7 @@ RUN \
-DCLEAR_VOTES=ON \
-DSKIP_BY_TX_ID=ON \
-DBUILD_STEEM_TESTNET=OFF \
-DSTEEM_STATIC_BUILD=${STEEM_STATIC_BUILD} \
.. \
&& \
make -j$(nproc) && \
Expand All @@ -116,6 +120,7 @@ RUN \
-DCLEAR_VOTES=OFF \
-DSKIP_BY_TX_ID=ON \
-DBUILD_STEEM_TESTNET=OFF \
-DSTEEM_STATIC_BUILD=${STEEM_STATIC_BUILD} \
.. \
&& \
make -j$(nproc) && \
Expand Down
12 changes: 9 additions & 3 deletions programs/cli_wallet/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@ if( GPERFTOOLS_FOUND )
list( APPEND PLATFORM_SPECIFIC_LIBS tcmalloc )
endif()

# I don't know why steemit_app is required twice in the following line, I just know the linker breaks if it isn't.
target_link_libraries( cli_wallet
PRIVATE steemit_app graphene_net steemit_chain steemit_protocol graphene_utilities steemit_wallet steemit_private_message steemit_app steemit_follow fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} )
if( STEEM_STATIC_BUILD )
# I don't know why steemit_app is required twice in the following line, I just know the linker breaks if it isn't.
target_link_libraries( cli_wallet PRIVATE
"-static-libstdc++ -static-libgcc -lreadline"
steemit_app graphene_net steemit_chain steemit_protocol graphene_utilities steemit_wallet steemit_private_message steemit_app steemit_follow fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} )
else( STEEM_STATIC_BUILD )
target_link_libraries( cli_wallet PRIVATE
steemit_app graphene_net steemit_chain steemit_protocol graphene_utilities steemit_wallet steemit_private_message steemit_app steemit_follow fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} )
endif( STEEM_STATIC_BUILD )

if(MSVC)
set_source_files_properties( main.cpp PROPERTIES COMPILE_FLAGS "/bigobj" )
Expand Down
40 changes: 28 additions & 12 deletions programs/steemd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,34 @@ if( GPERFTOOLS_FOUND )
list( APPEND PLATFORM_SPECIFIC_LIBS tcmalloc )
endif()

target_link_libraries( steemd PRIVATE
steemit_plugins
steemit_mf_plugins
steemit_app
steemit_witness
steemit_account_history
steemit_chain
steemit_protocol
fc
${CMAKE_DL_LIBS}
${PLATFORM_SPECIFIC_LIBS}
)
if( STEEM_STATIC_BUILD )
target_link_libraries( steemd PRIVATE
"-static-libstdc++ -static-libgcc"
steemit_plugins
steemit_mf_plugins
steemit_app
steemit_witness
steemit_account_history
steemit_chain
steemit_protocol
fc
${CMAKE_DL_LIBS}
${PLATFORM_SPECIFIC_LIBS}
)
else( STEEM_STATIC_BUILD )
target_link_libraries( steemd PRIVATE
steemit_plugins
steemit_mf_plugins
steemit_app
steemit_witness
steemit_account_history
steemit_chain
steemit_protocol
fc
${CMAKE_DL_LIBS}
${PLATFORM_SPECIFIC_LIBS}
)
endif( STEEM_STATIC_BUILD )

install( TARGETS
steemd
Expand Down

0 comments on commit 0f05bcb

Please sign in to comment.