FindMeta.cmake 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. # Copyright Louis Dionne 2013-2017
  2. # Distributed under the Boost Software License, Version 1.0.
  3. # (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
  4. #
  5. # This file was adapted from FindMeta.cmake at https://github.com/ericniebler/meta.
  6. #
  7. #
  8. # This CMake module finds the Meta include directory. This module sets the
  9. # following CMake variables:
  10. #
  11. # Meta_FOUND
  12. # Set to 1 when the Meta include directory is found, 0 otherwise.
  13. #
  14. # Meta_INCLUDE_DIR
  15. # If the Meta include directory is found, this is set to the path of that
  16. # directory. Otherwise, this is not set.
  17. #
  18. #
  19. # The following variables can be used to customize the behavior of the module:
  20. #
  21. # Meta_INCLUDE_DIR
  22. # The path to the Meta include directory. When set, this will be used as-is.
  23. #
  24. # Meta_CLONE_IF_MISSING
  25. # If the Meta include directory can't be found and this is set to true,
  26. # the Meta project will be cloned locally.
  27. if (NOT EXISTS "${Meta_INCLUDE_DIR}")
  28. find_path(Meta_INCLUDE_DIR NAMES meta/meta.hpp
  29. DOC "Meta library header files")
  30. endif()
  31. if (NOT EXISTS "${Meta_INCLUDE_DIR}" AND Meta_CLONE_IF_MISSING)
  32. include(ExternalProject)
  33. ExternalProject_Add(meta EXCLUDE_FROM_ALL 1
  34. GIT_REPOSITORY https://github.com/ericniebler/meta
  35. TIMEOUT 5
  36. CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
  37. PREFIX "${CMAKE_CURRENT_BINARY_DIR}"
  38. BUILD_COMMAND "" # Disable build step
  39. INSTALL_COMMAND "" # Disable install step
  40. TEST_COMMAND "" # Disable test step
  41. )
  42. ExternalProject_Get_Property(meta SOURCE_DIR)
  43. set(Meta_INCLUDE_DIR "${SOURCE_DIR}/include")
  44. endif()
  45. include(FindPackageHandleStandardArgs)
  46. find_package_handle_standard_args(Meta
  47. FOUND_VAR Meta_FOUND
  48. REQUIRED_VARS Meta_INCLUDE_DIR)