summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/hana/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'src/boost/libs/hana/cmake')
-rw-r--r--src/boost/libs/hana/cmake/CheckCxxCompilerSupport.cmake85
-rw-r--r--src/boost/libs/hana/cmake/FindMPL11.cmake48
-rw-r--r--src/boost/libs/hana/cmake/FindMeta.cmake52
-rw-r--r--src/boost/libs/hana/cmake/TestHeaders.cmake128
-rw-r--r--src/boost/libs/hana/cmake/hana.pc.in5
5 files changed, 318 insertions, 0 deletions
diff --git a/src/boost/libs/hana/cmake/CheckCxxCompilerSupport.cmake b/src/boost/libs/hana/cmake/CheckCxxCompilerSupport.cmake
new file mode 100644
index 000000000..0b5d72a6a
--- /dev/null
+++ b/src/boost/libs/hana/cmake/CheckCxxCompilerSupport.cmake
@@ -0,0 +1,85 @@
+# Copyright Louis Dionne 2013-2017
+# Copyright Markus J. Weber 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)
+#
+#
+# This CMake module checks whether the current compiler is supported, and
+# provides friendly hints to the user.
+
+if (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
+ if (${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS "3.9.1")
+ message(WARNING "
+ ### You appear to be using Clang ${CMAKE_CXX_COMPILER_VERSION}, which is known
+ ### to be unable to compile Hana. Consider switching to
+ ### Clang >= 3.9.1. If it is already installed on your
+ ### system, you can tell CMake about it with
+ ###
+ ### cmake .. -DCMAKE_CXX_COMPILER=/path/to/clang
+ ")
+ endif()
+
+ if (MSVC)
+ if(${MSVC_VERSION} LESS 1900)
+ message(WARNING "
+ ###
+ ### We detected that you were using Clang for Windows with a
+ ### -fms-compatibility-version parameter lower than 19. Only
+ ### -fms-compatibility-version=19 and above are supported by
+ ### Hana for lack of proper C++14 support prior for versions
+ ### below that.
+ ###
+ ### If this diagnostic is wrong and you are not using
+ ### -fms-compatibility-version, please file an issue at
+ ### https://github.com/boostorg/hana/issues.
+ ###
+ ")
+ endif()
+ endif()
+elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL "AppleClang")
+ if (${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS "6.1.0")
+ message(WARNING "
+ ### You appear to be using Apple's Clang ${CMAKE_CXX_COMPILER_VERSION}, which is
+ ### shipped with Xcode < 6.3. Unfortunately, only Apple's Clang
+ ### >= 6.1.0 (shipped with Xcode >= 6.3) can compile Hana.
+ ### You should consider updating to Xcode >= 6.3 (requires Yosemite)
+ ### or using a non-Apple Clang >= 3.9.1, which can be installed via
+ ### Homebrew with
+ ###
+ ### brew install llvm --with-clang
+ ###
+ ### You can then tell CMake to use that non-system Clang with
+ ###
+ ### cmake .. -DCMAKE_CXX_COMPILER=/path/to/clang
+ ")
+ endif()
+elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
+ if (${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS "6.0.0")
+ message(WARNING "
+ ### You appear to be using GCC ${CMAKE_CXX_COMPILER_VERSION}, which is known to be
+ ### unable to compile Hana. Only GCC >= 6.0.0 is supported.
+ ### Consider using a more recent GCC or switching to Clang.
+ ### If a more recent compiler is already installed on your
+ ### system, you can tell CMake to use it with
+ ###
+ ### cmake .. -DCMAKE_CXX_COMPILER=/path/to/compiler
+ ")
+ endif()
+elseif (MSVC)
+ message(WARNING "
+ ### Using the native Microsoft compiler (MSVC) is not supported for lack
+ ### of proper C++14 support. However, you can install pre-built Clang for
+ ### Windows binaries (with Visual Studio integration if desired) at
+ ### http://llvm.org/releases/download.html.
+ ###
+ ### More information about how to set up Hana with Clang for Windows is
+ ### available on Hana's wiki at http://git.io/vBYIp.
+ ")
+else()
+ message(WARNING "
+ ### You appear to be using a compiler that is not yet tested with Hana.
+ ### Please tell us whether it successfully compiles or if and how it
+ ### fails by opening an issue at https://github.com/boostorg/hana/issues.
+ ### Thanks!
+ ")
+endif()
diff --git a/src/boost/libs/hana/cmake/FindMPL11.cmake b/src/boost/libs/hana/cmake/FindMPL11.cmake
new file mode 100644
index 000000000..5b8b3c4e0
--- /dev/null
+++ b/src/boost/libs/hana/cmake/FindMPL11.cmake
@@ -0,0 +1,48 @@
+# 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 finds the MPL11 include directory. This module sets the
+# following CMake variables:
+#
+# MPL11_FOUND
+# Set to 1 when the MPL11 include directory is found, 0 otherwise.
+#
+# MPL11_INCLUDE_DIR
+# If the MPL11 include directory is found, this is set to the path of that
+# directory. Otherwise, this is not set.
+#
+#
+# The following variables can be used to customize the behavior of the module:
+#
+# MPL11_INCLUDE_DIR
+# The path to the MPL11 include directory. When set, this will be used as-is.
+#
+# MPL11_CLONE_IF_MISSING
+# If the MPL11 include directory can't be found and this is set to true,
+# the MPL11 project will be cloned locally.
+
+if (NOT EXISTS "${MPL11_INCLUDE_DIR}")
+ find_path(MPL11_INCLUDE_DIR NAMES boost/mpl11/mpl11.hpp
+ DOC "MPL11 library header files")
+endif()
+
+if (NOT EXISTS "${MPL11_INCLUDE_DIR}" AND MPL11_CLONE_IF_MISSING)
+ include(ExternalProject)
+ ExternalProject_Add(MPL11 EXCLUDE_FROM_ALL 1
+ GIT_REPOSITORY https://github.com/ldionne/mpl11
+ TIMEOUT 5
+ CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
+ PREFIX "${CMAKE_CURRENT_BINARY_DIR}"
+ BUILD_COMMAND "" # Disable build step
+ INSTALL_COMMAND "" # Disable install step
+ TEST_COMMAND "" # Disable test step
+ )
+
+ ExternalProject_Get_Property(MPL11 SOURCE_DIR)
+ set(MPL11_INCLUDE_DIR "${SOURCE_DIR}/include")
+endif()
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(MPL11 DEFAULT_MSG MPL11_INCLUDE_DIR)
diff --git a/src/boost/libs/hana/cmake/FindMeta.cmake b/src/boost/libs/hana/cmake/FindMeta.cmake
new file mode 100644
index 000000000..0a532062b
--- /dev/null
+++ b/src/boost/libs/hana/cmake/FindMeta.cmake
@@ -0,0 +1,52 @@
+# 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 file was adapted from FindMeta.cmake at https://github.com/ericniebler/meta.
+#
+#
+# This CMake module finds the Meta include directory. This module sets the
+# following CMake variables:
+#
+# Meta_FOUND
+# Set to 1 when the Meta include directory is found, 0 otherwise.
+#
+# Meta_INCLUDE_DIR
+# If the Meta include directory is found, this is set to the path of that
+# directory. Otherwise, this is not set.
+#
+#
+# The following variables can be used to customize the behavior of the module:
+#
+# Meta_INCLUDE_DIR
+# The path to the Meta include directory. When set, this will be used as-is.
+#
+# Meta_CLONE_IF_MISSING
+# If the Meta include directory can't be found and this is set to true,
+# the Meta project will be cloned locally.
+
+if (NOT EXISTS "${Meta_INCLUDE_DIR}")
+ find_path(Meta_INCLUDE_DIR NAMES meta/meta.hpp
+ DOC "Meta library header files")
+endif()
+
+if (NOT EXISTS "${Meta_INCLUDE_DIR}" AND Meta_CLONE_IF_MISSING)
+ include(ExternalProject)
+ ExternalProject_Add(meta EXCLUDE_FROM_ALL 1
+ GIT_REPOSITORY https://github.com/ericniebler/meta
+ TIMEOUT 5
+ CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
+ PREFIX "${CMAKE_CURRENT_BINARY_DIR}"
+ BUILD_COMMAND "" # Disable build step
+ INSTALL_COMMAND "" # Disable install step
+ TEST_COMMAND "" # Disable test step
+ )
+
+ ExternalProject_Get_Property(meta SOURCE_DIR)
+ set(Meta_INCLUDE_DIR "${SOURCE_DIR}/include")
+endif()
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(Meta
+ FOUND_VAR Meta_FOUND
+ REQUIRED_VARS Meta_INCLUDE_DIR)
diff --git a/src/boost/libs/hana/cmake/TestHeaders.cmake b/src/boost/libs/hana/cmake/TestHeaders.cmake
new file mode 100644
index 000000000..663c9f4e8
--- /dev/null
+++ b/src/boost/libs/hana/cmake/TestHeaders.cmake
@@ -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()
diff --git a/src/boost/libs/hana/cmake/hana.pc.in b/src/boost/libs/hana/cmake/hana.pc.in
new file mode 100644
index 000000000..316d379a8
--- /dev/null
+++ b/src/boost/libs/hana/cmake/hana.pc.in
@@ -0,0 +1,5 @@
+Name: Boost.Hana
+Description: A modern C++ metaprogramming library
+URL: https://github.com/boostorg/hana
+Version: @Boost.Hana_VERSION_STRING@
+Cflags: -I@CMAKE_INSTALL_PREFIX@/include