Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preparation for building with shared boost #2611

Merged
merged 4 commits into from
Apr 18, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 71 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ execute_process(
option (CI_BUILD false)
set (CI_TEST 0 CACHE STRING "")

if(MSVC)
add_definitions(/MP)
endif()

set (CPACK_PACKAGE_VERSION_MAJOR "21")
set (CPACK_PACKAGE_VERSION_MINOR "0")
set (CPACK_PACKAGE_VERSION_PATCH "0")
Expand All @@ -37,7 +41,12 @@ else()
set (TAG_VERSION_STRING "V${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
endif()

set (CMAKE_INSTALL_RPATH "@executable_path/../Frameworks")
if (APPLE)
set (CMAKE_INSTALL_RPATH "@executable_path/../Frameworks;@executable_path/../boost/lib")
else()
set (CMAKE_INSTALL_RPATH "$ORIGIN/lib")
endif()

# Create all libraries and executables in the root binary dir
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})

Expand Down Expand Up @@ -219,8 +228,24 @@ endif ()

include_directories (${CMAKE_SOURCE_DIR})

set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
if (WIN32 AND NANO_TEST AND NANO_SHARED_BOOST)
message (SEND_ERROR
" Linking errors occur if NANO_SHARED_BOOST is used with tests on Windows"
" Disable NANO_SHARED_BOOST or NANO_TEST on Windows")
set(NANO_SHARED_BOOST)
endif()

set(NANO_SHARED_BOOST OFF CACHE BOOL "Build Nano with shared boost")

if (NANO_SHARED_BOOST)
SET(Boost_USE_STATIC_LIBS OFF)
SET(Boost_USE_STATIC_RUNTIME OFF)
SET(Boost_NO_BOOST_CMAKE ON)
add_definitions( -DBOOST_ALL_DYN_LINK -DBoost_ALL_NO_LIB)
else()
set(Boost_USE_STATIC_LIBS ON)
endif()
set(Boost_USE_MULTITHREADED ON)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules")

