IF (ARMPL_LIBRARY_DIRS AND ARMPL_LIBRARIES)
  KOKKOSKERNELS_FIND_IMPORTED(ARMPL INTERFACE LIBRARIES ${ARMPL_LIBRARIES} LIBRARY_PATHS ${ARMPL_LIBRARY_DIRS})
ELSEIF (ARMPL_LIBRARIES)
  KOKKOSKERNELS_FIND_IMPORTED(ARMPL INTERFACE LIBRARIES ${ARMPL_LIBRARIES})
ELSEIF (ARMPL_LIBRARY_DIRS)
  KOKKOSKERNELS_FIND_IMPORTED(ARMPL INTERFACE LIBRARIES armpl LIBRARY_PATHS ${ARMPL_LIBRARY_DIRS})
ELSEIF (DEFINED ENV{ARMPL_DIR})
  SET(ARMPL_ROOT $ENV{ARMPL_DIR})
  KOKKOSKERNELS_FIND_IMPORTED(ARMPL INTERFACE
    LIBRARIES
      amath
      armpl
    LIBRARY_PATHS
      ${ARMPL_ROOT}/lib
    HEADERS
      armpl.h
    HEADER_PATHS
      ${ARMPL_ROOT}/include
  )
ELSE()
  FIND_PACKAGE(ARMPL REQUIRED)
  KOKKOSKERNELS_CREATE_IMPORTED_TPL(ARMPL INTERFACE LINK_LIBRARIES ${ARMPL_LIBRARIES})
ENDIF()

TRY_COMPILE(KOKKOSKERNELS_TRY_COMPILE_ARMPL
  ${KOKKOSKERNELS_TOP_BUILD_DIR}/tpl_tests
  ${KOKKOSKERNELS_TOP_SOURCE_DIR}/cmake/compile_tests/armpl.cpp
  LINK_LIBRARIES -larmpl -lgfortran -lamath -lm
  OUTPUT_VARIABLE KOKKOSKERNELS_TRY_COMPILE_ARMPL_OUT)
IF(NOT KOKKOSKERNELS_TRY_COMPILE_ARMPL)
  MESSAGE(FATAL_ERROR "KOKKOSKERNELS_TRY_COMPILE_ARMPL_OUT=${KOKKOSKERNELS_TRY_COMPILE_ARMPL_OUT}")
ENDIF()
