diff options
Diffstat (limited to 'src/boost/tools/cmake/include')
-rw-r--r-- | src/boost/tools/cmake/include/BoostFetch.cmake | 97 | ||||
-rw-r--r-- | src/boost/tools/cmake/include/BoostInstall.cmake | 456 | ||||
-rw-r--r-- | src/boost/tools/cmake/include/BoostMessage.cmake | 45 | ||||
-rw-r--r-- | src/boost/tools/cmake/include/BoostRoot.cmake | 311 | ||||
-rw-r--r-- | src/boost/tools/cmake/include/BoostTest.cmake | 217 | ||||
-rw-r--r-- | src/boost/tools/cmake/include/BoostTestJamfile.cmake | 69 |
6 files changed, 1195 insertions, 0 deletions
diff --git a/src/boost/tools/cmake/include/BoostFetch.cmake b/src/boost/tools/cmake/include/BoostFetch.cmake new file mode 100644 index 000000000..327976632 --- /dev/null +++ b/src/boost/tools/cmake/include/BoostFetch.cmake @@ -0,0 +1,97 @@ +# Copyright 2018, 2019 Peter Dimov +# Distributed under the Boost Software License, Version 1.0. +# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt + +if(NOT CMAKE_VERSION VERSION_LESS 3.10) + include_guard() +endif() + +if(NOT COMMAND FetchContent_Populate) + + if(CMAKE_VERSION VERSION_LESS 3.11) + + message(STATUS "Fetching FetchContent.cmake") + + file(DOWNLOAD + "https://gitlab.kitware.com/cmake/cmake/raw/v3.11.3/Modules/FetchContent.cmake" + "${CMAKE_BINARY_DIR}/Modules/FetchContent.cmake" + ) + + file(DOWNLOAD + "https://gitlab.kitware.com/cmake/cmake/raw/v3.11.3/Modules/FetchContent/CMakeLists.cmake.in" + "${CMAKE_BINARY_DIR}/Modules/FetchContent/CMakeLists.cmake.in" + ) + + include(${CMAKE_BINARY_DIR}/Modules/FetchContent.cmake) + + else() + + include(FetchContent) + + endif() + +endif() + +function(boost_fetch) + + cmake_parse_arguments(_ "EXCLUDE_FROM_ALL;NO_ADD_SUBDIR" "TAG" "" ${ARGN}) + + if(NOT __UNPARSED_ARGUMENTS) + + message(FATAL_ERROR "boost_fetch: missing required argument, repository name") + return() + + endif() + + list(GET __UNPARSED_ARGUMENTS 0 REPO) + list(REMOVE_AT __UNPARSED_ARGUMENTS 0) + + if(__UNPARSED_ARGUMENTS) + + message(AUTHOR_WARNING "boost_fetch: extra arguments ignored: ${__UNPARSED_ARGUMENTS}") + + endif() + + if(NOT __TAG) + + set(__TAG master) + + endif() + + string(MAKE_C_IDENTIFIER ${REPO} NAME) + + if(CMAKE_VERSION VERSION_LESS 3.6) + + FetchContent_Declare(${NAME} QUIET GIT_REPOSITORY "https://github.com/${REPO}" GIT_TAG ${__TAG}) + + else() + + FetchContent_Declare(${NAME} QUIET GIT_REPOSITORY "https://github.com/${REPO}" GIT_TAG ${__TAG} GIT_SHALLOW 1) + + endif() + + FetchContent_GetProperties(${NAME}) + + if(NOT ${NAME}_POPULATED) + + message(STATUS "Fetching ${REPO}:${__TAG}") + + FetchContent_Populate(${NAME}) + + if(__NO_ADD_SUBDIR) + + # Skip add_subdirectory + + elseif(__EXCLUDE_FROM_ALL) + + add_subdirectory(${${NAME}_SOURCE_DIR} ${${NAME}_BINARY_DIR} EXCLUDE_FROM_ALL) + + else() + + add_subdirectory(${${NAME}_SOURCE_DIR} ${${NAME}_BINARY_DIR}) + + endif() + + endif() + +endfunction(boost_fetch) diff --git a/src/boost/tools/cmake/include/BoostInstall.cmake b/src/boost/tools/cmake/include/BoostInstall.cmake new file mode 100644 index 000000000..0db87b07d --- /dev/null +++ b/src/boost/tools/cmake/include/BoostInstall.cmake @@ -0,0 +1,456 @@ +# Copyright 2019, 2020, 2021 Peter Dimov +# Distributed under the Boost Software License, Version 1.0. +# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt + +if(NOT CMAKE_VERSION VERSION_LESS 3.10) + include_guard() +endif() + +include(BoostMessage) +include(GNUInstallDirs) +include(CMakePackageConfigHelpers) + +# Variables + +if(WIN32) + set(__boost_default_layout "versioned") +else() + set(__boost_default_layout "system") +endif() + +set(__boost_default_cmakedir "${CMAKE_INSTALL_LIBDIR}/cmake") +set(__boost_default_include_subdir "/boost-${PROJECT_VERSION_MAJOR}_${PROJECT_VERSION_MINOR}") + +# Define cache variables when Boost is the root project + +if(CMAKE_SOURCE_DIR STREQUAL "${BOOST_SUPERPROJECT_SOURCE_DIR}") + + set(BOOST_INSTALL_LAYOUT "${__boost_default_layout}" CACHE STRING "Installation layout (versioned, tagged, or system)") + set_property(CACHE BOOST_INSTALL_LAYOUT PROPERTY STRINGS versioned tagged system) + + set(BOOST_INSTALL_CMAKEDIR "${__boost_default_cmakedir}" CACHE STRING "Installation directory for CMake configuration files") + set(BOOST_INSTALL_INCLUDE_SUBDIR "${__boost_default_include_subdir}" CACHE STRING "Header subdirectory when layout is versioned") + +else() + + # add_subdirectory use + + if(NOT DEFINED BOOST_INSTALL_LAYOUT) + set(BOOST_INSTALL_LAYOUT "${__boost_default_layout}") + endif() + + if(NOT DEFINED BOOST_INSTALL_CMAKEDIR) + set(BOOST_INSTALL_CMAKEDIR "${__boost_default_cmakedir}") + endif() + + if(NOT DEFINED BOOST_INSTALL_INCLUDE_SUBDIR) + set(BOOST_INSTALL_INCLUDE_SUBDIR "${__boost_default_include_subdir}") + endif() + +endif() + +if(BOOST_INSTALL_LAYOUT STREQUAL "versioned") + string(APPEND CMAKE_INSTALL_INCLUDEDIR "${BOOST_INSTALL_INCLUDE_SUBDIR}") +endif() + +# + +if(CMAKE_SOURCE_DIR STREQUAL "${BOOST_SUPERPROJECT_SOURCE_DIR}" AND NOT __boost_install_status_message_guard) + message(STATUS "Boost: using ${BOOST_INSTALL_LAYOUT} layout: ${CMAKE_INSTALL_INCLUDEDIR}, ${CMAKE_INSTALL_BINDIR}, ${CMAKE_INSTALL_LIBDIR}, ${BOOST_INSTALL_CMAKEDIR}") + set(__boost_install_status_message_guard TRUE) +endif() + +# + +function(__boost_install_set_output_name LIB TYPE VERSION) + + set(name_debug ${LIB}) + set(name_release ${LIB}) + + # prefix + if(WIN32 AND TYPE STREQUAL "STATIC_LIBRARY") + set_target_properties(${LIB} PROPERTIES PREFIX "lib") + endif() + + # toolset + if(BOOST_INSTALL_LAYOUT STREQUAL versioned) + + string(TOLOWER ${CMAKE_CXX_COMPILER_ID} toolset) + + if(toolset STREQUAL "msvc") + + set(toolset "vc") + + if(CMAKE_CXX_COMPILER_VERSION MATCHES "^([0-9]+)[.]([0-9]+)") + + if(CMAKE_MATCH_1 GREATER 18) + math(EXPR major ${CMAKE_MATCH_1}-5) + else() + math(EXPR major ${CMAKE_MATCH_1}-6) + endif() + + math(EXPR minor ${CMAKE_MATCH_2}/10) + + string(APPEND toolset ${major}${minor}) + + endif() + + else() + + if(toolset STREQUAL "gnu") + + set(toolset "gcc") + + elseif(toolset STREQUAL "clang") + + if(MSVC) + set(toolset "clangw") + endif() + + endif() + + if(CMAKE_CXX_COMPILER_VERSION MATCHES "^([0-9]+)[.]") + string(APPEND toolset ${CMAKE_MATCH_1}) + endif() + + endif() + + string(APPEND name_debug "-${toolset}") + string(APPEND name_release "-${toolset}") + + endif() + + if(BOOST_INSTALL_LAYOUT STREQUAL versioned OR BOOST_INSTALL_LAYOUT STREQUAL tagged) + + # threading + string(APPEND name_debug "-mt") + string(APPEND name_release "-mt") + + # ABI tag + + if(MSVC) + + get_target_property(MSVC_RUNTIME_LIBRARY ${LIB} MSVC_RUNTIME_LIBRARY) + + if(MSVC_RUNTIME_LIBRARY STREQUAL "MultiThreaded$<$<CONFIG:Debug>:Debug>") + + string(APPEND name_debug "-sgd") + string(APPEND name_release "-s") + + else() + + string(APPEND name_debug "-gd") + + endif() + + else() + + string(APPEND name_debug "-d") + + endif() + + # Arch and model + math(EXPR bits ${CMAKE_SIZEOF_VOID_P}*8) + + string(APPEND name_debug "-x${bits}") # x86 only for now + string(APPEND name_release "-x${bits}") + + endif() + + if(BOOST_INSTALL_LAYOUT STREQUAL versioned) + + string(REGEX REPLACE "^([0-9]+)[.]([0-9]+).*" "\\1_\\2" __ver ${VERSION}) + + string(APPEND name_debug "-${__ver}") + string(APPEND name_release "-${__ver}") + + endif() + + set_target_properties(${LIB} PROPERTIES OUTPUT_NAME_DEBUG ${name_debug}) + set_target_properties(${LIB} PROPERTIES OUTPUT_NAME ${name_release}) + + if(TYPE STREQUAL "STATIC_LIBRARY") + + set_target_properties(${LIB} PROPERTIES COMPILE_PDB_NAME_DEBUG "${name_debug}") + set_target_properties(${LIB} PROPERTIES COMPILE_PDB_NAME "${name_release}") + + endif() + +endfunction() + +function(__boost_install_update_include_directory lib incdir prop) + + get_target_property(value ${lib} ${prop}) + + if(value STREQUAL incdir) + + set_target_properties(${lib} PROPERTIES ${prop} "$<BUILD_INTERFACE:${incdir}>;$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>") + + endif() + +endfunction() + +# Installs a single target +# boost_install_target(TARGET target VERSION version [HEADER_DIRECTORY directory]) + +function(boost_install_target) + + cmake_parse_arguments(_ "" "TARGET;VERSION;HEADER_DIRECTORY" "" ${ARGN}) + + if(NOT __TARGET) + + message(SEND_ERROR "boost_install_target: TARGET not given.") + return() + + endif() + + if(NOT __VERSION) + + message(SEND_ERROR "boost_install_target: VERSION not given, but is required for installation.") + return() + + endif() + + set(LIB ${__TARGET}) + + if(NOT __HEADER_DIRECTORY) + + set(__HEADER_DIRECTORY "${PROJECT_SOURCE_DIR}/include") + + endif() + + get_target_property(TYPE ${LIB} TYPE) + + __boost_install_update_include_directory(${LIB} "${__HEADER_DIRECTORY}" INTERFACE_INCLUDE_DIRECTORIES) + + if(TYPE STREQUAL "STATIC_LIBRARY" OR TYPE STREQUAL "SHARED_LIBRARY") + + __boost_install_update_include_directory(${LIB} "${__HEADER_DIRECTORY}" INCLUDE_DIRECTORIES) + + get_target_property(OUTPUT_NAME ${LIB} OUTPUT_NAME) + + if(NOT OUTPUT_NAME) + __boost_install_set_output_name(${LIB} ${TYPE} ${__VERSION}) + endif() + + endif() + + if(TYPE STREQUAL "SHARED_LIBRARY" OR TYPE STREQUAL "EXECUTABLE") + + get_target_property(VERSION ${LIB} VERSION) + + if(NOT VERSION) + set_target_properties(${LIB} PROPERTIES VERSION ${__VERSION}) + endif() + + endif() + + if(LIB MATCHES "^boost_(.*)$") + set_target_properties(${LIB} PROPERTIES EXPORT_NAME ${CMAKE_MATCH_1}) + endif() + + if(CMAKE_SKIP_INSTALL_RULES) + + boost_message(DEBUG "boost_install_target: not installing target '${__TARGET}' due to CMAKE_SKIP_INSTALL_RULES=${CMAKE_SKIP_INSTALL_RULES}") + return() + + endif() + + set(CONFIG_INSTALL_DIR "${BOOST_INSTALL_CMAKEDIR}/${LIB}-${__VERSION}") + + install(TARGETS ${LIB} EXPORT ${LIB}-targets + # explicit destination specification required for 3.13, 3.14 no longer needs it + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + PRIVATE_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" + PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" + ) + + if(MSVC) + if(TYPE STREQUAL "SHARED_LIBRARY") + install(FILES $<TARGET_PDB_FILE:${LIB}> DESTINATION ${CMAKE_INSTALL_BINDIR} OPTIONAL) + endif() + + if(TYPE STREQUAL "STATIC_LIBRARY" AND NOT CMAKE_VERSION VERSION_LESS 3.15) + install(FILES "$<TARGET_FILE_DIR:${LIB}>/$<TARGET_FILE_PREFIX:${LIB}>$<TARGET_FILE_BASE_NAME:${LIB}>.pdb" DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL) + endif() + endif() + + install(EXPORT ${LIB}-targets DESTINATION "${CONFIG_INSTALL_DIR}" NAMESPACE Boost:: FILE ${LIB}-targets.cmake) + + set(CONFIG_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/tmpinst/${LIB}-config.cmake") + set(CONFIG_FILE_CONTENTS "# Generated by BoostInstall.cmake for ${LIB}-${__VERSION}\n\n") + + get_target_property(INTERFACE_LINK_LIBRARIES ${LIB} INTERFACE_LINK_LIBRARIES) + + set(LINK_LIBRARIES "") + + if(TYPE STREQUAL "STATIC_LIBRARY" OR TYPE STREQUAL "SHARED_LIBRARY") + get_target_property(LINK_LIBRARIES ${LIB} LINK_LIBRARIES) + endif() + + if(INTERFACE_LINK_LIBRARIES OR LINK_LIBRARIES) + + string(APPEND CONFIG_FILE_CONTENTS "include(CMakeFindDependencyMacro)\n\n") + + set(link_libraries ${INTERFACE_LINK_LIBRARIES} ${LINK_LIBRARIES}) + list(REMOVE_DUPLICATES link_libraries) + + set(python_components "") + set(icu_components "") + + foreach(dep IN LISTS link_libraries) + + if(dep MATCHES "^Boost::(.*)$") + + string(APPEND CONFIG_FILE_CONTENTS "find_dependency(boost_${CMAKE_MATCH_1} ${__VERSION} EXACT)\n") + + elseif(dep STREQUAL "Threads::Threads") + + string(APPEND CONFIG_FILE_CONTENTS "set(THREADS_PREFER_PTHREAD_FLAG ON)\n") + string(APPEND CONFIG_FILE_CONTENTS "find_dependency(Threads)\n") + + elseif(dep STREQUAL "ZLIB::ZLIB") + + string(APPEND CONFIG_FILE_CONTENTS "find_dependency(ZLIB)\n") + + elseif(dep STREQUAL "BZip2::BZip2") + + string(APPEND CONFIG_FILE_CONTENTS "find_dependency(BZip2)\n") + + elseif(dep STREQUAL "LibLZMA::LibLZMA") + + string(APPEND CONFIG_FILE_CONTENTS "find_dependency(LibLZMA)\n") + + elseif(dep STREQUAL "zstd::libzstd_shared" OR dep STREQUAL "zstd::libzstd_static") + + string(APPEND CONFIG_FILE_CONTENTS "find_dependency(zstd)\n") + + elseif(dep STREQUAL "MPI::MPI_CXX") + + # COMPONENTS requires 3.9, but the imported target also requires 3.9 + string(APPEND CONFIG_FILE_CONTENTS "find_dependency(MPI COMPONENTS CXX)\n") + + elseif(dep STREQUAL "Iconv::Iconv") + + string(APPEND CONFIG_FILE_CONTENTS "find_dependency(Iconv)\n") + + elseif(dep STREQUAL "Python::Module") + + string(APPEND python_components " Development") + + elseif(dep STREQUAL "Python::NumPy") + + string(APPEND python_components " NumPy") + + elseif(dep STREQUAL "ICU::data") + + string(APPEND icu_components " data") + + elseif(dep STREQUAL "ICU::i18n") + + string(APPEND icu_components " i18n") + + elseif(dep STREQUAL "ICU::uc") + + string(APPEND icu_components " uc") + + endif() + + endforeach() + + if(python_components) + + string(APPEND CONFIG_FILE_CONTENTS "find_dependency(Python COMPONENTS ${python_components})\n") + + endif() + + if(icu_components) + + string(APPEND CONFIG_FILE_CONTENTS "find_dependency(ICU COMPONENTS ${icu_components})\n") + + endif() + + string(APPEND CONFIG_FILE_CONTENTS "\n") + + endif() + + string(APPEND CONFIG_FILE_CONTENTS "include(\"\${CMAKE_CURRENT_LIST_DIR}/${LIB}-targets.cmake\")\n") + + file(WRITE "${CONFIG_FILE_NAME}" "${CONFIG_FILE_CONTENTS}") + install(FILES "${CONFIG_FILE_NAME}" DESTINATION "${CONFIG_INSTALL_DIR}") + + set(CONFIG_VERSION_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/tmpinst/${LIB}-config-version.cmake") + + if(TYPE STREQUAL "INTERFACE_LIBRARY") + + # Header-only libraries are architecture-independent + + if(NOT CMAKE_VERSION VERSION_LESS 3.14) + + write_basic_package_version_file("${CONFIG_VERSION_FILE_NAME}" COMPATIBILITY SameMajorVersion ARCH_INDEPENDENT) + + else() + + set(OLD_CMAKE_SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P}) + set(CMAKE_SIZEOF_VOID_P "") + + write_basic_package_version_file("${CONFIG_VERSION_FILE_NAME}" COMPATIBILITY SameMajorVersion) + + set(CMAKE_SIZEOF_VOID_P ${OLD_CMAKE_SIZEOF_VOID_P}) + + endif() + + else() + + write_basic_package_version_file("${CONFIG_VERSION_FILE_NAME}" COMPATIBILITY SameMajorVersion) + + endif() + + install(FILES "${CONFIG_VERSION_FILE_NAME}" DESTINATION "${CONFIG_INSTALL_DIR}") + +endfunction() + +# boost_install([VERSION version] [TARGETS targets...] [HEADER_DIRECTORY directory]) + +function(boost_install) + + cmake_parse_arguments(_ "" "VERSION;HEADER_DIRECTORY" "TARGETS" ${ARGN}) + + if(NOT __VERSION) + + if(NOT PROJECT_VERSION) + + message(AUTHOR_WARNING "boost_install: VERSION not given, PROJECT_VERSION not set, but a version is required for installation.") + return() + + else() + + boost_message(DEBUG "boost_install: VERSION not given, assuming PROJECT_VERSION ('${PROJECT_VERSION}')") + set(__VERSION ${PROJECT_VERSION}) + + endif() + + endif() + + if(__UNPARSED_ARGUMENTS) + + message(AUTHOR_WARNING "boost_install: extra arguments ignored: ${__UNPARSED_ARGUMENTS}") + + endif() + + if(__HEADER_DIRECTORY AND NOT CMAKE_SKIP_INSTALL_RULES) + + get_filename_component(__HEADER_DIRECTORY "${__HEADER_DIRECTORY}" ABSOLUTE) + install(DIRECTORY "${__HEADER_DIRECTORY}/" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") + + endif() + + foreach(target IN LISTS __TARGETS) + + boost_install_target(TARGET ${target} VERSION ${__VERSION} HEADER_DIRECTORY ${__HEADER_DIRECTORY}) + + endforeach() + +endfunction() diff --git a/src/boost/tools/cmake/include/BoostMessage.cmake b/src/boost/tools/cmake/include/BoostMessage.cmake new file mode 100644 index 000000000..f827f82b6 --- /dev/null +++ b/src/boost/tools/cmake/include/BoostMessage.cmake @@ -0,0 +1,45 @@ +# Copyright 2019 Peter Dimov +# Distributed under the Boost Software License, Version 1.0. +# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt + +if(NOT CMAKE_VERSION VERSION_LESS 3.10) + include_guard() +endif() + +# boost_message( +# [FATAL_ERROR|SEND_ERROR|WARNING|AUTHOR_WARNING|DEPRECATION|NOTICE|STATUS +# |VERBOSE|DEBUG] +# messages...) + +function(boost_message type) + + if(type STREQUAL "VERBOSE") + if(Boost_VERBOSE OR Boost_DEBUG) + set(type STATUS) + elseif(CMAKE_VERSION VERSION_LESS 3.15) + return() + endif() + endif() + + if(type STREQUAL "DEBUG") + if(Boost_DEBUG) + set(type STATUS) + elseif(CMAKE_VERSION VERSION_LESS 3.15) + return() + endif() + endif() + + if(type STREQUAL "NOTICE" AND CMAKE_VERSION VERSION_LESS 3.15) + set(type "") + endif() + + set(m "") + math(EXPR last "${ARGC}-1") + + foreach(i RANGE 1 ${last}) + string(APPEND m "${ARGV${i}}") + endforeach() + + message(${type} "${m}") + +endfunction() diff --git a/src/boost/tools/cmake/include/BoostRoot.cmake b/src/boost/tools/cmake/include/BoostRoot.cmake new file mode 100644 index 000000000..cc1de2530 --- /dev/null +++ b/src/boost/tools/cmake/include/BoostRoot.cmake @@ -0,0 +1,311 @@ +# Copyright 2019-2021 Peter Dimov +# Distributed under the Boost Software License, Version 1.0. +# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt + +if(CMAKE_SOURCE_DIR STREQUAL Boost_SOURCE_DIR AND WIN32 AND CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + + set(CMAKE_INSTALL_PREFIX "C:/Boost" CACHE PATH "Installation path prefix, prepended to installation directories" FORCE) + +endif() + +include(BoostMessage) +include(BoostInstall) + +# + +set(__boost_incompatible_libraries + gil +) + +# Define cache variables if root project + +if(CMAKE_SOURCE_DIR STREQUAL Boost_SOURCE_DIR) + + # --with-<library> + set(BOOST_INCLUDE_LIBRARIES "" CACHE STRING + "List of libraries to build (default: all but excluded and incompatible)") + + # --without-<library> + set(BOOST_EXCLUDE_LIBRARIES "" CACHE STRING + "List of libraries to exclude from build") + + set(BOOST_INCOMPATIBLE_LIBRARIES + "${__boost_incompatible_libraries}" + CACHE STRING + "List of libraries with incompatible CMakeLists.txt files") + + option(BOOST_ENABLE_MPI + "Build and enable installation of Boost.MPI and its dependents (requires MPI, CMake 3.9)") + + option(BOOST_ENABLE_PYTHON + "Build and enable installation of Boost.Python and its dependents (requires Python, CMake 3.14)") + + # --layout, --libdir, --cmakedir, --includedir in BoostInstall + + # runtime-link=static|shared + + set(BOOST_RUNTIME_LINK shared CACHE STRING "Runtime library selection for the MS ABI (shared or static)") + set_property(CACHE BOOST_RUNTIME_LINK PROPERTY STRINGS shared static) + + option(BUILD_TESTING "Build the tests." OFF) + include(CTest) + add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>) + + # link=static|shared + option(BUILD_SHARED_LIBS "Build shared libraries") + + # --stagedir + set(BOOST_STAGEDIR "${CMAKE_CURRENT_BINARY_DIR}/stage" CACHE STRING "Build output directory") + + if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${BOOST_STAGEDIR}/bin") + endif() + + if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${BOOST_STAGEDIR}/lib") + endif() + + if(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY) + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${BOOST_STAGEDIR}/lib") + endif() + +else() + + # add_subdirectory use + + if(NOT DEFINED BOOST_INCOMPATIBLE_LIBRARIES) + set(BOOST_INCOMPATIBLE_LIBRARIES ${__boost_incompatible_libraries}) + endif() + + if(NOT DEFINED BOOST_ENABLE_MPI) + set(BOOST_ENABLE_MPI OFF) + endif() + + if(NOT DEFINED BOOST_ENABLE_PYTHON) + set(BOOST_ENABLE_PYTHON OFF) + endif() + + set(BUILD_TESTING OFF) + set(CMAKE_SKIP_INSTALL_RULES ON) + +endif() + +if(NOT CMAKE_MSVC_RUNTIME_LIBRARY) + + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>") + + if(NOT BOOST_RUNTIME_LINK STREQUAL "static") + string(APPEND CMAKE_MSVC_RUNTIME_LIBRARY "DLL") + endif() + +endif() + +# Output configuration status lines + +set(_msg "") + +if(NOT CMAKE_CONFIGURATION_TYPES AND CMAKE_BUILD_TYPE) + string(APPEND _msg "${CMAKE_BUILD_TYPE} build, ") +endif() + +if(BUILD_SHARED_LIBS) + string(APPEND _msg "shared libraries, ") +else() + string(APPEND _msg "static libraries, ") +endif() + +if(MSVC) + if(CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL "MultiThreaded$<$<CONFIG:Debug>:Debug>") + string(APPEND _msg "static runtime, ") + elseif(CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL") + string(APPEND _msg "shared runtime, ") + endif() +endif() + +string(APPEND _msg "MPI ${BOOST_ENABLE_MPI}, Python ${BOOST_ENABLE_PYTHON}, testing ${BUILD_TESTING}") + +message(STATUS "Boost: ${_msg}") + +unset(_msg) + +if(BOOST_INCLUDE_LIBRARIES) + message(STATUS "Boost: libraries included: ${BOOST_INCLUDE_LIBRARIES}") +endif() + +if(BOOST_EXCLUDE_LIBRARIES) + message(STATUS "Boost: libraries excluded: ${BOOST_EXCLUDE_LIBRARIES}") +endif() + +# Define functions + +function(__boost_auto_install __boost_lib) + if(NOT CMAKE_VERSION VERSION_LESS 3.13) + + string(MAKE_C_IDENTIFIER "${__boost_lib}" __boost_lib_target) + + if(TARGET "Boost::${__boost_lib_target}" AND TARGET "boost_${__boost_lib_target}") + + get_target_property(__boost_lib_incdir "boost_${__boost_lib_target}" INTERFACE_INCLUDE_DIRECTORIES) + + if(__boost_lib_incdir STREQUAL "${BOOST_SUPERPROJECT_SOURCE_DIR}/libs/${__boost_lib}/include") + + boost_message(DEBUG "Enabling installation for '${__boost_lib}'") + boost_install(TARGETS "boost_${__boost_lib_target}" VERSION "${BOOST_SUPERPROJECT_VERSION}" HEADER_DIRECTORY "${BOOST_SUPERPROJECT_SOURCE_DIR}/libs/${__boost_lib}/include") + + else() + boost_message(DEBUG "Not enabling installation for '${__boost_lib}'; interface include directory '${__boost_lib_incdir}' does not equal '${BOOST_SUPERPROJECT_SOURCE_DIR}/libs/${__boost_lib}/include'") + endif() + + else() + boost_message(DEBUG "Not enabling installation for '${__boost_lib}'; targets 'Boost::${__boost_lib_target}' and 'boost_${__boost_lib_target}' weren't found") + endif() + + endif() +endfunction() + +function(__boost_scan_dependencies lib var) + + set(result "") + + if(EXISTS "${BOOST_SUPERPROJECT_SOURCE_DIR}/libs/${lib}/CMakeLists.txt") + + file(STRINGS "${BOOST_SUPERPROJECT_SOURCE_DIR}/libs/${lib}/CMakeLists.txt" data) + + foreach(line IN LISTS data) + + if(line MATCHES "^[ ]*Boost::([A-Za-z0-9_]+)[ ]*$") + + string(REGEX REPLACE "^numeric_" "numeric/" dep ${CMAKE_MATCH_1}) + list(APPEND result ${dep}) + + endif() + + endforeach() + + endif() + + set(${var} ${result} PARENT_SCOPE) + +endfunction() + +# + +file(GLOB __boost_libraries RELATIVE "${BOOST_SUPERPROJECT_SOURCE_DIR}/libs" "${BOOST_SUPERPROJECT_SOURCE_DIR}/libs/*/CMakeLists.txt" "${BOOST_SUPERPROJECT_SOURCE_DIR}/libs/numeric/*/CMakeLists.txt") + +# Check for mistakes in BOOST_INCLUDE_LIBRARIES + +foreach(__boost_included_lib IN LISTS BOOST_INCLUDE_LIBRARIES) + + if(NOT "${__boost_included_lib}/CMakeLists.txt" IN_LIST __boost_libraries) + + message(WARNING "Library '${__boost_included_lib}' given in BOOST_INCLUDE_LIBRARIES has not been found.") + + endif() + +endforeach() + +# Scan for dependencies + +set(__boost_include_libraries ${BOOST_INCLUDE_LIBRARIES}) + +if(__boost_include_libraries) + list(REMOVE_DUPLICATES __boost_include_libraries) +endif() + +set(__boost_libs_to_scan ${__boost_include_libraries}) + +while(__boost_libs_to_scan) + + boost_message(DEBUG "Scanning dependencies: ${__boost_libs_to_scan}") + + set(__boost_dependencies "") + + foreach(__boost_lib IN LISTS __boost_libs_to_scan) + + __boost_scan_dependencies(${__boost_lib} __boost_deps) + list(APPEND __boost_dependencies ${__boost_deps}) + + endforeach() + + list(REMOVE_DUPLICATES __boost_dependencies) + + set(__boost_libs_to_scan ${__boost_dependencies}) + + if(__boost_libs_to_scan) + list(REMOVE_ITEM __boost_libs_to_scan ${__boost_include_libraries}) + endif() + + list(APPEND __boost_include_libraries ${__boost_libs_to_scan}) + +endwhile() + +# Installing targets created in other directories requires CMake 3.13 +if(CMAKE_VERSION VERSION_LESS 3.13) + + boost_message(STATUS "Boost installation support requires CMake 3.13 (have ${CMAKE_VERSION})") + +endif() + +set(__boost_mpi_libs mpi graph_parallel property_map_parallel) +set(__boost_python_libs python parameter_python) + +foreach(__boost_lib_cml IN LISTS __boost_libraries) + + get_filename_component(__boost_lib "${__boost_lib_cml}" DIRECTORY) + + if(__boost_lib IN_LIST BOOST_INCOMPATIBLE_LIBRARIES) + + boost_message(DEBUG "Skipping incompatible Boost library ${__boost_lib}") + + elseif(__boost_lib IN_LIST BOOST_EXCLUDE_LIBRARIES) + + boost_message(DEBUG "Skipping excluded Boost library ${__boost_lib}") + + elseif(NOT BOOST_ENABLE_MPI AND __boost_lib IN_LIST __boost_mpi_libs) + + boost_message(DEBUG "Skipping Boost library ${__boost_lib}, BOOST_ENABLE_MPI is OFF") + + elseif(NOT BOOST_ENABLE_PYTHON AND __boost_lib IN_LIST __boost_python_libs) + + boost_message(DEBUG "Skipping Boost library ${__boost_lib}, BOOST_ENABLE_PYTHON is OFF") + + elseif(NOT BOOST_INCLUDE_LIBRARIES OR __boost_lib IN_LIST BOOST_INCLUDE_LIBRARIES) + + boost_message(VERBOSE "Adding Boost library ${__boost_lib}") + add_subdirectory(libs/${__boost_lib}) + + __boost_auto_install(${__boost_lib}) + + elseif(__boost_lib IN_LIST __boost_include_libraries) + + # Disable tests for dependencies + + set(__boost_build_testing ${BUILD_TESTING}) + set(BUILD_TESTING OFF) # hide cache variable + + boost_message(VERBOSE "Adding Boost dependency ${__boost_lib}") + add_subdirectory(libs/${__boost_lib}) + + __boost_auto_install(${__boost_lib}) + + set(BUILD_TESTING ${__boost_build_testing}) + + elseif(BUILD_TESTING) + + # Disable tests and installation for libraries neither included nor dependencies + + set(__boost_build_testing ${BUILD_TESTING}) + set(BUILD_TESTING OFF) # hide cache variable + + set(__boost_skip_install ${CMAKE_SKIP_INSTALL_RULES}) + set(CMAKE_SKIP_INSTALL_RULES ON) + + boost_message(DEBUG "Adding Boost library ${__boost_lib} with EXCLUDE_FROM_ALL") + add_subdirectory(libs/${__boost_lib} EXCLUDE_FROM_ALL) + + set(BUILD_TESTING ${__boost_build_testing}) + set(CMAKE_SKIP_INSTALL_RULES ${__boost_skip_install}) + + endif() + +endforeach() diff --git a/src/boost/tools/cmake/include/BoostTest.cmake b/src/boost/tools/cmake/include/BoostTest.cmake new file mode 100644 index 000000000..9bc589267 --- /dev/null +++ b/src/boost/tools/cmake/include/BoostTest.cmake @@ -0,0 +1,217 @@ +# Copyright 2018, 2019 Peter Dimov +# Distributed under the Boost Software License, Version 1.0. +# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt + +# Clear global variables on each `include(BoostTest)` + +set(BOOST_TEST_LINK_LIBRARIES "") +set(BOOST_TEST_COMPILE_DEFINITIONS "") +set(BOOST_TEST_COMPILE_OPTIONS "") +set(BOOST_TEST_COMPILE_FEATURES "") + +# Include guard + +if(NOT CMAKE_VERSION VERSION_LESS 3.10) + include_guard() +endif() + +include(BoostMessage) + +# Private helper functions + +function(__boost_test_list_replace list what with) + + set(result "") + + foreach(x IN LISTS ${list}) + + if(x STREQUAL what) + set(x ${with}) + endif() + + list(APPEND result ${x}) + + endforeach() + + set(${list} ${result} PARENT_SCOPE) + +endfunction() + +# boost_test( [TYPE type] [PREFIX prefix] [NAME name] [IGNORE_TEST_GLOBALS] +# SOURCES sources... +# ARGUMENTS args... +# LINK_LIBRARIES libs... +# COMPILE_DEFINITIONS defs... +# COMPILE_OPTIONS opts... +# COMPILE_FEATURES features... +# ) + +function(boost_test) + + cmake_parse_arguments(_ "IGNORE_TEST_GLOBALS" "TYPE;PREFIX;NAME" "SOURCES;ARGUMENTS;LIBRARIES;LINK_LIBRARIES;COMPILE_DEFINITIONS;COMPILE_OPTIONS;COMPILE_FEATURES" ${ARGN}) + + if(NOT __TYPE) + set(__TYPE run) + endif() + + if(NOT __PREFIX) + set(__PREFIX ${PROJECT_NAME}) + endif() + + if(NOT __NAME) + list(GET __SOURCES 0 __NAME) + string(MAKE_C_IDENTIFIER ${__NAME} __NAME) + endif() + + set(__NAME ${__PREFIX}-${__NAME}) + + if(__UNPARSED_ARGUMENTS) + message(AUTHOR_WARNING "Extra arguments for test '${__NAME}' ignored: ${__UNPARSED_ARGUMENTS}") + endif() + + if(__LIBRARIES) + boost_message(VERBOSE "Test '${__NAME}' uses deprecated parameter LIBRARIES; use LINK_LIBRARIES") + endif() + + if(DEFINED BUILD_TESTING AND NOT BUILD_TESTING) + return() + endif() + + if(__IGNORE_TEST_GLOBALS) + + set(BOOST_TEST_LINK_LIBRARIES "") + set(BOOST_TEST_COMPILE_DEFINITIONS "") + set(BOOST_TEST_COMPILE_OPTIONS "") + set(BOOST_TEST_COMPILE_FEATURES "") + + endif() + + list(APPEND BOOST_TEST_LINK_LIBRARIES ${__LIBRARIES} ${__LINK_LIBRARIES}) + list(APPEND BOOST_TEST_COMPILE_DEFINITIONS ${__COMPILE_DEFINITIONS}) + list(APPEND BOOST_TEST_COMPILE_OPTIONS ${__COMPILE_OPTIONS}) + list(APPEND BOOST_TEST_COMPILE_FEATURES ${__COMPILE_FEATURES}) + + if(MSVC) + + __boost_test_list_replace(BOOST_TEST_COMPILE_OPTIONS "-fexceptions" "/GX") + __boost_test_list_replace(BOOST_TEST_COMPILE_OPTIONS "-fno-exceptions" "/GX-") + + __boost_test_list_replace(BOOST_TEST_COMPILE_OPTIONS "-frtti" "/GR") + __boost_test_list_replace(BOOST_TEST_COMPILE_OPTIONS "-fno-rtti" "/GR-") + + __boost_test_list_replace(BOOST_TEST_COMPILE_OPTIONS "-w" "/W0") + __boost_test_list_replace(BOOST_TEST_COMPILE_OPTIONS "-Wall" "/W4") + __boost_test_list_replace(BOOST_TEST_COMPILE_OPTIONS "-Wextra" "") + __boost_test_list_replace(BOOST_TEST_COMPILE_OPTIONS "-pedantic" "") + __boost_test_list_replace(BOOST_TEST_COMPILE_OPTIONS "-Wpedantic" "") + + __boost_test_list_replace(BOOST_TEST_COMPILE_OPTIONS "-Werror" "/WX") + __boost_test_list_replace(BOOST_TEST_COMPILE_OPTIONS "-Wno-error" "/WX-") + + endif() + + foreach(feature IN LISTS BOOST_TEST_COMPILE_FEATURES) + if(NOT feature IN_LIST CMAKE_CXX_COMPILE_FEATURES) + + boost_message(VERBOSE "Test '${__NAME}' skipped, '${feature}' is not supported") + return() + + endif() + endforeach() + + foreach(library IN LISTS BOOST_TEST_LINK_LIBRARIES) + + if(TARGET ${library}) + get_target_property(features ${library} INTERFACE_COMPILE_FEATURES) + + if(features) # need to check because features-NOTFOUND is a valid list + foreach(feature IN LISTS features) + if(NOT feature IN_LIST CMAKE_CXX_COMPILE_FEATURES) + + boost_message(VERBOSE "Test '${__NAME}' skipped, '${feature}' required by '${library}' is not supported") + return() + + endif() + endforeach() + endif() + endif() + endforeach() + + if(NOT TARGET tests) + add_custom_target(tests) + endif() + + if(__TYPE STREQUAL "compile") + + add_library(${__NAME} STATIC EXCLUDE_FROM_ALL ${__SOURCES}) + target_link_libraries(${__NAME} ${BOOST_TEST_LINK_LIBRARIES}) + target_compile_definitions(${__NAME} PRIVATE ${BOOST_TEST_COMPILE_DEFINITIONS}) + target_compile_options(${__NAME} PRIVATE ${BOOST_TEST_COMPILE_OPTIONS}) + target_compile_features(${__NAME} PRIVATE ${BOOST_TEST_COMPILE_FEATURES}) + + add_dependencies(tests ${__NAME}) + + elseif(__TYPE STREQUAL "compile-fail") + + add_library(${__NAME} STATIC EXCLUDE_FROM_ALL ${__SOURCES}) + target_link_libraries(${__NAME} ${BOOST_TEST_LINK_LIBRARIES}) + target_compile_definitions(${__NAME} PRIVATE ${BOOST_TEST_COMPILE_DEFINITIONS}) + target_compile_options(${__NAME} PRIVATE ${BOOST_TEST_COMPILE_OPTIONS}) + target_compile_features(${__NAME} PRIVATE ${BOOST_TEST_COMPILE_FEATURES}) + + add_test(NAME ${__TYPE}-${__NAME} COMMAND "${CMAKE_COMMAND}" --build ${CMAKE_BINARY_DIR} --target ${__NAME} --config $<CONFIG>) + + set_tests_properties(${__TYPE}-${__NAME} PROPERTIES WILL_FAIL TRUE RUN_SERIAL TRUE) + + elseif(__TYPE STREQUAL "link") + + add_executable(${__NAME} EXCLUDE_FROM_ALL ${__SOURCES}) + target_link_libraries(${__NAME} ${BOOST_TEST_LINK_LIBRARIES}) + target_compile_definitions(${__NAME} PRIVATE ${BOOST_TEST_COMPILE_DEFINITIONS}) + target_compile_options(${__NAME} PRIVATE ${BOOST_TEST_COMPILE_OPTIONS}) + target_compile_features(${__NAME} PRIVATE ${BOOST_TEST_COMPILE_FEATURES}) + + add_dependencies(tests ${__NAME}) + + elseif(__TYPE STREQUAL "link-fail") + + add_library(compile-${__NAME} OBJECT EXCLUDE_FROM_ALL ${__SOURCES}) + target_link_libraries(compile-${__NAME} ${BOOST_TEST_LINK_LIBRARIES}) + target_compile_definitions(compile-${__NAME} PRIVATE ${BOOST_TEST_COMPILE_DEFINITIONS}) + target_compile_options(compile-${__NAME} PRIVATE ${BOOST_TEST_COMPILE_OPTIONS}) + target_compile_features(compile-${__NAME} PRIVATE ${BOOST_TEST_COMPILE_FEATURES}) + + add_dependencies(tests compile-${__NAME}) + + add_executable(${__NAME} EXCLUDE_FROM_ALL $<TARGET_OBJECTS:compile-${__NAME}>) + target_link_libraries(${__NAME} ${BOOST_TEST_LINK_LIBRARIES}) + target_compile_definitions(${__NAME} PRIVATE ${BOOST_TEST_COMPILE_DEFINITIONS}) + target_compile_options(${__NAME} PRIVATE ${BOOST_TEST_COMPILE_OPTIONS}) + target_compile_features(${__NAME} PRIVATE ${BOOST_TEST_COMPILE_FEATURES}) + + add_test(NAME ${__TYPE}-${__NAME} COMMAND "${CMAKE_COMMAND}" --build ${CMAKE_BINARY_DIR} --target ${__NAME} --config $<CONFIG>) + set_tests_properties(${__TYPE}-${__NAME} PROPERTIES WILL_FAIL TRUE RUN_SERIAL TRUE) + + elseif(__TYPE STREQUAL "run" OR __TYPE STREQUAL "run-fail") + + add_executable(${__NAME} EXCLUDE_FROM_ALL ${__SOURCES}) + target_link_libraries(${__NAME} ${BOOST_TEST_LINK_LIBRARIES}) + target_compile_definitions(${__NAME} PRIVATE ${BOOST_TEST_COMPILE_DEFINITIONS}) + target_compile_options(${__NAME} PRIVATE ${BOOST_TEST_COMPILE_OPTIONS}) + target_compile_features(${__NAME} PRIVATE ${BOOST_TEST_COMPILE_FEATURES}) + + add_dependencies(tests ${__NAME}) + + add_test(NAME ${__TYPE}-${__NAME} COMMAND ${__NAME} ${__ARGUMENTS}) + + if(__TYPE STREQUAL "run-fail") + set_tests_properties(${__TYPE}-${__NAME} PROPERTIES WILL_FAIL TRUE) + endif() + + else() + + message(AUTHOR_WARNING "Unknown test type '${__TYPE}' for test '${__NAME}'") + + endif() + +endfunction(boost_test) diff --git a/src/boost/tools/cmake/include/BoostTestJamfile.cmake b/src/boost/tools/cmake/include/BoostTestJamfile.cmake new file mode 100644 index 000000000..5fb0464c6 --- /dev/null +++ b/src/boost/tools/cmake/include/BoostTestJamfile.cmake @@ -0,0 +1,69 @@ +# Copyright 2018, 2019 Peter Dimov +# Distributed under the Boost Software License, Version 1.0. +# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt + +# Include BoostTest outside the include guard for it to clear its global variables +include(BoostTest) + +if(NOT CMAKE_VERSION VERSION_LESS 3.10) + include_guard() +endif() + +if(BUILD_TESTING AND CMAKE_VERSION VERSION_LESS 3.9) + message(AUTHOR_WARNING "BoostTestJamfile requires CMake 3.9") # CMAKE_MATCH_x +endif() + +include(BoostMessage) + +# boost_test_jamfile( FILE jamfile [PREFIX prefix] +# LINK_LIBRARIES libs... +# COMPILE_DEFINITIONS defs... +# COMPILE_OPTIONS opts... +# COMPILE_FEATURES features... +# ) + +function(boost_test_jamfile) + + cmake_parse_arguments(_ "" "FILE;PREFIX" "LIBRARIES;LINK_LIBRARIES;COMPILE_DEFINITIONS;COMPILE_OPTIONS;COMPILE_FEATURES" ${ARGN}) + + if(__UNPARSED_ARGUMENTS) + message(AUTHOR_WARNING "boost_test_jamfile: extra arguments ignored: ${__UNPARSED_ARGUMENTS}") + endif() + + if(__LIBRARIES) + message(AUTHOR_WARNING "boost_test_jamfile: LIBRARIES is deprecated, use LINK_LIBRARIES") + endif() + + if(NOT __FILE) + message(AUTHOR_WARNING "boost_test_jamfile: required argument FILE is missing") + return() + endif() + + if(DEFINED BUILD_TESTING AND NOT BUILD_TESTING) + return() + endif() + + file(STRINGS "${__FILE}" data) + + set(types "compile|compile-fail|link|link-fail|run|run-fail") + + foreach(line IN LISTS data) + + if(line MATCHES "^[ \t]*(${types})[ \t]+([^ \t]+)[ \t]*(\;[ \t]*)?$") + + boost_test(PREFIX "${__PREFIX}" TYPE "${CMAKE_MATCH_1}" + SOURCES "${CMAKE_MATCH_2}" + LINK_LIBRARIES ${__LIBRARIES} ${__LINK_LIBRARIES} + COMPILE_DEFINITIONS ${__COMPILE_DEFINITIONS} + COMPILE_OPTIONS ${__COMPILE_OPTIONS} + COMPILE_FEATURES ${__COMPILE_FEATURES} + ) + + elseif(line MATCHES "^[ \t]*(${types})([ \t]|$)") + + boost_message(VERBOSE "boost_test_jamfile: Jamfile line ignored: ${line}") + + endif() + + endforeach() +endfunction() |