1 # Copyright 2018 Peter Dimov
2 # Distributed under the Boost Software License, Version 1.0.
3 # See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
5 cmake_minimum_required(VERSION 3.5)
7 project(BoostMp11 VERSION 1.72.0 LANGUAGES CXX)
9 add_library(boost_mp11 INTERFACE)
10 set_property(TARGET boost_mp11 PROPERTY EXPORT_NAME mp11)
12 add_library(Boost::mp11 ALIAS boost_mp11)
14 target_include_directories(boost_mp11 INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include>)
15 target_compile_features(boost_mp11 INTERFACE cxx_alias_templates cxx_variadic_templates cxx_decltype)
17 if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
21 # `function` confuses FetchContent, sees empty CMAKE_CURRENT_LIST_DIR
22 macro(fetch_and_include name)
24 message(STATUS "Fetching ${name}")
27 "https://raw.githubusercontent.com/boostorg/mincmake/master/${name}"
28 "${CMAKE_BINARY_DIR}/fetch_and_include/${name}"
31 include("${CMAKE_BINARY_DIR}/fetch_and_include/${name}")
35 fetch_and_include(cmake/boost_fetch.cmake)
36 fetch_and_include(cmake/boost_test.cmake)
38 boost_fetch(boostorg/assert TAG develop)
39 boost_fetch(boostorg/config TAG develop)
40 boost_fetch(boostorg/core TAG develop)
43 add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
47 set(CONFIG_INSTALL_DIR lib/cmake/${PROJECT_NAME}-${PROJECT_VERSION})
49 install(TARGETS boost_mp11 EXPORT ${PROJECT_NAME}Targets)
50 install(EXPORT ${PROJECT_NAME}Targets DESTINATION ${CONFIG_INSTALL_DIR} NAMESPACE Boost:: FILE ${PROJECT_NAME}Config.cmake)
52 install(DIRECTORY include/ DESTINATION include)
54 include(CMakePackageConfigHelpers)
56 # Mp11 is independent of 32/64, so this hack makes BoostMp11ConfigVersion.cmake skip the check
57 set(OLD_CMAKE_SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P})
58 unset(CMAKE_SIZEOF_VOID_P)
59 write_basic_package_version_file("${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" COMPATIBILITY AnyNewerVersion)
60 set(CMAKE_SIZEOF_VOID_P ${OLD_CMAKE_SIZEOF_VOID_P})
62 install(FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" DESTINATION ${CONFIG_INSTALL_DIR})
64 #export(EXPORT ${PROJECT_NAME}Targets NAMESPACE Boost:: FILE ${PROJECT_NAME}Config.cmake)
68 if(COMMAND boost_test)
70 add_subdirectory(test)