CMakeLists.txt 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. cmake_minimum_required(VERSION 3.5)
  5. project(BoostMp11 VERSION 1.72.0 LANGUAGES CXX)
  6. add_library(boost_mp11 INTERFACE)
  7. set_property(TARGET boost_mp11 PROPERTY EXPORT_NAME mp11)
  8. add_library(Boost::mp11 ALIAS boost_mp11)
  9. target_include_directories(boost_mp11 INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include>)
  10. target_compile_features(boost_mp11 INTERFACE cxx_alias_templates cxx_variadic_templates cxx_decltype)
  11. if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
  12. # --target check
  13. # `function` confuses FetchContent, sees empty CMAKE_CURRENT_LIST_DIR
  14. macro(fetch_and_include name)
  15. message(STATUS "Fetching ${name}")
  16. file(DOWNLOAD
  17. "https://raw.githubusercontent.com/boostorg/mincmake/master/${name}"
  18. "${CMAKE_BINARY_DIR}/fetch_and_include/${name}"
  19. )
  20. include("${CMAKE_BINARY_DIR}/fetch_and_include/${name}")
  21. endmacro()
  22. fetch_and_include(cmake/boost_fetch.cmake)
  23. fetch_and_include(cmake/boost_test.cmake)
  24. boost_fetch(boostorg/assert TAG develop)
  25. boost_fetch(boostorg/config TAG develop)
  26. boost_fetch(boostorg/core TAG develop)
  27. enable_testing()
  28. add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
  29. # --target install
  30. set(CONFIG_INSTALL_DIR lib/cmake/${PROJECT_NAME}-${PROJECT_VERSION})
  31. install(TARGETS boost_mp11 EXPORT ${PROJECT_NAME}Targets)
  32. install(EXPORT ${PROJECT_NAME}Targets DESTINATION ${CONFIG_INSTALL_DIR} NAMESPACE Boost:: FILE ${PROJECT_NAME}Config.cmake)
  33. install(DIRECTORY include/ DESTINATION include)
  34. include(CMakePackageConfigHelpers)
  35. # Mp11 is independent of 32/64, so this hack makes BoostMp11ConfigVersion.cmake skip the check
  36. set(OLD_CMAKE_SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P})
  37. unset(CMAKE_SIZEOF_VOID_P)
  38. write_basic_package_version_file("${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" COMPATIBILITY AnyNewerVersion)
  39. set(CMAKE_SIZEOF_VOID_P ${OLD_CMAKE_SIZEOF_VOID_P})
  40. install(FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" DESTINATION ${CONFIG_INSTALL_DIR})
  41. #export(EXPORT ${PROJECT_NAME}Targets NAMESPACE Boost:: FILE ${PROJECT_NAME}Config.cmake)
  42. endif()
  43. if(COMMAND boost_test)
  44. add_subdirectory(test)
  45. endif()