vcpkg/ports/boost/portfile.cmake

320 lines
13 KiB
CMake
Raw Normal View History

2016-09-19 11:50:08 +08:00
include(vcpkg_common_functions)
2017-08-22 11:41:35 +08:00
set(VERSION 1_65)
2017-09-10 07:40:01 +08:00
set(VERSION_FULL 1_65_1)
set(VERSION2 1.65.1)
set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/boost_${VERSION_FULL})
2016-09-29 07:41:02 +08:00
######################
# Acquire and arrange sources
######################
2016-09-19 11:50:08 +08:00
vcpkg_download_distfile(ARCHIVE_FILE
2017-09-10 07:40:01 +08:00
URLS "https://sourceforge.net/projects/boost/files/boost/${VERSION2}/boost_${VERSION_FULL}.7z" "http://dl.bintray.com/boostorg/release/${VERSION2}/source/boost_${VERSION_FULL}.7z"
FILENAME "boost_${VERSION_FULL}.7z"
SHA512 b1d9264ec74dd75c68176f5a2d2da33a2c1e3162842cc61a07ac8ed1ebb953855cece4faf72ce99b490b665e813b839e35c7fc8026f2f9cb31b106fb8bab2a9c
2016-09-19 11:50:08 +08:00
)
vcpkg_extract_source_archive(${ARCHIVE_FILE})
# apply boost range hotfix
vcpkg_download_distfile(DIFF
URLS "https://github.com/boostorg/range/commit/e7ebe14707130cda7b72e0ae5e93b17157fdb6a2.diff"
FILENAME "boost-range-has_range_iterator-hotfix_e7ebe14707130cda7b72e0ae5e93b17157fdb6a2-2.diff"
SHA512 88392fcf092d07ee2de66d937634688eef1d7491a4e2fb0fce064b4e631813a0814455a329f9eed8b968ff205883751d51a86edecc8e355790fc8a35d6742483
)
FILE(READ "${DIFF}" content)
STRING(REGEX REPLACE "include/" "" content "${content}")
2017-01-27 05:28:07 +08:00
set(DIFF2 ${CURRENT_BUILDTREES_DIR}/src/boost-range-has_range_iterator-hotfix_e7ebe14707130cda7b72e0ae5e93b17157fdb6a2.diff.fixed)
FILE(WRITE ${DIFF2} "${content}")
2017-07-12 23:31:51 +08:00
vcpkg_apply_patches(SOURCE_PATH ${SOURCE_PATH} PATCHES ${DIFF2}
${CMAKE_CURRENT_LIST_DIR}/0001-Fix-boost-ICU-support.patch)
######################
# Cleanup previous builds
######################
file(REMOVE_RECURSE ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel)
if(EXISTS ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel)
# It is possible for a file in this folder to be locked due to antivirus or vctip
execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 1)
file(REMOVE_RECURSE ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel)
if(EXISTS ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel)
message(FATAL_ERROR "Unable to remove directory: ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel\n Files are likely in use.")
endif()
endif()
file(REMOVE_RECURSE ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg)
if(EXISTS ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg)
# It is possible for a file in this folder to be locked due to antivirus or vctip
execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 1)
file(REMOVE_RECURSE ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg)
if(EXISTS ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg)
message(FATAL_ERROR "Unable to remove directory: ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg\n Files are likely in use.")
endif()
endif()
if(EXISTS ${CURRENT_PACKAGES_DIR}/debug)
message(FATAL_ERROR "Error: directory exists: ${CURRENT_PACKAGES_DIR}/debug\n The previous package was not fully cleared. This is an internal error.")
endif()
file(MAKE_DIRECTORY
${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg
${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel)
######################
# Bootstrap b2
######################
2016-09-29 07:41:02 +08:00
if(NOT EXISTS ${SOURCE_PATH}/b2.exe)
2016-09-19 11:50:08 +08:00
message(STATUS "Bootstrapping")
vcpkg_execute_required_process(
2017-08-22 11:41:35 +08:00
COMMAND "${SOURCE_PATH}/bootstrap.bat" msvc
2016-09-29 07:41:02 +08:00
WORKING_DIRECTORY ${SOURCE_PATH}
2016-09-19 11:50:08 +08:00
LOGNAME bootstrap
)
endif()
message(STATUS "Bootstrapping done")
######################
# Generate configuration
######################
2016-09-19 11:50:08 +08:00
set(B2_OPTIONS
2016-11-21 18:43:23 +08:00
-sZLIB_INCLUDE="${CURRENT_INSTALLED_DIR}\\include"
2017-01-09 18:04:18 +08:00
-sBZIP2_INCLUDE="${CURRENT_INSTALLED_DIR}\\include"
2017-07-12 23:31:51 +08:00
-sICU_PATH="${CURRENT_INSTALLED_DIR}"
2016-09-19 11:50:08 +08:00
-j$ENV{NUMBER_OF_PROCESSORS}
--debug-configuration
2016-11-17 09:54:34 +08:00
--hash
2017-03-01 03:03:39 +08:00
-q
2016-11-17 09:54:34 +08:00
threading=multi
2016-09-19 11:50:08 +08:00
)
2016-10-18 14:23:37 +08:00
# Add build type specific options
set(B2_OPTIONS_DBG
-sZLIB_BINARY=zlibd
-sZLIB_LIBPATH="${CURRENT_INSTALLED_DIR}\\debug\\lib"
-sBZIP2_BINARY=bz2d
-sBZIP2_LIBPATH="${CURRENT_INSTALLED_DIR}\\debug\\lib"
)
set(B2_OPTIONS_REL
-sZLIB_BINARY=zlib
-sZLIB_LIBPATH="${CURRENT_INSTALLED_DIR}\\lib"
-sBZIP2_BINARY=bz2
-sBZIP2_LIBPATH="${CURRENT_INSTALLED_DIR}\\lib"
)
2017-07-12 23:31:51 +08:00
set(LIB_RUNTIME_LINK "shared")
2016-10-18 14:23:37 +08:00
if (VCPKG_CRT_LINKAGE STREQUAL dynamic)
list(APPEND B2_OPTIONS runtime-link=shared)
else()
2016-10-18 14:23:37 +08:00
list(APPEND B2_OPTIONS runtime-link=static)
2017-07-12 23:31:51 +08:00
set(LIB_RUNTIME_LINK "static")
2016-10-18 14:23:37 +08:00
endif()
if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
list(APPEND B2_OPTIONS link=shared)
else()
2016-10-18 14:23:37 +08:00
list(APPEND B2_OPTIONS link=static)
endif()
2016-09-19 11:50:08 +08:00
if(TRIPLET_SYSTEM_ARCH MATCHES "x64")
list(APPEND B2_OPTIONS address-model=64)
endif()
2017-03-01 03:03:39 +08:00
if(VCPKG_CMAKE_SYSTEM_NAME MATCHES "WindowsStore")
list(APPEND B2_OPTIONS
windows-api=store
# --without-atomic
# --without-chrono
# --without-system
# --without-date_time
# --without-exception
# --without-serialization
# --without-context
# --without-graph_parallel
# --without-signals
# --without-coroutine2
# --without-graph
# --without-math
# --without-random
# --without-regex
################################
--without-type_erasure # depends on thread
--without-log # depends on filesystem
--without-mpi # Needs "using mpi ;"
--without-wave # depends on filesystem
--without-coroutine # depends on thread
--without-metaparse # depends on test
--without-locale # libs\locale\src\encoding\wconv_codepage.ipp(114): error C3861: 'IsDBCSLeadByteEx': identifier not found
--without-timer # libs\timer\src\cpu_timer.cpp(126): error C2039: 'GetProcessTimes': is not a member of '`global namespace''
--without-program_options # libs\program_options\src\parsers.cpp(194): error C2065: 'environ': undeclared identifier
--without-test
--without-fiber
--without-stacktrace
--without-filesystem # libs\filesystem\src\operations.cpp(178): error C2039: 'GetEnvironmentVariableW': is not a member of '`global namespace''
--without-thread
--without-iostreams
--without-container
2017-07-13 01:12:01 +08:00
--without-python
)
if(VCPKG_PLATFORM_TOOLSET MATCHES "v141")
find_path(PATH_TO_CL cl.exe)
find_path(PLATFORM_WINMD_DIR platform.winmd PATHS "${PATH_TO_CL}/../../../lib/x86/store/references" NO_DEFAULT_PATH)
if(PLATFORM_WINMD_DIR MATCHES "NOTFOUND")
message(FATAL_ERROR "Could not find `platform.winmd` in VS2017. Do you have the Universal Windows Platform development workload installed?")
endif()
else()
find_path(PLATFORM_WINMD_DIR platform.winmd PATHS "$ENV{VS140COMNTOOLS}/../../VC/LIB/store/references")
if(PLATFORM_WINMD_DIR MATCHES "NOTFOUND")
message(FATAL_ERROR "Could not find `platform.winmd` in VS2015.")
endif()
endif()
file(TO_NATIVE_PATH "${PLATFORM_WINMD_DIR}" PLATFORM_WINMD_DIR)
string(REPLACE "\\" "\\\\" PLATFORM_WINMD_DIR ${PLATFORM_WINMD_DIR}) # escape backslashes
configure_file(${CMAKE_CURRENT_LIST_DIR}/uwp/user-config.jam ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/user-config.jam ESCAPE_QUOTES @ONLY)
configure_file(${CMAKE_CURRENT_LIST_DIR}/uwp/user-config.jam ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/user-config.jam ESCAPE_QUOTES @ONLY)
2017-03-01 03:03:39 +08:00
else()
2017-07-13 01:12:01 +08:00
# Find Python. Can't use find_package here, but we already know where everything is
file(GLOB PYTHON_INCLUDE_PATH "${CURRENT_INSTALLED_DIR}/include/python[0-9.]*")
set(PYTHONLIBS_RELEASE "${CURRENT_INSTALLED_DIR}/lib")
set(PYTHONLIBS_DEBUG "${CURRENT_INSTALLED_DIR}/debug/lib")
string(REGEX REPLACE ".*python([0-9\.]+)$" "\\1" PYTHON_VERSION ${PYTHON_INCLUDE_PATH})
configure_file(${CMAKE_CURRENT_LIST_DIR}/desktop/user-config.jam ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/user-config.jam @ONLY)
configure_file(${CMAKE_CURRENT_LIST_DIR}/desktop/user-config.jam ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/user-config.jam @ONLY)
list(APPEND B2_OPTIONS_DBG
python-debugging=on)
2017-03-01 03:03:39 +08:00
endif()
if(VCPKG_PLATFORM_TOOLSET MATCHES "v141")
list(APPEND B2_OPTIONS toolset=msvc-14.1)
elseif(VCPKG_PLATFORM_TOOLSET MATCHES "v140")
list(APPEND B2_OPTIONS toolset=msvc-14.0)
else()
message(FATAL_ERROR "Unsupported value for VCPKG_PLATFORM_TOOLSET: '${VCPKG_PLATFORM_TOOLSET}'")
2016-09-19 11:50:08 +08:00
endif()
2017-01-27 05:28:07 +08:00
set(B2_OPTIONS_DBG
${B2_OPTIONS}
${B2_OPTIONS_DBG}
)
2017-01-27 05:28:07 +08:00
set(B2_OPTIONS_REL
${B2_OPTIONS}
${B2_OPTIONS_REL}
)
######################
# Perform build + Package
######################
2016-09-19 11:50:08 +08:00
message(STATUS "Building ${TARGET_TRIPLET}-rel")
set(ENV{BOOST_BUILD_PATH} ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel)
vcpkg_execute_required_process_repeat(
COUNT 2
2016-09-29 07:41:02 +08:00
COMMAND "${SOURCE_PATH}/b2.exe"
2016-09-19 11:50:08 +08:00
--stagedir=${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/stage
--build-dir=${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel
${B2_OPTIONS_REL}
2016-09-19 11:50:08 +08:00
variant=release
debug-symbols=on
2016-09-29 07:41:02 +08:00
WORKING_DIRECTORY ${SOURCE_PATH}
2016-09-19 11:50:08 +08:00
LOGNAME build-${TARGET_TRIPLET}-rel
)
message(STATUS "Building ${TARGET_TRIPLET}-rel done")
message(STATUS "Building ${TARGET_TRIPLET}-dbg")
set(ENV{BOOST_BUILD_PATH} ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg)
vcpkg_execute_required_process_repeat(
COUNT 2
2016-09-29 07:41:02 +08:00
COMMAND "${SOURCE_PATH}/b2.exe"
2016-09-19 11:50:08 +08:00
--stagedir=${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/stage
--build-dir=${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg
${B2_OPTIONS_DBG}
2016-09-19 11:50:08 +08:00
variant=debug
2016-09-29 07:41:02 +08:00
WORKING_DIRECTORY ${SOURCE_PATH}
2016-09-19 11:50:08 +08:00
LOGNAME build-${TARGET_TRIPLET}-dbg
)
message(STATUS "Building ${TARGET_TRIPLET}-dbg done")
message(STATUS "Packaging headers")
file(
2016-09-29 07:41:02 +08:00
COPY ${SOURCE_PATH}/boost
2016-09-19 11:50:08 +08:00
DESTINATION ${CURRENT_PACKAGES_DIR}/include
)
# Disable Boost auto-link.
file(APPEND ${CURRENT_PACKAGES_DIR}/include/boost/config/user.hpp
"\n#define BOOST_ALL_NO_LIB\n"
)
file(APPEND ${CURRENT_PACKAGES_DIR}/include/boost/config/user.hpp
"\n#undef BOOST_ALL_DYN_LINK\n"
)
if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
file(APPEND ${CURRENT_PACKAGES_DIR}/include/boost/config/user.hpp
"\n#define BOOST_ALL_DYN_LINK\n"
)
endif()
2016-09-29 07:41:02 +08:00
file(INSTALL ${SOURCE_PATH}/LICENSE_1_0.txt DESTINATION ${CURRENT_PACKAGES_DIR}/share/boost RENAME copyright)
2016-09-19 11:50:08 +08:00
message(STATUS "Packaging headers done")
# This function makes the static build lib names match the dynamic build lib names which FindBoost.cmake is looking for by default.
2017-01-27 05:28:07 +08:00
# It also renames a couple of "libboost" lib files in the dynamic build (for example libboost_exception-vc140-mt-1_63.lib).
function(boost_rename_libs LIBS)
foreach(LIB ${${LIBS}})
get_filename_component(OLD_FILENAME ${LIB} NAME)
get_filename_component(DIRECTORY_OF_LIB_FILE ${LIB} DIRECTORY)
string(REPLACE "libboost_" "boost_" NEW_FILENAME ${OLD_FILENAME})
string(REPLACE "-s-" "-" NEW_FILENAME ${NEW_FILENAME}) # For Release libs
2017-03-01 03:03:39 +08:00
string(REPLACE "-vc141-" "-vc140-" NEW_FILENAME ${NEW_FILENAME}) # To merge VS2017 and VS2015 binaries
string(REPLACE "-sgd-" "-gd-" NEW_FILENAME ${NEW_FILENAME}) # For Debug libs
2017-03-02 18:56:35 +08:00
if ("${DIRECTORY_OF_LIB_FILE}/${NEW_FILENAME}" STREQUAL "${DIRECTORY_OF_LIB_FILE}/${OLD_FILENAME}")
# nothing to do
elseif (EXISTS ${DIRECTORY_OF_LIB_FILE}/${NEW_FILENAME})
2016-12-07 05:48:37 +08:00
file(REMOVE ${DIRECTORY_OF_LIB_FILE}/${OLD_FILENAME})
else()
file(RENAME ${DIRECTORY_OF_LIB_FILE}/${OLD_FILENAME} ${DIRECTORY_OF_LIB_FILE}/${NEW_FILENAME})
endif()
endforeach()
endfunction()
2016-09-19 11:50:08 +08:00
message(STATUS "Packaging ${TARGET_TRIPLET}-rel")
file(INSTALL ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/stage/lib/
DESTINATION ${CURRENT_PACKAGES_DIR}/lib
FILES_MATCHING PATTERN "*.lib")
2016-10-18 14:23:37 +08:00
if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
file(INSTALL ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/stage/lib/
DESTINATION ${CURRENT_PACKAGES_DIR}/bin
FILES_MATCHING PATTERN "*.dll")
endif()
2017-03-01 03:03:39 +08:00
file(GLOB RELEASE_LIBS ${CURRENT_PACKAGES_DIR}/lib/*.lib)
boost_rename_libs(RELEASE_LIBS)
if(EXISTS ${CURRENT_PACKAGES_DIR}/lib/boost_test_exec_monitor-vc140-mt-${VERSION}.lib)
file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/lib/manual-link)
file(RENAME
${CURRENT_PACKAGES_DIR}/lib/boost_test_exec_monitor-vc140-mt-${VERSION}.lib
${CURRENT_PACKAGES_DIR}/lib/manual-link/boost_test_exec_monitor-vc140-mt-${VERSION}.lib
)
endif()
2016-09-19 11:50:08 +08:00
message(STATUS "Packaging ${TARGET_TRIPLET}-rel done")
message(STATUS "Packaging ${TARGET_TRIPLET}-dbg")
file(INSTALL ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/stage/lib/
DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib
FILES_MATCHING PATTERN "*.lib")
2016-10-18 14:23:37 +08:00
if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
file(INSTALL ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/stage/lib/
DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin
FILES_MATCHING PATTERN "*.dll")
endif()
2017-03-01 03:03:39 +08:00
file(GLOB DEBUG_LIBS ${CURRENT_PACKAGES_DIR}/debug/lib/*.lib)
boost_rename_libs(DEBUG_LIBS)
if(EXISTS ${CURRENT_PACKAGES_DIR}/debug/lib/boost_test_exec_monitor-vc140-mt-gd-${VERSION}.lib)
file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/debug/lib/manual-link)
file(RENAME
${CURRENT_PACKAGES_DIR}/debug/lib/boost_test_exec_monitor-vc140-mt-gd-${VERSION}.lib
${CURRENT_PACKAGES_DIR}/debug/lib/manual-link/boost_test_exec_monitor-vc140-mt-gd-${VERSION}.lib
)
endif()
2016-09-19 11:50:08 +08:00
message(STATUS "Packaging ${TARGET_TRIPLET}-dbg done")
vcpkg_copy_pdbs()