From e6918187568dbd01842d8d1d2c808ce16a894239 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 21 Apr 2024 13:54:28 +0200 Subject: Adding upstream version 18.2.2. Signed-off-by: Daniel Baumann --- src/boost/tools/cmake/README.md | 5 + src/boost/tools/cmake/include/BoostFetch.cmake | 97 +++++ src/boost/tools/cmake/include/BoostInstall.cmake | 456 +++++++++++++++++++++ src/boost/tools/cmake/include/BoostMessage.cmake | 45 ++ src/boost/tools/cmake/include/BoostRoot.cmake | 311 ++++++++++++++ src/boost/tools/cmake/include/BoostTest.cmake | 217 ++++++++++ .../tools/cmake/include/BoostTestJamfile.cmake | 69 ++++ .../tools/cmake/test/add_subdir/CMakeLists.txt | 18 + src/boost/tools/cmake/test/add_subdir/main.cpp | 11 + .../tools/cmake/test/add_subdir_exc/CMakeLists.txt | 18 + src/boost/tools/cmake/test/add_subdir_exc/main.cpp | 11 + src/boost/tools/cmake/test/assert/CMakeLists.txt | 17 + src/boost/tools/cmake/test/assert/main.cpp | 11 + src/boost/tools/cmake/test/atomic/CMakeLists.txt | 21 + src/boost/tools/cmake/test/atomic/main.cpp | 16 + .../tools/cmake/test/boost_fetch/CMakeLists.txt | 27 ++ src/boost/tools/cmake/test/boost_fetch/main.cpp | 14 + .../tools/cmake/test/boost_test/CMakeLists.txt | 58 +++ src/boost/tools/cmake/test/boost_test/Jamfile | 21 + .../tools/cmake/test/boost_test/arguments.cpp | 18 + src/boost/tools/cmake/test/boost_test/compile.cpp | 8 + .../tools/cmake/test/boost_test/compile_fail.cpp | 8 + .../tools/cmake/test/boost_test/emits_warning.cpp | 9 + src/boost/tools/cmake/test/boost_test/link.cpp | 13 + .../tools/cmake/test/boost_test/link_fail.cpp | 10 + .../test/boost_test/requires_no_exceptions.cpp | 18 + .../cmake/test/boost_test/requires_no_rtti.cpp | 18 + .../boost_test/requires_variadic_templates.cpp | 13 + .../cmake/test/boost_test/return_exit_code.cpp | 8 + src/boost/tools/cmake/test/boost_test/run.cpp | 7 + src/boost/tools/cmake/test/boost_test/run_fail.cpp | 8 + .../tools/cmake/test/iostreams/CMakeLists.txt | 21 + src/boost/tools/cmake/test/iostreams/test.txt | 1 + src/boost/tools/cmake/test/iostreams/test_fd.cpp | 22 + src/boost/tools/cmake/test/locale/CMakeLists.txt | 21 + src/boost/tools/cmake/test/locale/main.cpp | 32 ++ src/boost/tools/cmake/test/mp11/CMakeLists.txt | 17 + src/boost/tools/cmake/test/mp11/main.cpp | 12 + src/boost/tools/cmake/test/timer/CMakeLists.txt | 21 + src/boost/tools/cmake/test/timer/main.cpp | 11 + 40 files changed, 1739 insertions(+) create mode 100644 src/boost/tools/cmake/README.md create mode 100644 src/boost/tools/cmake/include/BoostFetch.cmake create mode 100644 src/boost/tools/cmake/include/BoostInstall.cmake create mode 100644 src/boost/tools/cmake/include/BoostMessage.cmake create mode 100644 src/boost/tools/cmake/include/BoostRoot.cmake create mode 100644 src/boost/tools/cmake/include/BoostTest.cmake create mode 100644 src/boost/tools/cmake/include/BoostTestJamfile.cmake create mode 100644 src/boost/tools/cmake/test/add_subdir/CMakeLists.txt create mode 100644 src/boost/tools/cmake/test/add_subdir/main.cpp create mode 100644 src/boost/tools/cmake/test/add_subdir_exc/CMakeLists.txt create mode 100644 src/boost/tools/cmake/test/add_subdir_exc/main.cpp create mode 100644 src/boost/tools/cmake/test/assert/CMakeLists.txt create mode 100644 src/boost/tools/cmake/test/assert/main.cpp create mode 100644 src/boost/tools/cmake/test/atomic/CMakeLists.txt create mode 100644 src/boost/tools/cmake/test/atomic/main.cpp create mode 100644 src/boost/tools/cmake/test/boost_fetch/CMakeLists.txt create mode 100644 src/boost/tools/cmake/test/boost_fetch/main.cpp create mode 100644 src/boost/tools/cmake/test/boost_test/CMakeLists.txt create mode 100644 src/boost/tools/cmake/test/boost_test/Jamfile create mode 100644 src/boost/tools/cmake/test/boost_test/arguments.cpp create mode 100644 src/boost/tools/cmake/test/boost_test/compile.cpp create mode 100644 src/boost/tools/cmake/test/boost_test/compile_fail.cpp create mode 100644 src/boost/tools/cmake/test/boost_test/emits_warning.cpp create mode 100644 src/boost/tools/cmake/test/boost_test/link.cpp create mode 100644 src/boost/tools/cmake/test/boost_test/link_fail.cpp create mode 100644 src/boost/tools/cmake/test/boost_test/requires_no_exceptions.cpp create mode 100644 src/boost/tools/cmake/test/boost_test/requires_no_rtti.cpp create mode 100644 src/boost/tools/cmake/test/boost_test/requires_variadic_templates.cpp create mode 100644 src/boost/tools/cmake/test/boost_test/return_exit_code.cpp create mode 100644 src/boost/tools/cmake/test/boost_test/run.cpp create mode 100644 src/boost/tools/cmake/test/boost_test/run_fail.cpp create mode 100644 src/boost/tools/cmake/test/iostreams/CMakeLists.txt create mode 100644 src/boost/tools/cmake/test/iostreams/test.txt create mode 100644 src/boost/tools/cmake/test/iostreams/test_fd.cpp create mode 100644 src/boost/tools/cmake/test/locale/CMakeLists.txt create mode 100644 src/boost/tools/cmake/test/locale/main.cpp create mode 100644 src/boost/tools/cmake/test/mp11/CMakeLists.txt create mode 100644 src/boost/tools/cmake/test/mp11/main.cpp create mode 100644 src/boost/tools/cmake/test/timer/CMakeLists.txt create mode 100644 src/boost/tools/cmake/test/timer/main.cpp (limited to 'src/boost/tools/cmake') diff --git a/src/boost/tools/cmake/README.md b/src/boost/tools/cmake/README.md new file mode 100644 index 000000000..dbc34d36c --- /dev/null +++ b/src/boost/tools/cmake/README.md @@ -0,0 +1,5 @@ +# tools/cmake + +This repository hosts the `tools/cmake` Boost submodule, containing experimental CMake support infrastructure for Boost. + +Note that building Boost with CMake _does not work yet and is not supported_. The supported way to build Boost is [with `b2`](https://www.boost.org/more/getting_started/index.html). 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$<$: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} "$;$") + + 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 $ DESTINATION ${CMAKE_INSTALL_BINDIR} OPTIONAL) + endif() + + if(TYPE STREQUAL "STATIC_LIBRARY" AND NOT CMAKE_VERSION VERSION_LESS 3.15) + install(FILES "$/$$.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- + set(BOOST_INCLUDE_LIBRARIES "" CACHE STRING + "List of libraries to build (default: all but excluded and incompatible)") + + # --without- + 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 $) + + # 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$<$: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$<$:Debug>") + string(APPEND _msg "static runtime, ") + elseif(CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL "MultiThreaded$<$: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 $) + + 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_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 $) + 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() diff --git a/src/boost/tools/cmake/test/add_subdir/CMakeLists.txt b/src/boost/tools/cmake/test/add_subdir/CMakeLists.txt new file mode 100644 index 000000000..132435833 --- /dev/null +++ b/src/boost/tools/cmake/test/add_subdir/CMakeLists.txt @@ -0,0 +1,18 @@ +# Copyright 2018-2021 Peter Dimov +# Distributed under the Boost Software License, Version 1.0. +# https://www.boost.org/LICENSE_1_0.txt + +cmake_minimum_required(VERSION 3.5...3.20) + +project(boost_add_sibdir_test LANGUAGES CXX) + +include(CTest) + +set(BOOST_INCLUDE_LIBRARIES timer) + +add_subdirectory(../../../.. deps/boost) + +add_executable(main main.cpp) +target_link_libraries(main Boost::timer) + +add_test(NAME main COMMAND main) diff --git a/src/boost/tools/cmake/test/add_subdir/main.cpp b/src/boost/tools/cmake/test/add_subdir/main.cpp new file mode 100644 index 000000000..25ce9c842 --- /dev/null +++ b/src/boost/tools/cmake/test/add_subdir/main.cpp @@ -0,0 +1,11 @@ +// 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 + +#include + +int main() +{ + boost::timer::cpu_timer timer; + timer.stop(); +} diff --git a/src/boost/tools/cmake/test/add_subdir_exc/CMakeLists.txt b/src/boost/tools/cmake/test/add_subdir_exc/CMakeLists.txt new file mode 100644 index 000000000..20bd38949 --- /dev/null +++ b/src/boost/tools/cmake/test/add_subdir_exc/CMakeLists.txt @@ -0,0 +1,18 @@ +# Copyright 2018-2021 Peter Dimov +# Distributed under the Boost Software License, Version 1.0. +# https://www.boost.org/LICENSE_1_0.txt + +cmake_minimum_required(VERSION 3.5...3.20) + +project(boost_add_sibdir_exc_test LANGUAGES CXX) + +include(CTest) + +# set(BOOST_INCLUDE_LIBRARIES timer) + +add_subdirectory(../../../.. deps/boost EXCLUDE_FROM_ALL) + +add_executable(main main.cpp) +target_link_libraries(main Boost::timer) + +add_test(NAME main COMMAND main) diff --git a/src/boost/tools/cmake/test/add_subdir_exc/main.cpp b/src/boost/tools/cmake/test/add_subdir_exc/main.cpp new file mode 100644 index 000000000..25ce9c842 --- /dev/null +++ b/src/boost/tools/cmake/test/add_subdir_exc/main.cpp @@ -0,0 +1,11 @@ +// 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 + +#include + +int main() +{ + boost::timer::cpu_timer timer; + timer.stop(); +} diff --git a/src/boost/tools/cmake/test/assert/CMakeLists.txt b/src/boost/tools/cmake/test/assert/CMakeLists.txt new file mode 100644 index 000000000..d358816f8 --- /dev/null +++ b/src/boost/tools/cmake/test/assert/CMakeLists.txt @@ -0,0 +1,17 @@ +# 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 + +cmake_minimum_required(VERSION 3.5...3.16) + +project(boost_assert_install_test LANGUAGES CXX) + +find_package(boost_assert REQUIRED) + +add_executable(main main.cpp) +target_link_libraries(main Boost::assert) + +enable_testing() +add_test(NAME main COMMAND main) + +add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $) diff --git a/src/boost/tools/cmake/test/assert/main.cpp b/src/boost/tools/cmake/test/assert/main.cpp new file mode 100644 index 000000000..305a35441 --- /dev/null +++ b/src/boost/tools/cmake/test/assert/main.cpp @@ -0,0 +1,11 @@ +// 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 + +#include + +int main() +{ + int x = 5; + BOOST_ASSERT( x > 4 ); +} diff --git a/src/boost/tools/cmake/test/atomic/CMakeLists.txt b/src/boost/tools/cmake/test/atomic/CMakeLists.txt new file mode 100644 index 000000000..983c15cf8 --- /dev/null +++ b/src/boost/tools/cmake/test/atomic/CMakeLists.txt @@ -0,0 +1,21 @@ +# 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 + +cmake_minimum_required(VERSION 3.5...3.16) + +project(boost_atomic_install_test LANGUAGES CXX) + +if(BOOST_RUNTIME_LINK STREQUAL "static") + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") +endif() + +find_package(boost_atomic REQUIRED) + +add_executable(main main.cpp) +target_link_libraries(main Boost::atomic) + +enable_testing() +add_test(NAME main COMMAND main) + +add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $) diff --git a/src/boost/tools/cmake/test/atomic/main.cpp b/src/boost/tools/cmake/test/atomic/main.cpp new file mode 100644 index 000000000..21d11af8b --- /dev/null +++ b/src/boost/tools/cmake/test/atomic/main.cpp @@ -0,0 +1,16 @@ +// 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 + +#include + +struct X +{ + double v[ 8 ]; +}; + +int main() +{ + boost::atomic a; + a.store( X() ); +} diff --git a/src/boost/tools/cmake/test/boost_fetch/CMakeLists.txt b/src/boost/tools/cmake/test/boost_fetch/CMakeLists.txt new file mode 100644 index 000000000..e193ca785 --- /dev/null +++ b/src/boost/tools/cmake/test/boost_fetch/CMakeLists.txt @@ -0,0 +1,27 @@ +# 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 + +cmake_minimum_required(VERSION 3.5...3.16) + +project(boost_fetch_test LANGUAGES CXX) + +include("${CMAKE_CURRENT_SOURCE_DIR}/../../include/BoostFetch.cmake") + +include(CTest) +add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $) + +set(BUILD_TESTING OFF) # hide cache variable + +boost_fetch(boostorg/assert TAG develop EXCLUDE_FROM_ALL) +boost_fetch(boostorg/config TAG develop EXCLUDE_FROM_ALL) +boost_fetch(boostorg/core TAG develop EXCLUDE_FROM_ALL) +boost_fetch(boostorg/static_assert TAG develop EXCLUDE_FROM_ALL) +boost_fetch(boostorg/throw_exception TAG develop EXCLUDE_FROM_ALL) + +unset(BUILD_TESTING) + +add_executable(main main.cpp) +target_link_libraries(main Boost::core) + +add_test(NAME main COMMAND main) diff --git a/src/boost/tools/cmake/test/boost_fetch/main.cpp b/src/boost/tools/cmake/test/boost_fetch/main.cpp new file mode 100644 index 000000000..639b9c37a --- /dev/null +++ b/src/boost/tools/cmake/test/boost_fetch/main.cpp @@ -0,0 +1,14 @@ +// 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 + +#include + +int main() +{ + int x = 5; + + BOOST_TEST_GT( x, 4 ); + + return boost::report_errors(); +} diff --git a/src/boost/tools/cmake/test/boost_test/CMakeLists.txt b/src/boost/tools/cmake/test/boost_test/CMakeLists.txt new file mode 100644 index 000000000..22dfaad0b --- /dev/null +++ b/src/boost/tools/cmake/test/boost_test/CMakeLists.txt @@ -0,0 +1,58 @@ +# 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 + +cmake_minimum_required(VERSION 3.5...3.16) + +project(boost_cmake_test LANGUAGES CXX) + +include(CTest) + +set(BUILD_TESTING OFF) # hide cache variable + +add_subdirectory(../../../../libs/assert EXCLUDE_FROM_ALL boostorg/assert) +add_subdirectory(../../../../libs/config EXCLUDE_FROM_ALL boostorg/config) +add_subdirectory(../../../../libs/core EXCLUDE_FROM_ALL boostorg/core) +add_subdirectory(../../../../libs/static_assert EXCLUDE_FROM_ALL boostorg/static_assert) +add_subdirectory(../../../../libs/throw_exception EXCLUDE_FROM_ALL boostorg/throw_exception) + +unset(BUILD_TESTING) + +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../include) + +# boost_test + +include(BoostTest) + +boost_test(TYPE compile SOURCES compile.cpp) +boost_test(TYPE compile-fail SOURCES compile_fail.cpp) +boost_test(TYPE link SOURCES link.cpp) +boost_test(TYPE link-fail SOURCES link_fail.cpp) +boost_test(TYPE run SOURCES run.cpp) +boost_test(TYPE run-fail SOURCES run_fail.cpp) + +boost_test(TYPE run SOURCES arguments.cpp ARGUMENTS pumpkin LINK_LIBRARIES Boost::core) + +boost_test(TYPE run NAME return_exit_code_pass SOURCES return_exit_code.cpp COMPILE_DEFINITIONS EXIT_CODE=0) +boost_test(TYPE run-fail NAME return_exit_code_fail SOURCES return_exit_code.cpp COMPILE_DEFINITIONS EXIT_CODE=1) + +boost_test(TYPE run SOURCES requires_variadic_templates.cpp COMPILE_FEATURES cxx_variadic_templates) + +boost_test(TYPE run SOURCES requires_no_rtti.cpp COMPILE_OPTIONS -fno-rtti LINK_LIBRARIES Boost::config) +boost_test(TYPE run SOURCES requires_no_exceptions.cpp COMPILE_OPTIONS -fno-exceptions LINK_LIBRARIES Boost::config) + +boost_test(TYPE compile-fail SOURCES emits_warning.cpp COMPILE_OPTIONS -Wall -Werror) + +# boost_test, w/ globals + +set(BOOST_TEST_COMPILE_OPTIONS -fno-rtti -fno-exceptions) +set(BOOST_TEST_LINK_LIBRARIES Boost::config) + +boost_test(SOURCES requires_no_rtti.cpp PREFIX boost_cmake_test_globals) +boost_test(SOURCES requires_no_exceptions.cpp PREFIX boost_cmake_test_globals) + +# boost_test_jamfile + +include(BoostTestJamfile) + +boost_test_jamfile(FILE Jamfile PREFIX boost_cmake_test_jamfile) diff --git a/src/boost/tools/cmake/test/boost_test/Jamfile b/src/boost/tools/cmake/test/boost_test/Jamfile new file mode 100644 index 000000000..a1ae7b093 --- /dev/null +++ b/src/boost/tools/cmake/test/boost_test/Jamfile @@ -0,0 +1,21 @@ +# 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 + +import testing ; + +project + : default-build on +; + +compile compile.cpp ; +compile-fail compile_fail.cpp ; +link link.cpp ; +link-fail link_fail.cpp ; +run run.cpp ; +run-fail run_fail.cpp + : ; + +run + arguments.cpp : + pumpkin ; diff --git a/src/boost/tools/cmake/test/boost_test/arguments.cpp b/src/boost/tools/cmake/test/boost_test/arguments.cpp new file mode 100644 index 000000000..8ebe8eddb --- /dev/null +++ b/src/boost/tools/cmake/test/boost_test/arguments.cpp @@ -0,0 +1,18 @@ +// Copyright 2018 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 +#include + +int main( int ac, char const* av[] ) +{ + BOOST_TEST_EQ( ac, 2 ); + + if( ac >= 2 ) + { + BOOST_TEST_CSTR_EQ( av[1], "pumpkin" ); + } + + return boost::report_errors(); +} diff --git a/src/boost/tools/cmake/test/boost_test/compile.cpp b/src/boost/tools/cmake/test/boost_test/compile.cpp new file mode 100644 index 000000000..07df2b88a --- /dev/null +++ b/src/boost/tools/cmake/test/boost_test/compile.cpp @@ -0,0 +1,8 @@ +// Copyright 2018 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 + +int f() +{ + return 0; +} diff --git a/src/boost/tools/cmake/test/boost_test/compile_fail.cpp b/src/boost/tools/cmake/test/boost_test/compile_fail.cpp new file mode 100644 index 000000000..58d4181e6 --- /dev/null +++ b/src/boost/tools/cmake/test/boost_test/compile_fail.cpp @@ -0,0 +1,8 @@ +// Copyright 2018 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 + +int f() +{ + return x; +} diff --git a/src/boost/tools/cmake/test/boost_test/emits_warning.cpp b/src/boost/tools/cmake/test/boost_test/emits_warning.cpp new file mode 100644 index 000000000..91bcf0ccf --- /dev/null +++ b/src/boost/tools/cmake/test/boost_test/emits_warning.cpp @@ -0,0 +1,9 @@ +// 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 + +int main() +{ + int x, y; + return x; +} diff --git a/src/boost/tools/cmake/test/boost_test/link.cpp b/src/boost/tools/cmake/test/boost_test/link.cpp new file mode 100644 index 000000000..d843d0c0a --- /dev/null +++ b/src/boost/tools/cmake/test/boost_test/link.cpp @@ -0,0 +1,13 @@ +// Copyright 2018 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 + +int f() +{ + return 0; +} + +int main() +{ + return f(); +} diff --git a/src/boost/tools/cmake/test/boost_test/link_fail.cpp b/src/boost/tools/cmake/test/boost_test/link_fail.cpp new file mode 100644 index 000000000..e271ced9c --- /dev/null +++ b/src/boost/tools/cmake/test/boost_test/link_fail.cpp @@ -0,0 +1,10 @@ +// Copyright 2018 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 + +int f(); + +int main() +{ + return f(); +} diff --git a/src/boost/tools/cmake/test/boost_test/requires_no_exceptions.cpp b/src/boost/tools/cmake/test/boost_test/requires_no_exceptions.cpp new file mode 100644 index 000000000..f4ed46110 --- /dev/null +++ b/src/boost/tools/cmake/test/boost_test/requires_no_exceptions.cpp @@ -0,0 +1,18 @@ +// 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 + +#include + +int main() +{ +#if defined(BOOST_NO_EXCEPTIONS) + + return 0; + +#else + + return 1; + +#endif +} diff --git a/src/boost/tools/cmake/test/boost_test/requires_no_rtti.cpp b/src/boost/tools/cmake/test/boost_test/requires_no_rtti.cpp new file mode 100644 index 000000000..33030b5e7 --- /dev/null +++ b/src/boost/tools/cmake/test/boost_test/requires_no_rtti.cpp @@ -0,0 +1,18 @@ +// 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 + +#include + +int main() +{ +#if defined(BOOST_NO_RTTI) + + return 0; + +#else + + return 1; + +#endif +} diff --git a/src/boost/tools/cmake/test/boost_test/requires_variadic_templates.cpp b/src/boost/tools/cmake/test/boost_test/requires_variadic_templates.cpp new file mode 100644 index 000000000..ce516c60b --- /dev/null +++ b/src/boost/tools/cmake/test/boost_test/requires_variadic_templates.cpp @@ -0,0 +1,13 @@ +// 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 + +template int f() +{ + return sizeof...(T); +} + +int main() +{ + return f() == 3? 0: 1; +} diff --git a/src/boost/tools/cmake/test/boost_test/return_exit_code.cpp b/src/boost/tools/cmake/test/boost_test/return_exit_code.cpp new file mode 100644 index 000000000..372988bb2 --- /dev/null +++ b/src/boost/tools/cmake/test/boost_test/return_exit_code.cpp @@ -0,0 +1,8 @@ +// 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 + +int main() +{ + return EXIT_CODE; +} diff --git a/src/boost/tools/cmake/test/boost_test/run.cpp b/src/boost/tools/cmake/test/boost_test/run.cpp new file mode 100644 index 000000000..a23cef0dc --- /dev/null +++ b/src/boost/tools/cmake/test/boost_test/run.cpp @@ -0,0 +1,7 @@ +// Copyright 2018 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 + +int main() +{ +} diff --git a/src/boost/tools/cmake/test/boost_test/run_fail.cpp b/src/boost/tools/cmake/test/boost_test/run_fail.cpp new file mode 100644 index 000000000..bdb31cb73 --- /dev/null +++ b/src/boost/tools/cmake/test/boost_test/run_fail.cpp @@ -0,0 +1,8 @@ +// Copyright 2018 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 + +int main() +{ + return 1; +} diff --git a/src/boost/tools/cmake/test/iostreams/CMakeLists.txt b/src/boost/tools/cmake/test/iostreams/CMakeLists.txt new file mode 100644 index 000000000..fba956fb2 --- /dev/null +++ b/src/boost/tools/cmake/test/iostreams/CMakeLists.txt @@ -0,0 +1,21 @@ +# Copyright 2018, 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 + +cmake_minimum_required(VERSION 3.5...3.16) + +project(boost_iostreams_install_test LANGUAGES CXX) + +if(BOOST_RUNTIME_LINK STREQUAL "static") + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") +endif() + +find_package(boost_iostreams REQUIRED) + +add_executable(test_fd test_fd.cpp) +target_link_libraries(test_fd Boost::iostreams Boost::core) + +enable_testing() +add_test(NAME test_fd COMMAND test_fd WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + +add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $) diff --git a/src/boost/tools/cmake/test/iostreams/test.txt b/src/boost/tools/cmake/test/iostreams/test.txt new file mode 100644 index 000000000..03410e845 --- /dev/null +++ b/src/boost/tools/cmake/test/iostreams/test.txt @@ -0,0 +1 @@ +=== reference output === \ No newline at end of file diff --git a/src/boost/tools/cmake/test/iostreams/test_fd.cpp b/src/boost/tools/cmake/test/iostreams/test_fd.cpp new file mode 100644 index 000000000..dd93bde12 --- /dev/null +++ b/src/boost/tools/cmake/test/iostreams/test_fd.cpp @@ -0,0 +1,22 @@ +// Copyright 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 + +#include +#include +#include +#include + +namespace io = boost::iostreams; + +int main() +{ + io::file_descriptor_source fs( "test.txt" ); + + std::string s; + io::copy( fs, io::back_inserter( s ) ); + + BOOST_TEST( s == "=== reference output ===" ); + + return boost::report_errors(); +} diff --git a/src/boost/tools/cmake/test/locale/CMakeLists.txt b/src/boost/tools/cmake/test/locale/CMakeLists.txt new file mode 100644 index 000000000..294322903 --- /dev/null +++ b/src/boost/tools/cmake/test/locale/CMakeLists.txt @@ -0,0 +1,21 @@ +# Copyright 2018, 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 + +cmake_minimum_required(VERSION 3.5...3.16) + +project(boost_locale_install_test LANGUAGES CXX) + +if(BOOST_RUNTIME_LINK STREQUAL "static") + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") +endif() + +find_package(boost_locale REQUIRED) + +add_executable(main main.cpp) +target_link_libraries(main Boost::locale) + +enable_testing() +add_test(NAME main COMMAND main) + +add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $) diff --git a/src/boost/tools/cmake/test/locale/main.cpp b/src/boost/tools/cmake/test/locale/main.cpp new file mode 100644 index 000000000..4a7056365 --- /dev/null +++ b/src/boost/tools/cmake/test/locale/main.cpp @@ -0,0 +1,32 @@ +// Copyright 2009-2011 Artyom Beilis (Tonkikh) +// Copyright 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 + +#include +#include +#include + +int main() +{ + boost::locale::generator gen; + + std::locale loc = gen( "en_US.UTF-8" ); + + std::cout.imbue( loc ); + + std::cout << boost::locale::format( "Today {1,date} at {1,time} we had run our first localization example" ) % std::time( 0 ) << std::endl; + + std::cout << "This is how we show numbers in this locale " << boost::locale::as::number << 103.34 << std::endl; + std::cout << "This is how we show currency in this locale " << boost::locale::as::currency << 103.34 << std::endl; + + std::cout << "This is typical date in the locale " << boost::locale::as::date << std::time( 0 ) << std::endl; + std::cout << "This is typical time in the locale " << boost::locale::as::time << std::time( 0 ) << std::endl; + + std::string str( "Hello World!" ); + + std::cout << "This is upper case " << boost::locale::to_upper( str, loc ) << std::endl; + std::cout << "This is lower case " << boost::locale::to_lower( str, loc ) << std::endl; + std::cout << "This is title case " << boost::locale::to_title( str, loc ) << std::endl; + std::cout << "This is fold case " << boost::locale::fold_case( str, loc ) << std::endl; +} diff --git a/src/boost/tools/cmake/test/mp11/CMakeLists.txt b/src/boost/tools/cmake/test/mp11/CMakeLists.txt new file mode 100644 index 000000000..6c47a0877 --- /dev/null +++ b/src/boost/tools/cmake/test/mp11/CMakeLists.txt @@ -0,0 +1,17 @@ +# Copyright 2018 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 + +cmake_minimum_required(VERSION 3.5...3.16) + +project(boost_mp11_install_test LANGUAGES CXX) + +find_package(boost_mp11 REQUIRED) + +add_executable(main main.cpp) +target_link_libraries(main Boost::mp11) + +enable_testing() +add_test(NAME main COMMAND main) + +add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $) diff --git a/src/boost/tools/cmake/test/mp11/main.cpp b/src/boost/tools/cmake/test/mp11/main.cpp new file mode 100644 index 000000000..7b8689ac6 --- /dev/null +++ b/src/boost/tools/cmake/test/mp11/main.cpp @@ -0,0 +1,12 @@ +// Copyright 2018 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 +using namespace boost::mp11; + +int main() +{ + using L1 = mp_list; + return mp_size>::value == 2? 0: 1; +} diff --git a/src/boost/tools/cmake/test/timer/CMakeLists.txt b/src/boost/tools/cmake/test/timer/CMakeLists.txt new file mode 100644 index 000000000..6f3fe9a52 --- /dev/null +++ b/src/boost/tools/cmake/test/timer/CMakeLists.txt @@ -0,0 +1,21 @@ +# 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 + +cmake_minimum_required(VERSION 3.5...3.16) + +project(boost_timer_install_test LANGUAGES CXX) + +if(BOOST_RUNTIME_LINK STREQUAL "static") + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") +endif() + +find_package(boost_timer REQUIRED) + +add_executable(main main.cpp) +target_link_libraries(main Boost::timer) + +enable_testing() +add_test(NAME main COMMAND main) + +add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $) diff --git a/src/boost/tools/cmake/test/timer/main.cpp b/src/boost/tools/cmake/test/timer/main.cpp new file mode 100644 index 000000000..25ce9c842 --- /dev/null +++ b/src/boost/tools/cmake/test/timer/main.cpp @@ -0,0 +1,11 @@ +// 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 + +#include + +int main() +{ + boost::timer::cpu_timer timer; + timer.stop(); +} -- cgit v1.2.3