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)
5 # This file was adapted from FindMeta.cmake at https://github.com/ericniebler/meta.
8 # This CMake module finds the Meta include directory. This module sets the
9 # following CMake variables:
12 # Set to 1 when the Meta include directory is found, 0 otherwise.
15 # If the Meta include directory is found, this is set to the path of that
16 # directory. Otherwise, this is not set.
19 # The following variables can be used to customize the behavior of the module:
22 # The path to the Meta include directory. When set, this will be used as-is.
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.
28 if (NOT EXISTS "${Meta_INCLUDE_DIR}")
29 find_path(Meta_INCLUDE_DIR NAMES meta/meta.hpp
30 DOC "Meta library header files")
33 if (NOT EXISTS "${Meta_INCLUDE_DIR}" AND Meta_CLONE_IF_MISSING)
34 include(ExternalProject)
35 ExternalProject_Add(meta EXCLUDE_FROM_ALL 1
36 GIT_REPOSITORY https://github.com/ericniebler/meta
38 CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
39 PREFIX "${CMAKE_CURRENT_BINARY_DIR}"
40 BUILD_COMMAND "" # Disable build step
41 INSTALL_COMMAND "" # Disable install step
42 TEST_COMMAND "" # Disable test step
45 ExternalProject_Get_Property(meta SOURCE_DIR)
46 set(Meta_INCLUDE_DIR "${SOURCE_DIR}/include")
49 include(FindPackageHandleStandardArgs)
50 find_package_handle_standard_args(Meta
52 REQUIRED_VARS Meta_INCLUDE_DIR)