#Check if we can compile with GPU
if (CLI_FLEUR_USE_GPU)
   #No check is done
   set(FLEUR_USE_GPU TRUE)
   message("GPU:${CLI_FLEUR_USE_GPU}")
   if (CLI_FLEUR_USE_GPU MATCHES "cuda8")
      set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ta=tesla:cuda8.0,cc60 -Mcuda:kepler+ -Minfo=accel -Mcudalib=cublas -acc ")
      message("Using cuda8")
   elseif (CLI_FLEUR_USE_GPU MATCHES "cuda9")
      set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -Mcuda=cuda9.0,cc60 -Mcuda=rdc -Mcudalib=cublas")
      set(FLEUR_MPI_DEFINITIONS ${FLEUR_MPI_DEFINITIONS} "CPP_GPU" "CPP_MANAGED=,MANAGED")
      set(FLEUR_DEFINITIONS ${FLEUR_DEFINITIONS} "CPP_GPU" "CPP_MANAGED=,MANAGED")
   elseif(${CLI_FLEUR_USE_GPU} MATCHES "cuda9.1")
      set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -Mcuda=cuda9.1,cc60 -Mcuda=rdc -Mcudalib=cublas")
      set(FLEUR_MPI_DEFINITIONS ${FLEUR_MPI_DEFINITIONS} "CPP_GPU" "CPP_MANAGED=,MANAGED")
      set(FLEUR_DEFINITIONS ${FLEUR_DEFINITIONS} "CPP_GPU" "CPP_MANAGED=,MANAGED")
   elseif(${CLI_FLEUR_USE_GPU} MATCHES "nvtx")
      #set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}  -Mcuda=cuda9.1,cc60,ptxinfo,lineinfo -Mcuda=rdc -Mcudalib=cublas -lnvToolsExt ")
      set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -acc -Minfo=all -Mcuda=cuda10.2,cc60 -Mcuda=rdc -Mcudalib=cublas -lnvToolsExt ")
      set(FLEUR_MPI_DEFINITIONS ${FLEUR_MPI_DEFINITIONS} "CPP_GPU" "CPP_MANAGED=,MANAGED")
      set(FLEUR_DEFINITIONS ${FLEUR_DEFINITIONS} "CPP_GPU" "CPP_MANAGED=,MANAGED")
   elseif(${CLI_FLEUR_USE_GPU} MATCHES "magma")
      #set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}  -Mcuda=cuda9.1,cc60 -Mcuda=rdc -Mcudalib=cublas -lnvToolsExt -lmagma -lmkl_intel_lp64 -lmkl_core")
      #set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}  -Mcuda=cuda9.2,cc60 -Mcuda=rdc -Mcudalib=cublas -lnvToolsExt -lmagma -lmkl_intel_lp64 -lmkl_core")
      set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}  -Mcuda=cc60 -Mcuda=rdc -lcublas -lnvToolsExt -lmagma -lmkl_intel_lp64 -lmkl_core")
      set(FLEUR_MPI_DEFINITIONS ${FLEUR_MPI_DEFINITIONS} "CPP_GPU" "CPP_MANAGED=,MANAGED")
      set(FLEUR_DEFINITIONS ${FLEUR_DEFINITIONS} "CPP_GPU" "CPP_MANAGED=,MANAGED")
   elseif(${CLI_FLEUR_USE_GPU} MATCHES "emu")
      #set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -Mcuda=emu -Mcudalib=cublas -Minfo=accel ")
      set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -Mcuda=emu -Mcudalib=cublas ")
      set(FLEUR_MPI_DEFINITIONS ${FLEUR_MPI_DEFINITIONS} "CPP_GPU" "CPP_MANAGED=,MANAGED")
      set(FLEUR_DEFINITIONS ${FLEUR_DEFINITIONS} "CPP_GPU" "CPP_MANAGED=,MANAGED")
   elseif(${CLI_FLEUR_USE_GPU} MATCHES "acc")
      set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -acc -Mcuda -Mcudalib=cublas -Minfo=accel -lnvToolsExt")
      set(FLEUR_MPI_DEFINITIONS ${FLEUR_MPI_DEFINITIONS} "CPP_MANAGED=")
      set(FLEUR_DEFINITIONS ${FLEUR_DEFINITIONS} "CPP_MANAGED=")
  else()
      message(ERROR,"Choose a GPU mode")
   endif()
#Now check for cusolverDN library
#   set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Mcuda -ta=tesla,cuda9.1 ")
#   try_compile(FLEUR_USE_CUSOLVER ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/cmake/tests/test_cusolver.c
#	    LINK_LIBRARIES "-lcusolver"
#            )
#   if (FLEUR_USE_CUSOLVER)
#     set(FLEUR_LIBRARIES "${FLEUR_LIBRARIES};-lcusolver")
#     set(FLEUR_MPI_DEFINITIONS ${FLEUR_MPI_DEFINITIONS} "CPP_CUSOLVER")
#     set(FLEUR_DEFINITIONS ${FLEUR_DEFINITIONS} "CPP_CUSOLVER")
#   endif()
else()
   set(FLEUR_USE_GPU FALSE)
   set(FLEUR_MPI_DEFINITIONS ${FLEUR_MPI_DEFINITIONS} "CPP_MANAGED=")
   set(FLEUR_DEFINITIONS ${FLEUR_DEFINITIONS} "CPP_MANAGED=")
endif()
