set(src_modules
    additional_kpoints.f90 
    autopilot.f90 
    basic_algebra_routines.f90 
    becmod.f90 
    bfgs_module.f90 
    bspline.f90 
    bz_form.f90 
    cell_base.f90  
    check_stop.f90  
    command_line_options.f90 
    compute_dipole.f90 
    constants.f90 
    constraints_module.f90 
    control_flags.f90 
    coulomb_vcut.f90  
    dist.f90 
    electrons_base.f90 
    environment.f90 
    fd_gradient.f90 
    fft_base.f90 
    fft_rho.f90 
    fsockets.f90 
    funct.f90 
    generate_function.f90 
    gradutils.f90 
    gvecw.f90 
    input_parameters.f90 
    invmat.f90 
    io_files.f90 
    io_global.f90  
    ions_base.f90 
    kind.f90 
    mdiis.f90 
    mm_dispersion.f90 
    mp_bands.f90 
    mp_exx.f90 
    mp_global.f90 
    mp_images.f90 
    mp_pools.f90 
    mp_wave.f90 
    mp_world.f90 
    noncol.f90 
    open_close_input_file.f90 
    parameters.f90 
    parser.f90 
    plugin_flags.f90 
    plugin_arguments.f90 
    plugin_variables.f90 
    lmdif.f90  
    pw_dot.f90 
    qmmm.f90 
    random_numbers.f90 
    read_cards.f90 
    read_input.f90 
    read_namelists.f90 
    read_pseudo.f90 
    recvec.f90 
    recvec_subs.f90 
    run_info.f90 
    space_group.f90 
    set_para_diag.f90 
    set_signal.f90 
    set_vdw_corr.f90 
    setqf.f90 
    timestep.f90
    tsvdw.f90
    mbdlib.f90
    version.f90 
    wannier_gw.f90
    wannier_new.f90 
    wavefunctions.f90 
    wrappers.f90
    ws_base.f90 
    xc_vdW_DF.f90 
    xc_rVV10.f90 
    io_base.f90 
    qes_types_module.f90 
    qes_libs_module.f90  
    qes_write_module.f90 
    qes_read_module.f90 
    qes_reset_module.f90 
    qes_init_module.f90 
    qes_read_module.f90 
    qes_bcast_module.f90 
    qexsd.f90   
    qexsd_copy.f90   
    qexsd_init.f90   
    qexsd_input.f90 
    hdf5_qe.f90
    qeh5_module.f90
    fox_init_module.f90 
    xsf.f90 
    wyckoff.f90 
    wypos.f90 
    zvscal.f90 
    # list of subroutines and functions (not modules) previously found in flib/
    atom_weight.f90 
    capital.f90 
    cryst_to_car.f90
    expint.f90 
    generate_k_along_lines.f90 
    more_functionals.f90 
    has_xml.f90 
    inpfile.f90 
    int_to_char.f90 
    latgen.f90 
    linpack.f90 
    matches.f90 
    plot_io.f90 
    radial_gradients.f90 
    rgen.f90 
    recips.f90 
    remove_tot_torque.f90
    set_hubbard_l.f90 
    set_hubbard_n.f90 
    sort.f90 
    trimcheck.f90 
    test_input_file.f90 
    date_and_tim.f90 
    volume.f90 
    wgauss.f90 
    w0gauss.f90
    w1gauss.f90
    deviatoric.f90
    # GPU
    wavefunctions_gpu.f90
    becmod_gpu.f90
    becmod_subs_gpu.f90
    random_numbers_gpu.f90
    cuda_subroutines.f90)
qe_enable_cuda_fortran("${src_modules}")

qe_add_library(qe_modules ${src_modules})
target_link_libraries(qe_modules
    PRIVATE
        qe_openmp_fortran
        qe_fftx
        qe_lax
        qe_clib # this is needed only by wrappers.f90
        qe_mpi_fortran
        qe_mbd
        qe_xclib
        qe_devxlib
    PUBLIC
        qe_hdf5_fortran
        qe_upflib
        qe_fox
        qe_utilx)

###########################################################

qe_install_targets(qe_modules)