Expand Down Expand Up @@ -515,6 +540,19 @@ if (NANO_GUI OR RAIBLOCKS_GUI)
install (DIRECTORY ${Qt5_DIR}/../../QtTest.framework DESTINATION Nano.app/Contents/Frameworks)
install (DIRECTORY ${Qt5_DIR}/../../QtWidgets.framework DESTINATION Nano.app/Contents/Frameworks)
install (FILES "${Qt5_DIR}/../../../plugins/platforms/libqcocoa.dylib" DESTINATION Nano.app/Contents/PlugIns/platforms)
if (NANO_SHARED_BOOST)
get_filename_component(Boost_LIB_DIR ${BOOST_ROOT}/lib ABSOLUTE)
install (FILES ${Boost_LIB_DIR}/libboost_log.dylib DESTINATION Nano.app/Contents/boost/lib)
install (FILES ${Boost_LIB_DIR}/libboost_filesystem.dylib DESTINATION Nano.app/Contents/boost/lib)
install (FILES ${Boost_LIB_DIR}/libboost_log_setup.dylib DESTINATION Nano.app/Contents/boost/lib)
install (FILES ${Boost_LIB_DIR}/libboost_regex.dylib DESTINATION Nano.app/Contents/boost/lib)
install (FILES ${Boost_LIB_DIR}/libboost_program_options.dylib DESTINATION Nano.app/Contents/boost/lib)
install (FILES ${Boost_LIB_DIR}/libboost_system.dylib DESTINATION Nano.app/Contents/boost/lib)
install (FILES ${Boost_LIB_DIR}/libboost_thread.dylib DESTINATION Nano.app/Contents/boost/lib)
install (FILES ${Boost_LIB_DIR}/libboost_date_time.dylib DESTINATION Nano.app/Contents/boost/lib)
install (FILES ${Boost_LIB_DIR}/libboost_chrono.dylib DESTINATION Nano.app/Contents/boost/lib)
install (FILES ${Boost_LIB_DIR}/libboost_atomic.dylib DESTINATION Nano.app/Contents/boost/lib)
endif()
if (NANO_POW_SERVER)
install (TARGETS nano_pow_server DESTINATION Nano.app/Contents/MacOS)
install (DIRECTORY ${PROJECT_SOURCE_DIR}/nano-pow-server/public DESTINATION Nano.app/Contents/MacOS)
Expand Down Expand Up @@ -543,6 +581,23 @@ if (NANO_GUI OR RAIBLOCKS_GUI)
get_filename_component (Qt5_bin_DIR ${Qt5_DIR}/../../../bin ABSOLUTE)
install (TARGETS nano_wallet DESTINATION .)
install (TARGETS nano_wallet_com DESTINATION .)
if (NANO_SHARED_BOOST)
foreach(boost_lib IN LISTS Boost_LIBRARIES)
if (${CMAKE_BUILD_TYPE} MATCHES "Rel")
string(REGEX MATCH "(.+/.*boost_[^-]+-.+-mt-x64.+\)(.lib|a)" boost_lib_name ${boost_lib})
set (boost_dll "${CMAKE_MATCH_1}.dll")
if (${boost_dll} MATCHES "boost")
install (FILES ${boost_dll} DESTINATION .)
endif()
else ()
string(REGEX MATCH "(.+/.*boost_[^-]+-.+-mt-.+-x64.+\)(.lib|a)" boost_lib_name ${boost_lib})
set (boost_dll "${CMAKE_MATCH_1}.dll")
if (${boost_dll} MATCHES "boost")
install (FILES ${boost_dll} DESTINATION .)
endif()
endif()
endforeach(boost_lib)
endif()
if (NANO_POW_SERVER)
install (TARGETS nano_pow_server DESTINATION .)
install (DIRECTORY ${PROJECT_SOURCE_DIR}/nano-pow-server/public DESTINATION .)
Expand All @@ -559,6 +614,19 @@ if (NANO_GUI OR RAIBLOCKS_GUI)
install(TARGETS nano_wallet
RUNTIME DESTINATION .
)
if (NANO_SHARED_BOOST)
get_filename_component(Boost_LIB_DIR ${BOOST_ROOT}/lib ABSOLUTE)
install (FILES ${Boost_LIB_DIR}/libboost_log.so.${Boost_VERSION_STRING} DESTINATION ./lib)
install (FILES ${Boost_LIB_DIR}/libboost_filesystem.so.${Boost_VERSION_STRING} DESTINATION ./lib)
install (FILES ${Boost_LIB_DIR}/libboost_log_setup.so.${Boost_VERSION_STRING} DESTINATION ./lib)
install (FILES ${Boost_LIB_DIR}/libboost_regex.so.${Boost_VERSION_STRING} DESTINATION ./lib)
install (FILES ${Boost_LIB_DIR}/libboost_program_options.so.${Boost_VERSION_STRING} DESTINATION ./lib)
install (FILES ${Boost_LIB_DIR}/libboost_system.so.${Boost_VERSION_STRING} DESTINATION ./lib)
install (FILES ${Boost_LIB_DIR}/libboost_thread.so.${Boost_VERSION_STRING} DESTINATION ./lib)
install (FILES ${Boost_LIB_DIR}/libboost_date_time.so.${Boost_VERSION_STRING} DESTINATION ./lib)
install (FILES ${Boost_LIB_DIR}/libboost_chrono.so.${Boost_VERSION_STRING} DESTINATION ./lib)
install (FILES ${Boost_LIB_DIR}/libboost_atomic.so.${Boost_VERSION_STRING} DESTINATION ./lib)
endif()
if (NANO_POW_SERVER)
install (TARGETS nano_pow_server DESTINATION .)
install (DIRECTORY ${PROJECT_SOURCE_DIR}/nano-pow-server/public DESTINATION .)
Expand Down
9 changes: 7 additions & 2 deletions util/build_prep/bootstrap_boost.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@ buildArgs=()
useClang='false'
useLibCXX='false'
keepArchive='false'
LINK_TYPE=('link=static')
debugLevel=0
buildCArgs=()
buildCXXArgs=()
buildLDArgs=()
boostVersion='1.67'
while getopts 'hmcCkpvB:' OPT; do
while getopts 'hmscCkpvB:' OPT; do
case "${OPT}" in
h)
echo "Usage: bootstrap_boost.sh [-hmcCkpv] [-B <boostVersion>]"
echo " -h This help"
echo " -s Build shared default builds static"
echo " -m Build a minimal set of libraries needed for Nano"
echo " -c Use Clang"
echo " -C Use libc++ when using Clang"
Expand All @@ -25,6 +27,9 @@ while getopts 'hmcCkpvB:' OPT; do
echo " -B <boostVersion> Specify version of Boost to build"
exit 0
;;
s)
LINK_TYPE+=('link=shared')
;;
m)
bootstrapArgs+=('--with-libraries=system,thread,log,filesystem,program_options')
;;
Expand Down Expand Up @@ -126,7 +131,7 @@ tar xf "${BOOST_ARCHIVE}"

pushd "${BOOST_BASENAME}"
./bootstrap.sh "${bootstrapArgs[@]}"
./b2 -d${debugLevel} --prefix="${BOOST_ROOT}" link=static "${buildArgs[@]}" install
./b2 -d${debugLevel} --prefix="${BOOST_ROOT}" ${LINK_TYPE[@]} "${buildArgs[@]}" install
popd

rm -rf "${BOOST_BASENAME}"
Expand Down