[boost-modular-build-helper] Fix issue that link incorrect dependent libraries (#9224)

* [boost-modular-build-helper] Fix build issues when release only

* Configure Jamroot.jam on linux

* Fix indentation

Co-authored-by: PhoebeHui <v-phma@microsoft.com>
This commit is contained in:
Phoebe 2020-08-11 08:36:10 +08:00 committed by GitHub
parent 7ad0f085d7
commit 0a16cad007
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 25 deletions

View File

@ -36,8 +36,7 @@ if "@PORT@" != "boost-system"
{
use-project /boost/system : . ;
lib boost_system : : <file>"@CURRENT_INSTALLED_DIR@/lib/@BOOST_LIB_PREFIX@boost_system@BOOST_LIB_RELEASE_SUFFIX@" <variant>release ;
lib boost_system : : <file>"@CURRENT_INSTALLED_DIR@/debug/lib/@BOOST_LIB_PREFIX@boost_system@BOOST_LIB_DEBUG_SUFFIX@" <variant>debug ;
lib boost_system : : <file>"@CURRENT_INSTALLED_DIR@/@BUILD_LIB_PATH@@BOOST_LIB_PREFIX@boost_system@BOOST_LIB_SUFFIX@" <variant>@VARIANT@ ;
explicit boost_system ;
use-project /boost : . ;
@ -48,8 +47,7 @@ if "@PORT@" != "boost-chrono"
{
use-project /boost/chrono : . ;
lib boost_chrono : : <file>"@CURRENT_INSTALLED_DIR@/lib/@BOOST_LIB_PREFIX@boost_chrono@BOOST_LIB_RELEASE_SUFFIX@" <variant>release ;
lib boost_chrono : : <file>"@CURRENT_INSTALLED_DIR@/debug/lib/@BOOST_LIB_PREFIX@boost_chrono@BOOST_LIB_DEBUG_SUFFIX@" <variant>debug ;
lib boost_chrono : : <file>"@CURRENT_INSTALLED_DIR@/@BUILD_LIB_PATH@@BOOST_LIB_PREFIX@boost_chrono@BOOST_LIB_SUFFIX@" <variant>@VARIANT@ ;
explicit boost_chrono ;
}
@ -57,8 +55,7 @@ if "@PORT@" != "boost-regex"
{
use-project /boost/regex : . ;
lib boost_regex : : <file>"@CURRENT_INSTALLED_DIR@/lib/@BOOST_LIB_PREFIX@boost_regex@BOOST_LIB_RELEASE_SUFFIX@" <variant>release ;
lib boost_regex : : <file>"@CURRENT_INSTALLED_DIR@/debug/lib/@BOOST_LIB_PREFIX@boost_regex@BOOST_LIB_DEBUG_SUFFIX@" <variant>debug ;
lib boost_regex : : <file>"@CURRENT_INSTALLED_DIR@/@BUILD_LIB_PATH@@BOOST_LIB_PREFIX@boost_regex@BOOST_LIB_SUFFIX@" <variant>@VARIANT@ ;
explicit boost_regex ;
}
@ -66,8 +63,7 @@ if "@PORT@" != "boost-date-time"
{
use-project /boost/date_time : . ;
lib boost_date_time : : <file>"@CURRENT_INSTALLED_DIR@/lib/@BOOST_LIB_PREFIX@boost_date_time@BOOST_LIB_RELEASE_SUFFIX@" <variant>release -<library>/boost/date_time//boost_date_time ;
lib boost_date_time : : <file>"@CURRENT_INSTALLED_DIR@/debug/lib/@BOOST_LIB_PREFIX@boost_date_time@BOOST_LIB_DEBUG_SUFFIX@" <variant>debug -<library>/boost/date_time//boost_date_time ;
lib boost_date_time : : <file>"@CURRENT_INSTALLED_DIR@/@BUILD_LIB_PATH@@BOOST_LIB_PREFIX@boost_date_time@BOOST_LIB_SUFFIX@" <variant>@VARIANT@ -<library>/boost/date_time//boost_date_time ;
explicit boost_date_time ;
}
@ -75,8 +71,7 @@ if "@PORT@" != "boost-thread"
{
use-project /boost/thread : . ;
lib boost_thread : : <file>"@CURRENT_INSTALLED_DIR@/lib/@BOOST_LIB_PREFIX@boost_thread@BOOST_LIB_RELEASE_SUFFIX@" <variant>release : : <library>/boost/date_time//boost_date_time ;
lib boost_thread : : <file>"@CURRENT_INSTALLED_DIR@/debug/lib/@BOOST_LIB_PREFIX@boost_thread@BOOST_LIB_DEBUG_SUFFIX@" <variant>debug : : <library>/boost/date_time//boost_date_time ;
lib boost_thread : : <file>"@CURRENT_INSTALLED_DIR@/@BUILD_LIB_PATH@@BOOST_LIB_PREFIX@boost_thread@BOOST_LIB_SUFFIX@" <variant>@VARIANT@ : : <library>/boost/date_time//boost_date_time ;
explicit boost_thread ;
}
@ -84,8 +79,7 @@ if "@PORT@" != "boost-timer"
{
use-project /boost/timer : . ;
lib boost_timer : : <file>"@CURRENT_INSTALLED_DIR@/lib/@BOOST_LIB_PREFIX@boost_timer@BOOST_LIB_RELEASE_SUFFIX@" <variant>release ;
lib boost_timer : : <file>"@CURRENT_INSTALLED_DIR@/debug/lib/@BOOST_LIB_PREFIX@boost_timer@BOOST_LIB_DEBUG_SUFFIX@" <variant>debug ;
lib boost_timer : : <file>"@CURRENT_INSTALLED_DIR@/@BUILD_LIB_PATH@@BOOST_LIB_PREFIX@boost_timer@BOOST_LIB_SUFFIX@" <variant>@VARIANT@ ;
explicit boost_timer ;
}
@ -93,8 +87,7 @@ if "@PORT@" != "boost-filesystem"
{
use-project /boost/filesystem : . ;
lib boost_filesystem : : <file>"@CURRENT_INSTALLED_DIR@/lib/@BOOST_LIB_PREFIX@boost_filesystem@BOOST_LIB_RELEASE_SUFFIX@" <variant>release : : <library>/boost/system//boost_system ;
lib boost_filesystem : : <file>"@CURRENT_INSTALLED_DIR@/debug/lib/@BOOST_LIB_PREFIX@boost_filesystem@BOOST_LIB_DEBUG_SUFFIX@" <variant>debug : : <library>/boost/system//boost_system ;
lib boost_filesystem : : <file>"@CURRENT_INSTALLED_DIR@/@BUILD_LIB_PATH@@BOOST_LIB_PREFIX@boost_filesystem@BOOST_LIB_SUFFIX@" <variant>@VARIANT@ : : <library>/boost/system//boost_system ;
explicit boost_filesystem ;
}
@ -102,8 +95,7 @@ if "@PORT@" != "boost-atomic"
{
use-project /boost/atomic : . ;
lib boost_atomic : : <file>"@CURRENT_INSTALLED_DIR@/lib/@BOOST_LIB_PREFIX@boost_atomic@BOOST_LIB_RELEASE_SUFFIX@" <variant>release ;
lib boost_atomic : : <file>"@CURRENT_INSTALLED_DIR@/debug/lib/@BOOST_LIB_PREFIX@boost_atomic@BOOST_LIB_DEBUG_SUFFIX@" <variant>debug ;
lib boost_atomic : : <file>"@CURRENT_INSTALLED_DIR@/@BUILD_LIB_PATH@@BOOST_LIB_PREFIX@boost_atomic@BOOST_LIB_SUFFIX@" <variant>@VARIANT@ ;
explicit boost_atomic ;
}
@ -114,8 +106,7 @@ if "@PORT@" != "boost-context"
use-project /boost/context : . ;
lib boost_context : : <file>"@CURRENT_INSTALLED_DIR@/lib/@BOOST_LIB_PREFIX@boost_context@BOOST_LIB_RELEASE_SUFFIX@" <variant>release ;
lib boost_context : : <file>"@CURRENT_INSTALLED_DIR@/debug/lib/@BOOST_LIB_PREFIX@boost_context@BOOST_LIB_DEBUG_SUFFIX@" <variant>debug ;
lib boost_context : : <file>"@CURRENT_INSTALLED_DIR@/@BUILD_LIB_PATH@@BOOST_LIB_PREFIX@boost_context@BOOST_LIB_SUFFIX@" <variant>@VARIANT@ ;
explicit boost_context ;
}
@ -123,8 +114,7 @@ if "@PORT@" != "boost-test"
{
use-project /boost/test : . ;
lib boost_unit_test_framework : : <file>"@CURRENT_INSTALLED_DIR@/lib/@BOOST_LIB_PREFIX@boost_unit_test_framework@BOOST_LIB_RELEASE_SUFFIX@" <variant>release ;
lib boost_unit_test_framework : : <file>"@CURRENT_INSTALLED_DIR@/debug/lib/@BOOST_LIB_PREFIX@boost_unit_test_framework@BOOST_LIB_DEBUG_SUFFIX@" <variant>debug ;
lib boost_unit_test_framework : : <file>"@CURRENT_INSTALLED_DIR@/@BUILD_LIB_PATH@@BOOST_LIB_PREFIX@boost_unit_test_framework@BOOST_LIB_SUFFIX@" <variant>@VARIANT@ ;
explicit boost_unit_test_framework ;
}
@ -132,8 +122,7 @@ if "@PORT@" != "boost-serialization"
{
use-project /boost/serialization : . ;
lib boost_serialization : : <file>"@CURRENT_INSTALLED_DIR@/lib/@BOOST_LIB_PREFIX@boost_serialization@BOOST_LIB_RELEASE_SUFFIX@" <variant>release ;
lib boost_serialization : : <file>"@CURRENT_INSTALLED_DIR@/debug/lib/@BOOST_LIB_PREFIX@boost_serialization@BOOST_LIB_DEBUG_SUFFIX@" <variant>debug ;
lib boost_serialization : : <file>"@CURRENT_INSTALLED_DIR@/@BUILD_LIB_PATH@@BOOST_LIB_PREFIX@boost_serialization@BOOST_LIB_SUFFIX@" <variant>@VARIANT@ ;
explicit boost_serialization ;
}

View File

@ -81,15 +81,20 @@ function(boost_modular_build)
file(WRITE ${_bm_SOURCE_PATH}/build/Jamfile.v2 "${_contents}")
endif()
configure_file(${_bm_DIR}/Jamroot.jam ${_bm_SOURCE_PATH}/Jamroot.jam @ONLY)
# if(EXISTS "${CURRENT_INSTALLED_DIR}/share/boost-config/checks")
# file(COPY "${CURRENT_INSTALLED_DIR}/share/boost-config/checks" DESTINATION "${_bm_SOURCE_PATH}/build/config")
# endif()
# if(EXISTS "${CURRENT_INSTALLED_DIR}/share/boost-predef/check")
# file(COPY "${CURRENT_INSTALLED_DIR}/share/boost-predef/check" DESTINATION "${_bm_SOURCE_PATH}/build/predef")
# endif()
if(VCPKG_CMAKE_SYSTEM_NAME AND NOT VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
function(unix_build BOOST_LIB_SUFFIX BUILD_TYPE BUILD_LIB_PATH)
message(STATUS "Building ${BUILD_TYPE}...")
set(BOOST_LIB_SUFFIX ${BOOST_LIB_SUFFIX})
set(VARIANT ${BUILD_TYPE})
set(BUILD_LIB_PATH ${BUILD_LIB_PATH})
configure_file(${_bm_DIR}/Jamroot.jam ${_bm_SOURCE_PATH}/Jamroot.jam @ONLY)
set(configure_option)
if(DEFINED _bm_BOOST_CMAKE_FRAGMENT)
list(APPEND configure_option "-DBOOST_CMAKE_FRAGMENT=${_bm_BOOST_CMAKE_FRAGMENT}")
@ -107,6 +112,16 @@ function(boost_modular_build)
${configure_option}
)
vcpkg_install_cmake()
endfunction()
if(VCPKG_CMAKE_SYSTEM_NAME AND NOT VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
unix_build(${BOOST_LIB_RELEASE_SUFFIX} "release" "lib/")
endif()
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
unix_build(${BOOST_LIB_DEBUG_SUFFIX} "debug" "debug/lib/")
endif()
if(NOT EXISTS ${CURRENT_PACKAGES_DIR}/lib)
message(FATAL_ERROR "No libraries were produced. This indicates a failure while building the boost library.")
@ -295,6 +310,10 @@ function(boost_modular_build)
######################
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
message(STATUS "Building ${TARGET_TRIPLET}-rel")
set(BOOST_LIB_SUFFIX ${BOOST_LIB_RELEASE_SUFFIX})
set(VARIANT "release")
set(BUILD_LIB_PATH "lib/")
configure_file(${_bm_DIR}/Jamroot.jam ${_bm_SOURCE_PATH}/Jamroot.jam @ONLY)
set(ENV{BOOST_BUILD_PATH} "${BOOST_BUILD_PATH}")
vcpkg_execute_required_process(
COMMAND "${B2_EXE}"
@ -313,6 +332,10 @@ function(boost_modular_build)
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
message(STATUS "Building ${TARGET_TRIPLET}-dbg")
set(BOOST_LIB_SUFFIX ${BOOST_LIB_DEBUG_SUFFIX})
set(VARIANT debug)
set(BUILD_LIB_PATH "debug/lib/")
configure_file(${_bm_DIR}/Jamroot.jam ${_bm_SOURCE_PATH}/Jamroot.jam @ONLY)
set(ENV{BOOST_BUILD_PATH} "${BOOST_BUILD_PATH}")
vcpkg_execute_required_process(
COMMAND "${B2_EXE}"