init
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled

This commit is contained in:
allhaileris
2026-02-16 15:50:16 +03:00
commit afb81b8278
13816 changed files with 3689732 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
# Copyright Eric Niebler 2019
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
cmake_minimum_required(VERSION 2.8.2)
project(google-benchmark-download NONE)
include(ExternalProject)
ExternalProject_Add(google-benchmark
GIT_REPOSITORY https://github.com/google/benchmark.git
GIT_TAG master
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/google-benchmark-src"
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/google-benchmark-build"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
)

View File

@@ -0,0 +1,19 @@
# Copyright Eric Niebler 2019
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
cmake_minimum_required(VERSION 2.8.2)
project(google-test-download NONE)
include(ExternalProject)
ExternalProject_Add(google-test
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG master
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/google-test-src"
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/google-test-build"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
)

View File

@@ -0,0 +1,128 @@
# Copyright Louis Dionne 2013-2017
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
#
#
# This CMake module provides a function generating a unit test to make sure
# that every public header can be included on its own.
#
# When a C++ library or application has many header files, it can happen that
# a header does not include all the other headers it depends on. When this is
# the case, it can happen that including that header file on its own will
# break the compilation. This CMake module generates a dummy executable
# comprised of many .cpp files, each of which includes a header file that
# is part of the public API. In other words, the executable is comprised
# of .cpp files of the form:
#
# #include <the/public/header.hpp>
#
# and then exactly one `main` function. If this succeeds to compile, it means
# that the header can be included on its own, which is what clients expect.
# Otherwise, you have a problem. Since writing these dumb unit tests by hand
# is tedious and repetitive, you can use this CMake module to automate this
# task.
# add_header_test(<target> [EXCLUDE_FROM_ALL] [EXCLUDE excludes...] HEADERS headers...)
#
# Generates header-inclusion unit tests for all the specified headers.
#
# This function creates a target which builds a dummy executable including
# each specified header file individually. If this target builds successfully,
# it means that all the specified header files can be included individually.
#
# Parameters
# ----------
# <target>:
# The name of the target to generate.
#
# HEADERS headers:
# A list of header files to generate the inclusion tests for. All headers
# in this list must be represented as relative paths from the root of the
# include directory added to the compiler's header search path. In other
# words, it should be possible to include all headers in this list as
#
# #include <${header}>
#
# For example, for a library with the following structure:
#
# project/
# doc/
# test/
# ...
# include/
# boost/
# hana.hpp
# hana/
# transform.hpp
# tuple.hpp
# pair.hpp
# ...
#
# When building the unit tests for that library, we'll add `-I project/include'
# to the compiler's arguments. The list of public headers should therefore contain
#
# boost/hana.hpp
# boost/hana/transform.hpp
# boost/hana/tuple.hpp
# boost/hana/pair.hpp
# ...
#
# Usually, all the 'public' header files of a library should be tested for
# standalone inclusion. A header is considered 'public' if a client should
# be able to include that header on its own.
#
# [EXCLUDE excludes]:
# An optional list of headers or regexes for which no unit test should be
# generated. Basically, any header in the list specified by the `HEADERS`
# argument that matches anything in `EXCLUDE` will be skipped.
#
# [EXCLUDE_FROM_ALL]:
# If provided, the generated target is excluded from the 'all' target.
#
function(add_header_test target)
cmake_parse_arguments(ARGS "EXCLUDE_FROM_ALL" # options
"" # 1 value args
"HEADERS;EXCLUDE" # multivalued args
${ARGN})
if (NOT ARGS_HEADERS)
message(FATAL_ERROR "The `HEADERS` argument must be provided.")
endif()
if (ARGS_EXCLUDE_FROM_ALL)
set(ARGS_EXCLUDE_FROM_ALL "EXCLUDE_FROM_ALL")
else()
set(ARGS_EXCLUDE_FROM_ALL "")
endif()
foreach(header ${ARGS_HEADERS})
set(skip FALSE)
foreach(exclude ${ARGS_EXCLUDE})
if (${header} MATCHES ${exclude})
set(skip TRUE)
break()
endif()
endforeach()
if (skip)
continue()
endif()
get_filename_component(filename "${header}" NAME_WE)
get_filename_component(directory "${header}" DIRECTORY)
set(source "${CMAKE_CURRENT_BINARY_DIR}/headers/${directory}/${filename}.cpp")
if (NOT EXISTS "${source}")
file(WRITE "${source}" "#include <${header}>")
endif()
list(APPEND sources "${source}")
endforeach()
set(standalone_main "${CMAKE_CURRENT_BINARY_DIR}/headers/_standalone_main.cpp")
if (NOT EXISTS "${standalone_main}")
file(WRITE "${standalone_main}" "int main() { }")
endif()
add_executable(${target}
${ARGS_EXCLUDE_FROM_ALL}
${sources}
"${CMAKE_CURRENT_BINARY_DIR}/headers/_standalone_main.cpp"
)
endfunction()

