FIND_LIBRARY(HUGETLBFS_LIBRARY
        NAMES
        hugetlbfs
)

FIND_PATH(HUGETLBFS_INCLUDE_DIR
        NAMES
        hugetlbfs.h
)

SET(HUGETLBFS_INCLUDE_DIRS ${HUGETLBFS_INCLUDE_DIR})
SET(HUGETLBFS_LIBRARIES ${HUGETLBFS_LIBRARY})

INCLUDE(CheckFunctionExists)
SET(CMAKE_REQUIRED_INCLUDES ${HUGETLBFS_INCLUDE_DIRS})
SET(CMAKE_REQUIRED_LIBRARIES ${HUGETLBFS_LIBRARIES})
CHECK_FUNCTION_EXISTS("get_huge_pages" HAVE_GET_HUGE_PAGES)
CHECK_FUNCTION_EXISTS("free_huge_pages" HAVE_FREE_HUGE_PAGES)

IF (HUGETLBFS_INCLUDE_DIRS AND HUGETLBFS_LIBRARIES)
    SET(HUGETLBFS_FOUND "YES")
ENDIF (HUGETLBFS_INCLUDE_DIRS AND HUGETLBFS_LIBRARIES)

MARK_AS_ADVANCED(
        HUGETLBFS_LIBRARIES
        HUGETLBFS_INCLUDE_DIRS
)
