set(sources
    additional_kpoints.f90 
    autopilot.f90 
    basic_algebra_routines.f90 
    becmod.f90 
    beef_interface.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 
    correlation_lda_lsda.f90 
    correlation_gga.f90 
    coulomb_vcut.f90 
    dgcxc_drivers.f90 
    dist.f90 
    dmxc_drivers.f90 
    dgcxc_drivers.f90 
    electrons_base.f90 
    environment.f90 
    exchange_lda_lsda.f90 
    exchange_gga.f90 
    fcp_variables.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 
    paw_variables.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_signal.f90 
    set_vdw_corr.f90 
    setqf.f90 
    timestep.f90
    tsvdw.f90
    version.f90 
    wannier_gw.f90
    wannier_new.f90 
    wave_base.f90 
    wavefunctions.f90 
    wrappers.f90
    ws_base.f90 
    xc_vdW_DF.f90 
    xc_rVV10.f90 
    xc_lda_lsda_drivers.f90 
    xc_gga_drivers.f90 
    xc_mgga_drivers.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 
    correlation_gga.f90 
    cryst_to_car.f90 
    erf.f90 
    exchange_gga.f90 
    expint.f90 
    generate_k_along_lines.f90 
    more_functionals.f90 
    has_xml.f90 
    inpfile.f90 
    int_to_char.f90 
    latgen.f90 
    linpack.f90 
    metagga.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 
    sph_bes.f90 
    sph_dbes.f90 
    trimcheck.f90 
    test_input_file.f90 
    date_and_tim.f90 
    volume.f90 
    dylmr2.f90 
    wgauss.f90 
    w0gauss.f90
    w1gauss.f90
    deviatoric.f90)

qe_add_library(qe_modules ${sources})
add_library(QE::Modules ALIAS qe_modules)
target_link_libraries(qe_modules
    PRIVATE
        QE::HDF5_Fortran
        QE::OpenMP_Fortran
        QE::FFTX
        QE::LAX
        QE::UPF
        QE::CLIB # this is needed only by wrappers.f90
        QE::libbeef
        QE::MPI_Fortran
        QE::FOX
        QE::UTILX)

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

qe_install_targets(qe_modules)