View File

@@ -0,0 +1,6 @@
#include <new>
int main() {
struct alignas(__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 4) S {};
(void) ::operator new(sizeof(S), static_cast<std::align_val_t>(alignof(S)));
}

View File

@@ -0,0 +1,29 @@
#if !defined(__cpp_concepts) || __cpp_concepts == 0
#error "Sorry, Charlie. No concepts"
#else
#if __cpp_concepts <= 201507L
#define concept concept bool
#endif
template<class>
concept True = true;
template<class T>
constexpr bool test(T)
{
return false;
}
template<class T>
requires True<T>
constexpr bool test(T)
{
return true;
}
int main()
{
static_assert(::test(42), "");
}
#endif

View File

@@ -0,0 +1,46 @@
#if defined(__cpp_coroutines) && defined(__has_include)
#if __has_include(<coroutine>)
#include <coroutine>
namespace std_coro = std;
#elif __has_include(<experimental/coroutine>)
#include <experimental/coroutine>
namespace std_coro = std::experimental;
#else
#error Either the compiler or the library lacks support for coroutines
#endif
#else
#error Either the compiler or the library lacks support for coroutines
#endif
struct present
{
struct promise_type
{
int result;
present get_return_object() { return {*this}; }
std_coro::suspend_never initial_suspend() { return {}; }
std_coro::suspend_never final_suspend() noexcept { return {}; }
void return_value(int i) { result = i; }
void unhandled_exception() {}
};
promise_type& promise;
bool await_ready() const { return true; }
void await_suspend(std_coro::coroutine_handle<>) const {}
int await_resume() const { return promise.result; }
};
present f(int n)
{
if (n < 2)
co_return 1;
else
co_return n * co_await f(n - 1);
}
int main()
{
return f(5).promise.result != 120;
}

View File

@@ -0,0 +1,26 @@
# Download and unpack googletest at configure time
configure_file(
cmake/GoogleBenchmark.cmake.in
google-benchmark-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/google-benchmark-download)
if(result)
message(FATAL_ERROR "CMake step for google-benchmark failed: ${result}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/google-benchmark-download)
if(result)
message(FATAL_ERROR "Build step for google-benchmark failed: ${result}")
endif()
# Add google-benchmark directly to our build. This defines
# the benchmark and benchmark_main targets.
add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/google-benchmark-src
${CMAKE_CURRENT_BINARY_DIR}/google-benchmark-build
EXCLUDE_FROM_ALL)

View File

@@ -0,0 +1,32 @@
# Copyright 2019 Eric Niebler
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
# Download and unpack googletest at configure time
configure_file(cmake/GoogleTest.cmake.in google-test-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/google-test-download )
if(result)
message(FATAL_ERROR "CMake step for google-test failed: ${result}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/google-test-download )
if(result)
message(FATAL_ERROR "Build step for google-test failed: ${result}")
endif()
# Prevent overriding the parent project's compiler/linker
# settings on Windows
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
# Add google-test directly to our build. This defines
# the gtest and gtest_main targets.
add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/google-test-src
${CMAKE_CURRENT_BINARY_DIR}/google-test-build
EXCLUDE_FROM_ALL)

View File

@@ -0,0 +1,21 @@
if (TARGET range-v3::meta)
return()
endif()
include("${CMAKE_CURRENT_LIST_DIR}/range-v3-targets.cmake")
add_library(range-v3::meta INTERFACE IMPORTED)
add_library(range-v3::concepts INTERFACE IMPORTED)
add_library(range-v3::range-v3 INTERFACE IMPORTED)
# workaround for target_link_libraries on lower cmake versions (< 3.11)
# see https://cmake.org/cmake/help/latest/release/3.11.html#commands
if(CMAKE_VERSION VERSION_LESS 3.11)
set_target_properties(range-v3::meta PROPERTIES INTERFACE_LINK_LIBRARIES "range-v3-meta")
set_target_properties(range-v3::concepts PROPERTIES INTERFACE_LINK_LIBRARIES "range-v3-concepts")
set_target_properties(range-v3::range-v3 PROPERTIES INTERFACE_LINK_LIBRARIES "range-v3")
else()
target_link_libraries(range-v3::meta INTERFACE range-v3-meta)
target_link_libraries(range-v3::concepts INTERFACE range-v3-concepts)
target_link_libraries(range-v3::range-v3 INTERFACE range-v3)
endif()

