Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / mp11 / CMakeLists.txt
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
4
5 cmake_minimum_required(VERSION 3.5)
6
7 project(BoostMp11 VERSION 1.72.0 LANGUAGES CXX)
8
9 add_library(boost_mp11 INTERFACE)
10 set_property(TARGET boost_mp11 PROPERTY EXPORT_NAME mp11)
11
12 add_library(Boost::mp11 ALIAS boost_mp11)
13
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)
16
17 if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
18
19     # --target check
20
21     # `function` confuses FetchContent, sees empty CMAKE_CURRENT_LIST_DIR
22     macro(fetch_and_include name)
23
24         message(STATUS "Fetching ${name}")
25
26         file(DOWNLOAD
27             "https://raw.githubusercontent.com/boostorg/mincmake/master/${name}"
28             "${CMAKE_BINARY_DIR}/fetch_and_include/${name}"
29         )
30
31         include("${CMAKE_BINARY_DIR}/fetch_and_include/${name}")
32
33     endmacro()
34
35     fetch_and_include(cmake/boost_fetch.cmake)
36     fetch_and_include(cmake/boost_test.cmake)
37
38     boost_fetch(boostorg/assert TAG develop)
39     boost_fetch(boostorg/config TAG develop)
40     boost_fetch(boostorg/core TAG develop)
41
42     enable_testing()
43     add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
44
45     # --target install
46
47     set(CONFIG_INSTALL_DIR lib/cmake/${PROJECT_NAME}-${PROJECT_VERSION})
48
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)
51
52     install(DIRECTORY include/ DESTINATION include)
53
54     include(CMakePackageConfigHelpers)
55
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})
61
62     install(FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" DESTINATION ${CONFIG_INSTALL_DIR})
63
64     #export(EXPORT ${PROJECT_NAME}Targets NAMESPACE Boost:: FILE ${PROJECT_NAME}Config.cmake)
65
66 endif()
67
68 if(COMMAND boost_test)
69
70     add_subdirectory(test)
71
72 endif()