source /theoryfs2/common/software/intel2015/bin/compilervars.sh intel64
MKLROOT=/theoryfs2/common/software/intel2015/composer_xe_2015.0.090/mkl/lib/intel64
#LAPACK_INTERJECT="${MKLROOT}/libmkl_intel_lp64.a ${MKLROOT}/libmkl_intel_thread.a ${MKLROOT}/libmkl_core.a -liomp5 -lm"
TLIBC=/theoryfs2/ds/cdsgroup/psi4-compile/psi4cmake/psi4/glibc2.12rpm
LIBC_INTERJECT="-L${TLIBC}/usr/lib64 ${TLIBC}/lib64/libpthread.so.0 ${TLIBC}/lib64/libc.so.6"
NCONDA=/theoryfs2/ds/cdsgroup/psi4-install/miniconda/envs/gslenv/lib
DEPS_INTERJECT="${NCONDA}/libgsl.so ${NCONDA}/libgslcblas.so ${NCONDA}/libhdf5.so ${NCONDA}/libhdf5_hl.so ${NCONDA}/libhdf5.so -lpthread ${NCONDA}/libz.so -lrt -ldl -lm"
INTERJECT="${LIBC_INTERJECT} ${LAPACK_INTERJECT} ${DEPS_INTERJECT}"
INTERJECT="-L/theoryfs2/ds/cdsgroup/psi4-compile/psi4cmake/psi4/glibc2.12rpm/usr/lib64 /theoryfs2/ds/cdsgroup/psi4-compile/psi4cmake/psi4/glibc2.12rpm/lib64/libpthread.so.0 /theoryfs2/ds/cdsgroup/psi4-compile/psi4cmake/psi4/glibc2.12rpm/lib64/libc.so.6 /theoryfs2/common/software/intel2015/composer_xe_2015.0.090/mkl/lib/intel64/libmkl_intel_lp64.a /theoryfs2/common/software/intel2015/composer_xe_2015.0.090/mkl/lib/intel64/libmkl_intel_thread.a /theoryfs2/common/software/intel2015/composer_xe_2015.0.090/mkl/lib/intel64/libmkl_core.a /theoryfs2/common/software/intel2015/composer_xe_2015.0.090/compiler/lib/intel64/libiomp5.so -lm" # /theoryfs2/ds/cdsgroup/psi4-install/miniconda/envs/gslenv/lib/libgsl.so /theoryfs2/ds/cdsgroup/psi4-install/miniconda/envs/gslenv/lib/libgslcblas.so /theoryfs2/ds/cdsgroup/psi4-install/miniconda/envs/gslenv/lib/libhdf5.so /theoryfs2/ds/cdsgroup/psi4-install/miniconda/envs/gslenv/lib/libhdf5_hl.so /theoryfs2/ds/cdsgroup/psi4-install/miniconda/envs/gslenv/lib/libhdf5.so -lpthread /theoryfs2/ds/cdsgroup/psi4-install/miniconda/envs/gslenv/lib/libz.so -lrt -ldl -lm"
echo "dog"
echo ${INTERJECT}
echo "dog"

REDIST=/theoryfs2/common/software/intel2015/composer_xe_2015.0.090/compiler/lib/intel64/libiomp5.so

mkdir build
cd build
mkdir lib
cp ${REDIST} ${PREFIX}/lib
VERBOSE=1 cmake \
    -DCMAKE_CXX_COMPILER=icpc \
    -DMKL=ON \
    -DBUILD_DOCUMENTATION=OFF \
    -DENABLE_TESTS=OFF \
    -DENABLE_GENERIC=ON \
    -DENABLE_XHOST=OFF \
    -DLINK_INTERJECT="${INTERJECT}" \
    -DHDF5_INCLUDE_DIRS=/theoryfs2/ds/cdsgroup/psi4-install/miniconda/envs/gslenv/include \
    -DCMAKE_INSTALL_PREFIX=${PREFIX} \
    -DCMAKE_INSTALL_LIBDIR=lib \
    ${SRC_DIR}