View File

@@ -0,0 +1,46 @@
# Copyright Louis Dionne 2015
# Copyright Gonzalo Brito Gadeschi 2015
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
#
# Setup compiler flags (more can be set on a per-target basis or in
# subdirectories)
# Enable all warnings:
ranges_append_flag(RANGES_HAS_WEVERYTHING -Weverything)
ranges_append_flag(RANGES_HAS_PEDANTIC -pedantic)
ranges_append_flag(RANGES_HAS_PEDANTIC_ERRORS -pedantic-errors)
# Selectively disable those warnings that are not worth it:
ranges_append_flag(RANGES_HAS_WNO_CXX98_COMPAT -Wno-c++98-compat)
ranges_append_flag(RANGES_HAS_WNO_CXX98_COMPAT_PEDANTIC -Wno-c++98-compat-pedantic)
ranges_append_flag(RANGES_HAS_WNO_WEAK_VTABLES -Wno-weak-vtables)
ranges_append_flag(RANGES_HAS_WNO_PADDED -Wno-padded)
ranges_append_flag(RANGES_HAS_WNO_MISSING_VARIABLE_DECLARATIONS -Wno-missing-variable-declarations)
ranges_append_flag(RANGES_HAS_WNO_DOCUMENTATION -Wno-documentation)
ranges_append_flag(RANGES_HAS_WNO_DOCUMENTATION_UNKNOWN_COMMAND -Wno-documentation-unknown-command)
ranges_append_flag(RANGES_HAS_WNO_OLD_STYLE_CAST -Wno-old-style-cast)
if (RANGES_ENV_MACOSX)
ranges_append_flag(RANGES_HAS_WNO_GLOBAL_CONSTRUCTORS -Wno-global-constructors)
ranges_append_flag(RANGES_HAS_WNO_EXIT_TIME_DESTRUCTORS -Wno-exit-time-destructors)
endif()
if (RANGES_CXX_COMPILER_CLANG OR RANGES_CXX_COMPILER_CLANGCL)
ranges_append_flag(RANGES_HAS_WNO_MISSING_PROTOTYPES -Wno-missing-prototypes)
endif()
if (RANGES_CXX_COMPILER_GCC)
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.0")
ranges_append_flag(RANGES_HAS_WNO_STRICT_OVERFLOW -Wno-strict-overflow)
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.0")
ranges_append_flag(RANGES_HAS_WNO_MISSING_FIELD_INITIALIZERS -Wno-missing-field-initializers)
endif()
elseif ((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "7.0") OR (CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL "7.0"))
ranges_append_flag(RANGES_HAS_WNO_NOEXCEPT_TYPE -Wno-noexcept-type)
endif()
endif()
if (RANGES_VERBOSE_BUILD)
message(STATUS "[range-v3]: test C++ flags: ${CMAKE_CXX_FLAGS}")
endif()

View File

