diff options
Diffstat (limited to 'src/boost/tools/cmake')
31 files changed, 1377 insertions, 0 deletions
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..7289bff2a --- /dev/null +++ b/src/boost/tools/cmake/include/BoostInstall.cmake @@ -0,0 +1,345 @@ +# Copyright 2019, 2020 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_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_LIBDIR "${CMAKE_INSTALL_LIBDIR}" CACHE STRING "Installation directory for library files") +set(BOOST_INSTALL_CMAKEDIR "${BOOST_INSTALL_LIBDIR}/cmake" CACHE STRING "Installation directory for CMake configuration files") +set(BOOST_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}" CACHE STRING "Installation directory for header files") + +if(BOOST_INSTALL_LAYOUT STREQUAL "versioned") + set(BOOST_INSTALL_INCLUDEDIR "$CACHE{BOOST_INSTALL_INCLUDEDIR}/boost-${PROJECT_VERSION_MAJOR}_${PROJECT_VERSION_MINOR}") +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:${BOOST_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() + + set(CONFIG_INSTALL_DIR "${BOOST_INSTALL_CMAKEDIR}/${LIB}-${__VERSION}") + + install(TARGETS ${LIB} EXPORT ${LIB}-targets DESTINATION ${BOOST_INSTALL_LIBDIR}) + + if(WIN32 AND TYPE STREQUAL "SHARED_LIBRARY") + + install(FILES $<TARGET_PDB_FILE:${LIB}> DESTINATION ${BOOST_INSTALL_LIBDIR} OPTIONAL) + + endif() + + if(WIN32 AND 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 ${BOOST_INSTALL_LIBDIR} OPTIONAL) + + 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") + + foreach(dep IN LISTS INTERFACE_LINK_LIBRARIES LINK_LIBRARIES) + + if(${dep} MATCHES "^Boost::(.*)$") + + string(APPEND CONFIG_FILE_CONTENTS "find_dependency(boost_${CMAKE_MATCH_1} ${__VERSION} EXACT)\n") + + endif() + + endforeach() + + 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 AnyNewerVersion 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 AnyNewerVersion) + + set(CMAKE_SIZEOF_VOID_P ${OLD_CMAKE_SIZEOF_VOID_P}) + + endif() + + else() + + write_basic_package_version_file("${CONFIG_VERSION_FILE_NAME}" COMPATIBILITY AnyNewerVersion) + + 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) + + get_filename_component(__HEADER_DIRECTORY "${__HEADER_DIRECTORY}" ABSOLUTE) + install(DIRECTORY "${__HEADER_DIRECTORY}/" DESTINATION "${BOOST_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..7b2ef9a57 --- /dev/null +++ b/src/boost/tools/cmake/include/BoostRoot.cmake @@ -0,0 +1,220 @@ +# Copyright 2019, 2020 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() + +if(NOT BOOST_ENABLE_CMAKE) + + message(FATAL_ERROR + "CMake support in Boost is experimental and part of an ongoing " + "development effort. It's not ready for use yet. Please use b2 " + "(Boost.Build) to build and install Boost.") + +endif() + +include(BoostMessage) +include(BoostInstall) + +# --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 beast;callable_traits;compute;gil;hana;hof;safe_numerics;serialization;static_string;yap CACHE STRING "List of libraries with incompatible CMakeLists.txt files") + +# --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) + +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() + +# 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) + + file(STRINGS "${BOOST_SUPERPROJECT_SOURCE_DIR}/libs/${lib}/CMakeLists.txt" data) + + set(result "") + + 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() + + set(${var} ${result} PARENT_SCOPE) + +endfunction() + +# + +if(CMAKE_SOURCE_DIR STREQUAL Boost_SOURCE_DIR) + + 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() + +endif() + +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(VERBOSE "Boost installation support is limited on CMake ${CMAKE_VERSION} (need 3.13)") + +endif() + +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_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) + + set(BUILD_TESTING OFF) # hide cache variable + + boost_message(VERBOSE "Adding dependent Boost library ${__boost_lib}") + add_subdirectory(libs/${__boost_lib}) + + __boost_auto_install(${__boost_lib}) + + unset(BUILD_TESTING) + + else() + + set(BUILD_TESTING OFF) # hide cache variable + + boost_message(DEBUG "Adding Boost library ${__boost_lib} with EXCLUDE_FROM_ALL") + add_subdirectory(libs/${__boost_lib} EXCLUDE_FROM_ALL) + + unset(BUILD_TESTING) + + 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..6b56cc9e2 --- /dev/null +++ b/src/boost/tools/cmake/include/BoostTest.cmake @@ -0,0 +1,206 @@ +# 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(__TYPE STREQUAL "compile" OR __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 compile-${__NAME} COMMAND "${CMAKE_COMMAND}" --build ${CMAKE_BINARY_DIR} --target ${__NAME} --config $<CONFIG>) + + if(__TYPE STREQUAL "compile-fail") + set_tests_properties(compile-${__NAME} PROPERTIES WILL_FAIL TRUE) + endif() + + 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_test(NAME link-${__NAME} COMMAND "${CMAKE_COMMAND}" --build ${CMAKE_BINARY_DIR} --target ${__NAME} --config $<CONFIG>) + + 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_test(NAME compile-${__NAME} COMMAND "${CMAKE_COMMAND}" --build ${CMAKE_BINARY_DIR} --target compile-${__NAME} --config $<CONFIG>) + + 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 link-${__NAME} COMMAND "${CMAKE_COMMAND}" --build ${CMAKE_BINARY_DIR} --target ${__NAME} --config $<CONFIG>) + set_tests_properties(link-${__NAME} PROPERTIES WILL_FAIL 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_test(NAME compile-${__NAME} COMMAND "${CMAKE_COMMAND}" --build ${CMAKE_BINARY_DIR} --target ${__NAME} --config $<CONFIG>) + + add_test(NAME run-${__NAME} COMMAND ${__NAME} ${__ARGUMENTS}) + set_tests_properties(run-${__NAME} PROPERTIES DEPENDS compile-${__NAME}) + + if(__TYPE STREQUAL "run-fail") + set_tests_properties(run-${__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..8240f683f --- /dev/null +++ b/src/boost/tools/cmake/include/BoostTestJamfile.cmake @@ -0,0 +1,80 @@ +# 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() + +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) + boost_message(VERBOSE "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) + + string(REGEX MATCHALL "[^ ]+" ll ${line}) + + if(ll) + list(GET ll 0 e0) + + if(e0 IN_LIST types) + + list(LENGTH ll lln) + + if(NOT lln EQUAL 2) + + boost_message(VERBOSE "boost_test_jamfile: Jamfile line ignored: ${line}") + + else() + + list(GET ll 1 e1) + + boost_test(PREFIX ${__PREFIX} TYPE ${e0} + SOURCES ${e1} + LINK_LIBRARIES ${__LIBRARIES} ${__LINK_LIBRARIES} + COMPILE_DEFINITIONS ${__COMPILE_DEFINITIONS} + COMPILE_OPTIONS ${__COMPILE_OPTIONS} + COMPILE_FEATURES ${__COMPILE_FEATURES} + ) + + endif() + endif() + endif() + endif() + endforeach(line) + +endfunction(boost_test_jamfile) 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 $<CONFIG>) 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 <boost/assert.hpp> + +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..8eb7edf84 --- /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) + +find_package(boost_atomic REQUIRED) + +if(BOOST_RUNTIME_LINK STREQUAL "static") + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>") +endif() + +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 $<CONFIG>) 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 <boost/atomic.hpp> + +struct X +{ + double v[ 8 ]; +}; + +int main() +{ + boost::atomic<X> 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..3883c6fe1 --- /dev/null +++ b/src/boost/tools/cmake/test/boost_fetch/CMakeLists.txt @@ -0,0 +1,25 @@ +# 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 $<CONFIG>) + +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) + +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 <boost/core/lightweight_test.hpp> + +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..e595f5d8a --- /dev/null +++ b/src/boost/tools/cmake/test/boost_test/CMakeLists.txt @@ -0,0 +1,56 @@ +# 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) + +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..7ef0c4516 --- /dev/null +++ b/src/boost/tools/cmake/test/boost_test/Jamfile @@ -0,0 +1,20 @@ +# 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 <warnings-as-errors>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 <boost/core/lightweight_test.hpp> +#include <string.h> + +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 <boost/config.hpp> + +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 <boost/config.hpp> + +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<class... T> int f() +{ + return sizeof...(T); +} + +int main() +{ + return f<int, void, float>() == 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/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 $<CONFIG>) 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 <boost/mp11.hpp> +using namespace boost::mp11; + +int main() +{ + using L1 = mp_list<int, float, int, float>; + return mp_size<mp_unique<L1>>::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..5de5f0980 --- /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) + +find_package(boost_timer REQUIRED) + +if(BOOST_RUNTIME_LINK STREQUAL "static") + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>") +endif() + +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 $<CONFIG>) 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 <boost/timer/timer.hpp> + +int main() +{ + boost::timer::cpu_timer timer; + timer.stop(); +} |