make -j3  # -j${CPU_COUNT}
make install

    #-DLAPACK_INTERJECT="${MKLROOT}/libmkl_intel_lp64.a ${MKLROOT}/libmkl_intel_thread.a ${MKLROOT}/libmkl_core.a -liomp5 -lm" \
    #-DLIBC_INTERJECT="-L${TLIBC}/usr/lib64 ${TLIBC}/lib64/libpthread.so.0 ${TLIBC}/lib64/libc.so.6" \


# /theoryfs2/ds/cdsgroup/psi4-compile/psi4mangle/psi4/objdir2/interfaces/chemps2/install/lib/libchemps2.a;/usr/lib64/libgsl.so;/usr/lib64/libgslcblas.so;/theoryfs2/ds/cdsgroup/psi4-install/miniconda/envs/gslenv/lib/libhdf5.so;/theoryfs2/ds/cdsgroup/psi4-install/miniconda/envs/gslenv/lib/libhdf5_hl.so;/theoryfs2/ds/cdsgroup/psi4-install/miniconda/envs/gslenv/lib/libhdf5.so;/usr/lib64/libpthread.so;/theoryfs2/ds/cdsgroup/psi4-install/miniconda/envs/boostenv/lib/libz.so;/usr/lib64/librt.so;/usr/lib64/libdl.so;/usr/lib64/libm.so
#-- CheMPS2 incl: /theoryfs2/ds/cdsgroup/psi4-compile/psi4mangle/psi4/objdir2/interfaces/chemps2/install/include;/usr/include;/theoryfs2/ds/cdsgroup/psi4-install/miniconda/envs/gslenv/include


#+    message("lapack ${LAPACK_LIBRARIES}")
#+    set(staticmkl ${MKLROOT}/libmkl_intel_lp64.a;${MKLROOT}/libmkl_intel_thread.a;${MKLROOT}/libmkl_core.a;/t
#+
#+
#+
#+
#+    #target_link_libraries (chemps2-shared ${LAPACK_LIBRARIES} ${HDF5_LIBRARIES} ${GSL_LIBRARIES})
#+    target_link_libraries (chemps2-shared ${LIBC_INTERJECT} ${staticmkl} ${HDF5_LIBRARIES} ${GSL_LIBRARIES})


#-L/theoryfs2/ds/cdsgroup/psi4-compile/psi4cmake/psi4/glibc2.12rpm/usr/lib64 /theoryfs2/ds/cdsgroup/psi4-compile/psi4cmake/psi4/glibc2.12rpm/lib64/libpthread.so.0 /theoryfs2/ds/cdsgroup/psi4-compile/psi4cmake/psi4/glibc2.12rpm/lib64/libc.so.6 /theoryfs2/common/software/intel2015/composer_xe_2015.0.090/mkl/lib/intel64/libmkl_intel_lp64.a /theoryfs2/common/software/intel2015/composer_xe_2015.0.090/mkl/lib/intel64/libmkl_intel_thread.a /theoryfs2/common/software/intel2015/composer_xe_2015.0.090/mkl/lib/intel64/libmkl_core.a /theoryfs2/ds/cdsgroup/psi4-install/miniconda/envs/gslenv/lib/libiomp5.so -lm /theoryfs2/ds/cdsgroup/psi4-install/miniconda/envs/gslenv/lib/libgsl.so /theoryfs2/ds/cdsgroup/psi4-install/miniconda/envs/gslenv/lib/libgslcblas.so /theoryfs2/ds/cdsgroup/psi4-install/miniconda/envs/gslenv/lib/libhdf5.so /theoryfs2/ds/cdsgroup/psi4-install/miniconda/envs/gslenv/lib/libhdf5_hl.so /theoryfs2/ds/cdsgroup/psi4-install/miniconda/envs/gslenv/lib/libhdf5.so -lpthread /theoryfs2/ds/cdsgroup/psi4-install/miniconda/envs/gslenv/lib/libz.so -lrt -ldl -lm