@@ -0,0 +1,90 @@
# Copyright Gonzalo Brito Gadeschi 2015
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
#
# Detects the C++ compiler, system, build-type, etc.
include(CheckCXXCompilerFlag)
if("x${CMAKE_CXX_COMPILER_ID}" MATCHES "x.*Clang")
if("x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
set (RANGES_CXX_COMPILER_CLANGCL TRUE)
if (RANGES_VERBOSE_BUILD)
message(STATUS "[range-v3]: compiler is clang-cl.")
endif()
else()
set (RANGES_CXX_COMPILER_CLANG TRUE)
if (RANGES_VERBOSE_BUILD)
message(STATUS "[range-v3]: compiler is clang.")
endif()
endif()
elseif(CMAKE_COMPILER_IS_GNUCXX)
set (RANGES_CXX_COMPILER_GCC TRUE)
if (RANGES_VERBOSE_BUILD)
message(STATUS "[range-v3]: compiler is gcc.")
endif()
elseif("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC")
set (RANGES_CXX_COMPILER_MSVC TRUE)
if (RANGES_VERBOSE_BUILD)
message(STATUS "[range-v3]: compiler is msvc.")
endif()
else()
message(WARNING "[range-v3 warning]: unknown compiler ${CMAKE_CXX_COMPILER_ID} !")
endif()
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
set (RANGES_ENV_MACOSX TRUE)
if (RANGES_VERBOSE_BUILD)
message(STATUS "[range-v3]: system is MacOSX.")
endif()
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
set (RANGES_ENV_LINUX TRUE)
if (RANGES_VERBOSE_BUILD)
message(STATUS "[range-v3]: system is Linux.")
endif()
elseif(CMAKE_SYSTEM_NAME MATCHES "Windows")
set (RANGES_ENV_WINDOWS TRUE)
if (RANGES_VERBOSE_BUILD)
message(STATUS "[range-v3]: system is Windows.")
endif()
elseif(CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
set (RANGES_ENV_OPENBSD TRUE)
if (RANGES_VERBOSE_BUILD)
message(STATUS "[range-v3]: system is OpenBSD.")
endif()
else()
message(WARNING "[range-v3 warning]: unknown system ${CMAKE_SYSTEM_NAME} !")
endif()
if(RANGES_CXX_STD MATCHES "^[0-9]+$")
if(RANGES_CXX_COMPILER_MSVC AND RANGES_CXX_STD LESS 17)
# MSVC is currently supported only in 17+ mode
set(RANGES_CXX_STD 17)
elseif(RANGES_CXX_STD LESS 14)
set(RANGES_CXX_STD 14)
endif()
endif()
# Build type
set(RANGES_DEBUG_BUILD FALSE)
set(RANGES_RELEASE_BUILD FALSE)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(RANGES_DEBUG_BUILD TRUE)
if (RANGES_VERBOSE_BUILD)
message(STATUS "[range-v3]: build type is debug.")
endif()
elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
set(RANGES_RELEASE_BUILD TRUE)
if (RANGES_VERBOSE_BUILD)
message(STATUS "[range-v3]: build type is release.")
endif()
else()
message(WARNING "[range-v3 warning]: unknown build type, defaults to release!")
set(CMAKE_BUILD_TYPE "Release")
set(RANGES_RELEASE_BUILD TRUE)
endif()
if(RANGE_V3_DOCS)
find_package(Doxygen)
endif()
find_package(Git)

View File

@@ -0,0 +1,301 @@
# Copyright Louis Dionne 2015
# Copyright Gonzalo Brito Gadeschi 2015
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
#
# Setup compiler flags (more can be set on a per-target basis or in
# subdirectories)
# Compilation flags
include(CheckCXXCompilerFlag)
macro(ranges_append_flag testname flag)
# As -Wno-* flags do not lead to build failure when there are no other
# diagnostics, we check positive option to determine their applicability.
# Of course, we set the original flag that is requested in the parameters.
string(REGEX REPLACE "^-Wno-" "-W" alt ${flag})
check_cxx_compiler_flag(${alt} ${testname})
if (${testname})
add_compile_options(${flag})
endif()
endmacro()
function(cxx_standard_normalize cxx_standard return_value)
if("x${cxx_standard}" STREQUAL "x1y")
set( ${return_value} "14" PARENT_SCOPE )
elseif("x${cxx_standard}" STREQUAL "x1z")
set( ${return_value} "17" PARENT_SCOPE )
elseif("x${cxx_standard}" STREQUAL "xlatest" OR "x${cxx_standard}" STREQUAL "x2a")
set( ${return_value} "20" PARENT_SCOPE )
else()
set( ${return_value} "${cxx_standard}" PARENT_SCOPE )
endif()
endfunction()
function(cxx_standard_denormalize cxx_standard return_value)
if("x${cxx_standard}" STREQUAL "x17")
if (RANGES_CXX_COMPILER_CLANGCL OR RANGES_CXX_COMPILER_MSVC)
set( ${return_value} 17 PARENT_SCOPE )
else()
set( ${return_value} 1z PARENT_SCOPE )
endif()
elseif("x${cxx_standard}" STREQUAL "x20")
if (RANGES_CXX_COMPILER_CLANGCL OR RANGES_CXX_COMPILER_MSVC)
set( ${return_value} latest PARENT_SCOPE )
else()
set( ${return_value} 2a PARENT_SCOPE )
endif()
else()
set( ${return_value} ${cxx_standard} PARENT_SCOPE )
endif()
endfunction()
if(CMAKE_CXX_STANDARD)
if(NOT "x${RANGES_CXX_STD}" STREQUAL "xdefault")
# Normalize RANGES_CXX_STD
cxx_standard_normalize( ${RANGES_CXX_STD} ranges_cxx_std )
if(NOT "x${ranges_cxx_std}" STREQUAL "x${CMAKE_CXX_STANDARD}")
message(FATAL_ERROR "[range-v3]: Cannot specify both CMAKE_CXX_STANDARD and RANGES_CXX_STD, or they must match.")
endif()
else()
cxx_standard_denormalize(${CMAKE_CXX_STANDARD} RANGES_CXX_STD)
endif()
elseif("x${RANGES_CXX_STD}" STREQUAL "xdefault")
if (RANGES_CXX_COMPILER_CLANGCL OR RANGES_CXX_COMPILER_MSVC)
set(RANGES_CXX_STD 17)
else()
set(RANGES_CXX_STD 14)
endif()
endif()
# All compilation flags
# Language flag: version of the C++ standard to use
message(STATUS "[range-v3]: C++ std=${RANGES_CXX_STD}")
if (RANGES_CXX_COMPILER_CLANGCL OR RANGES_CXX_COMPILER_MSVC)
ranges_append_flag(RANGES_HAS_CXXSTDCOLON "/std:c++${RANGES_CXX_STD}")
set(RANGES_STD_FLAG "/std:c++${RANGES_CXX_STD}")
if (RANGES_CXX_COMPILER_CLANGCL)
# The MSVC STL before VS 2019v16.6 with Clang 10 requires -fms-compatibility in C++17 mode, and
# doesn't support C++20 mode at all. Let's drop this flag until AppVeyor updates to VS2016v16.6.
# ranges_append_flag(RANGES_HAS_FNO_MS_COMPATIBIILITY "-fno-ms-compatibility")
ranges_append_flag(RANGES_HAS_FNO_DELAYED_TEMPLATE_PARSING "-fno-delayed-template-parsing")
endif()
# Enable "normal" warnings and make them errors:
ranges_append_flag(RANGES_HAS_W3 /W3)
ranges_append_flag(RANGES_HAS_WX /WX)
else()
ranges_append_flag(RANGES_HAS_CXXSTD "-std=c++${RANGES_CXX_STD}")
set(RANGES_STD_FLAG "-std=c++${RANGES_CXX_STD}")
# Enable "normal" warnings and make them errors:
ranges_append_flag(RANGES_HAS_WALL -Wall)
ranges_append_flag(RANGES_HAS_WEXTRA -Wextra)
if (RANGES_ENABLE_WERROR)
ranges_append_flag(RANGES_HAS_WERROR -Werror)
endif()
endif()
if (RANGES_ENV_LINUX AND RANGES_CXX_COMPILER_CLANG)
# On linux libc++ re-exports the system math headers. The ones from libstdc++
# use the GCC __extern_always_inline intrinsic which is not supported by clang
# versions 3.6, 3.7, 3.8, 3.9, 4.0, and current trunk 5.0 (as of 2017.04.13).
#
# This works around it by replacing __extern_always_inline with inline using a
# macro:
ranges_append_flag(RANGES_HAS_D__EXTERN_ALWAYS_INLINE -D__extern_always_inline=inline)
endif()
# Deep integration support
if (RANGES_DEEP_STL_INTEGRATION)
if (RANGES_CXX_COMPILER_MSVC)
add_compile_options(/I "${PROJECT_SOURCE_DIR}/include/std")
add_compile_options(/I "${PROJECT_SOURCE_DIR}/include")
else()
add_compile_options(-isystem "${PROJECT_SOURCE_DIR}/include/std")
add_compile_options(-I "${PROJECT_SOURCE_DIR}/include")
endif()
add_compile_options(-DRANGES_DEEP_STL_INTEGRATION=1)
endif()
# Template diagnostic flags
ranges_append_flag(RANGES_HAS_FDIAGNOSTIC_SHOW_TEMPLATE_TREE -fdiagnostics-show-template-tree)
ranges_append_flag(RANGES_HAS_FTEMPLATE_BACKTRACE_LIMIT "-ftemplate-backtrace-limit=0")
ranges_append_flag(RANGES_HAS_FMACRO_BACKTRACE_LIMIT "-fmacro-backtrace-limit=1")
# Clang modules support
if (RANGES_MODULES)
ranges_append_flag(RANGES_HAS_MODULES -fmodules)
ranges_append_flag(RANGES_HAS_MODULE_MAP_FILE "-fmodule-map-file=${PROJECT_SOURCE_DIR}/include/module.modulemap")
ranges_append_flag(RANGES_HAS_MODULE_CACHE_PATH "-fmodules-cache-path=${PROJECT_BINARY_DIR}/module.cache")
if (RANGES_LIBCXX_MODULE)
ranges_append_flag(RANGES_HAS_LIBCXX_MODULE_MAP_FILE "-fmodule-map-file=${RANGES_LIBCXX_MODULE}")
endif()
if (RANGES_ENV_MACOSX)
ranges_append_flag(RANGES_HAS_NO_IMPLICIT_MODULE_MAPS -fno-implicit-module-maps)
endif()
if (RANGES_DEBUG_BUILD)
ranges_append_flag(RANGES_HAS_GMODULES -gmodules)
endif()
endif()
# Sanitizer support: detect incompatible sanitizer combinations
if (RANGES_ASAN AND RANGES_MSAN)
message(FATAL_ERROR "[range-v3 error]: AddressSanitizer and MemorySanitizer are both enabled at the same time!")
endif()
if (RANGES_MSAN AND RANGES_ENV_MACOSX)
message(FATAL_ERROR "[range-v3 error]: MemorySanitizer is not supported on MacOSX!")
endif()
# AddressSanitizer support
if (RANGES_ASAN)
# This policy enables passing the linker flags to the linker when trying to
# test the features, which is required to successfully link ASan binaries
cmake_policy(SET CMP0056 NEW)
set (ASAN_FLAGS "")
if (RANGES_ENV_MACOSX) # LeakSanitizer not supported on MacOSX
set (ASAN_FLAGS "-fsanitize=address,signed-integer-overflow,shift,integer-divide-by-zero,implicit-signed-integer-truncation,implicit-integer-sign-change,undefined,nullability")
else()
if (RANGES_CXX_COMPILER_CLANG AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.0")
set (ASAN_FLAGS "-fsanitize=address")
else()
set (ASAN_FLAGS "-fsanitize=address,signed-integer-overflow,shift,integer-divide-by-zero,implicit-signed-integer-truncation,implicit-integer-sign-change,leak,nullability")
endif()
endif()
ranges_append_flag(RANGES_HAS_ASAN "${ASAN_FLAGS}")
if (RANGES_HAS_ASAN) #ASAN flags must be passed to the linker:
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${ASAN_FLAGS}")
endif()
ranges_append_flag(RANGES_HAS_SANITIZE_NO_RECOVER "-fno-sanitize-recover=all")
ranges_append_flag(RANGES_HAS_NO_OMIT_FRAME_POINTER -fno-omit-frame-pointer)
endif()
# MemorySanitizer support
if (RANGES_MSAN)
# This policy enables passing the linker flags to the linker when trying to
# compile the examples, which is required to successfully link MSan binaries
cmake_policy(SET CMP0056 NEW)
ranges_append_flag(RANGES_HAS_MSAN "-fsanitize=memory")
ranges_append_flag(RANGES_HAS_MSAN_TRACK_ORIGINS -fsanitize-memory-track-origins)
ranges_append_flag(RANGES_HAS_SANITIZE_RECOVER_ALL "-fno-sanitize-recover=all")
ranges_append_flag(RANGES_HAS_NO_OMIT_FRAME_POINTER -fno-omit-frame-pointer)
endif()
# Build types:
if (RANGES_DEBUG_BUILD AND RANGES_RELEASE_BUILD)
message(FATAL_ERROR "[range-v3 error] Cannot simultaneously generate debug and release builds!")
endif()
if (RANGES_DEBUG_BUILD)
ranges_append_flag(RANGES_HAS_NO_INLINE -fno-inline)
ranges_append_flag(RANGES_HAS_STACK_PROTECTOR_ALL -fstack-protector-all)
ranges_append_flag(RANGES_HAS_G3 -g3)
# Clang can generate debug info tuned for LLDB or GDB
if (RANGES_CXX_COMPILER_CLANG)
if (RANGES_ENV_MACOSX)
ranges_append_flag(RANGES_HAS_GLLDB -glldb)
elseif(RANGES_ENV_LINUX OR RANGES_ENV_OPENBSD)
ranges_append_flag(RANGES_HAS_GGDB -ggdb)
endif()
endif()
endif()
if (RANGES_RELEASE_BUILD)
if (NOT RANGES_ASSERTIONS)
ranges_append_flag(RANGES_HAS_DNDEBUG -DNDEBUG)
endif()
if (NOT RANGES_ASAN AND NOT RANGES_MSAN)
# The quality of ASan and MSan error messages suffers if we disable the
# frame pointer, so leave it enabled when compiling with either of them:
ranges_append_flag(RANGES_HAS_OMIT_FRAME_POINTER -fomit-frame-pointer)
endif()
ranges_append_flag(RANGES_HAS_OFAST -Ofast)
if (NOT RANGES_HAS_OFAST)
ranges_append_flag(RANGES_HAS_O2 -O2)
endif()
ranges_append_flag(RANGES_HAS_STRICT_ALIASING -fstrict-aliasing)
ranges_append_flag(RANGES_HAS_STRICT_VTABLE_POINTERS -fstrict-vtable-pointers)
ranges_append_flag(RANGES_HAS_FAST_MATH -ffast-math)
ranges_append_flag(RANGES_HAS_VECTORIZE -fvectorize)
if (NOT RANGES_ENV_MACOSX)
# Sized deallocation is not available in MacOSX:
ranges_append_flag(RANGES_HAS_SIZED_DEALLOCATION -fsized-deallocation)
endif()
if (RANGES_LLVM_POLLY)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mllvm -polly -mllvm -polly-vectorizer=stripmine")
endif()
if (RANGES_CXX_COMPILER_CLANG AND (NOT (RANGES_INLINE_THRESHOLD EQUAL -1)))
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mllvm -inline-threshold=${RANGES_INLINE_THRESHOLD}")
endif()
endif()
if (RANGES_NATIVE)
ranges_append_flag(RANGES_HAS_MARCH_NATIVE "-march=native")
ranges_append_flag(RANGES_HAS_MTUNE_NATIVE "-mtune=native")
endif()
include(CheckCXXSourceCompiles)
set(CMAKE_REQUIRED_FLAGS ${RANGES_STD_FLAG})
# Probe for library and compiler support for aligned new
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/cmake/aligned_new_probe.cpp" RANGE_V3_PROBE_CODE)
check_cxx_source_compiles("${RANGE_V3_PROBE_CODE}" RANGE_V3_ALIGNED_NEW_PROBE)
unset(RANGE_V3_PROBE_CODE)
unset(CMAKE_REQUIRED_FLAGS)
if (NOT RANGE_V3_ALIGNED_NEW_PROBE)
add_compile_options("-DRANGES_CXX_ALIGNED_NEW=0")
endif()
# Probe for coroutine TS support
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/cmake/coro_test_code.cpp" RANGE_V3_PROBE_CODE)
if(RANGES_CXX_COMPILER_MSVC)
set(CMAKE_REQUIRED_FLAGS "/await")
check_cxx_source_compiles("${RANGE_V3_PROBE_CODE}" RANGES_HAS_AWAIT)
if(RANGES_HAS_AWAIT)
set(RANGE_V3_COROUTINE_FLAGS "/await")
endif()
elseif(RANGES_CXX_COMPILER_CLANG)
set(CMAKE_REQUIRED_FLAGS "-fcoroutines-ts ${RANGES_STD_FLAG}")
check_cxx_source_compiles("${RANGE_V3_PROBE_CODE}" RANGES_HAS_FCOROUTINES_TS)
if(RANGES_HAS_FCOROUTINES_TS)
set(RANGE_V3_COROUTINE_FLAGS "-fcoroutines-ts")
endif()
endif()
unset(CMAKE_REQUIRED_FLAGS)
unset(RANGE_V3_PROBE_CODE)
if (RANGE_V3_COROUTINE_FLAGS)
add_compile_options(${RANGE_V3_COROUTINE_FLAGS})
endif()
# Test for concepts support
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/cmake/concepts_test_code.cpp" RANGE_V3_PROBE_CODE)
if(RANGES_CXX_COMPILER_GCC OR RANGES_CXX_COMPILER_CLANG)
set(CMAKE_REQUIRED_FLAGS "-fconcepts ${RANGES_STD_FLAG}")
check_cxx_source_compiles("${RANGE_V3_PROBE_CODE}" RANGE_V3_HAS_FCONCEPTS)
if(RANGE_V3_HAS_FCONCEPTS)
set(RANGE_V3_CONCEPTS_FLAGS "-fconcepts")
endif()
endif()
unset(CMAKE_REQUIRED_FLAGS)
unset(RANGE_V3_PROBE_CODE)
if (RANGE_V3_CONCEPTS_FLAGS AND RANGES_PREFER_REAL_CONCEPTS)
add_compile_options(${RANGE_V3_CONCEPTS_FLAGS})
endif()
if (RANGES_VERBOSE_BUILD)
get_directory_property(RANGES_COMPILE_OPTIONS COMPILE_OPTIONS)
message(STATUS "[range-v3]: C++ flags: ${CMAKE_CXX_FLAGS}")
message(STATUS "[range-v3]: C++ debug flags: ${CMAKE_CXX_FLAGS_DEBUG}")
message(STATUS "[range-v3]: C++ Release Flags: ${CMAKE_CXX_FLAGS_RELEASE}")
message(STATUS "[range-v3]: C++ Compile Flags: ${CMAKE_CXX_COMPILE_FLAGS}")
message(STATUS "[range-v3]: Compile options: ${RANGES_COMPILE_OPTIONS}")
message(STATUS "[range-v3]: C Flags: ${CMAKE_C_FLAGS}")
message(STATUS "[range-v3]: C Compile Flags: ${CMAKE_C_COMPILE_FLAGS}")
message(STATUS "[range-v3]: EXE Linker flags: ${CMAKE_EXE_LINKER_FLAGS}")
message(STATUS "[range-v3]: C++ Linker flags: ${CMAKE_CXX_LINK_FLAGS}")
message(STATUS "[range-v3]: MODULE Linker flags: ${CMAKE_MODULE_LINKER_FLAGS}")
get_directory_property(CMakeCompDirDefs COMPILE_DEFINITIONS)
message(STATUS "[range-v3]: Compile Definitions: ${CmakeCompDirDefs}")
endif()

View File

@@ -0,0 +1,59 @@
# Copyright Gonzalo Brito Gadeschi 2015
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
#
# CMake options
include(CMakeDependentOption)
set(RANGES_CXX_STD default CACHE STRING "C++ standard version.")
option(RANGES_BUILD_CALENDAR_EXAMPLE "Builds the calendar example." ON)
option(RANGES_ASAN "Run the tests using AddressSanitizer." OFF)
option(RANGES_MSAN "Run the tests using MemorySanitizer." OFF)
option(RANGES_ASSERTIONS "Enable assertions." ON)
option(RANGES_DEBUG_INFO "Include debug information in the binaries." ON)
option(RANGES_MODULES "Enables use of Clang modules (experimental)." OFF)
option(RANGES_NATIVE "Enables -march/-mtune=native." ON)
option(RANGES_VERBOSE_BUILD "Enables debug output from CMake." OFF)
option(RANGES_LLVM_POLLY "Enables LLVM Polly." OFF)
option(RANGES_ENABLE_WERROR
"Enables -Werror. Only effective if compiler is not clang-cl or MSVC. ON by default"
ON)
option(RANGES_PREFER_REAL_CONCEPTS
"Use real concepts instead of emulation if the compiler supports it"
ON)
option(RANGES_DEEP_STL_INTEGRATION
"Hijacks the primary std::iterator_traits template to emulate the C++20 std::ranges:: behavior."
OFF)
option(RANGE_V3_HEADER_CHECKS
"Build the Range-v3 header checks and integrate with ctest"
OFF)
set(RANGES_INLINE_THRESHOLD -1 CACHE STRING "Force a specific inlining threshold.")
# Enable verbose configure when passing -Wdev to CMake
if (DEFINED CMAKE_SUPPRESS_DEVELOPER_WARNINGS AND
NOT CMAKE_SUPPRESS_DEVELOPER_WARNINGS)
set(RANGES_VERBOSE_BUILD ON)
endif()
if (RANGES_VERBOSE_BUILD)
message(STATUS "[range-v3]: verbose build enabled.")
endif()
CMAKE_DEPENDENT_OPTION(RANGE_V3_TESTS
"Build the Range-v3 tests and integrate with ctest"
ON "${is_standalone}" OFF)
CMAKE_DEPENDENT_OPTION(RANGE_V3_EXAMPLES
"Build the Range-v3 examples and integrate with ctest"
ON "${is_standalone}" OFF)
option(RANGE_V3_PERF
"Build the Range-v3 performance benchmarks"
OFF)
CMAKE_DEPENDENT_OPTION(RANGE_V3_DOCS
"Build the Range-v3 documentation"
ON "${is_standalone}" OFF)
mark_as_advanced(RANGE_V3_PERF)

View File

@@ -0,0 +1,5 @@
# CMake files overview:
- `ranges_options.cmake`: All options to configure the library.
- `ranges_env.cmake`: Detects the environment: operating system, compiler, build-type, ...
- `ranges_flags.cmake`: Sets up all compiler flags.