cmake_minimum_required(VERSION 2.6)

project( gsl )


set(CMAKE_RUNTIME_OUTPUT_DIRECTORY  ${CMAKE_BINARY_DIR}/bin) 
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY  ${CMAKE_BINARY_DIR}/lib) 
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY  ${CMAKE_BINARY_DIR}/lib) 


if(NOT GSL_DIR)
    set(GSL_DIR ${CMAKE_SOURCE_DIR})
endif()

set(gsl_source_list 
  ${GSL_DIR}/version.c
  ${GSL_DIR}/block/block.c
  ${GSL_DIR}/block/file.c
  ${GSL_DIR}/fft/dft.c
  ${GSL_DIR}/fft/factorize.c
  ${GSL_DIR}/fft/fft.c
  ${GSL_DIR}/fft/signals.c
  ${GSL_DIR}/min/bracketing.c
  ${GSL_DIR}/min/brent.c
  ${GSL_DIR}/min/convergence.c
  ${GSL_DIR}/min/fsolver.c
  ${GSL_DIR}/min/golden.c
  ${GSL_DIR}/min/quad_golden.c
  ${GSL_DIR}/blas/blas.c
  ${GSL_DIR}/cdf/beta.c
  ${GSL_DIR}/cdf/betainv.c
  ${GSL_DIR}/cdf/binomial.c
  ${GSL_DIR}/cdf/cauchy.c
  ${GSL_DIR}/cdf/cauchyinv.c
  ${GSL_DIR}/cdf/chisq.c
  ${GSL_DIR}/cdf/chisqinv.c
  ${GSL_DIR}/cdf/exponential.c
  ${GSL_DIR}/cdf/exponentialinv.c
  ${GSL_DIR}/cdf/exppow.c
  ${GSL_DIR}/cdf/fdist.c
  ${GSL_DIR}/cdf/fdistinv.c
  ${GSL_DIR}/cdf/flat.c
  ${GSL_DIR}/cdf/flatinv.c
  ${GSL_DIR}/cdf/gamma.c
  ${GSL_DIR}/cdf/gammainv.c
  ${GSL_DIR}/cdf/gauss.c
  ${GSL_DIR}/cdf/gaussinv.c
  ${GSL_DIR}/cdf/geometric.c
  ${GSL_DIR}/cdf/gumbel1.c
  ${GSL_DIR}/cdf/gumbel1inv.c
  ${GSL_DIR}/cdf/gumbel2.c
  ${GSL_DIR}/cdf/gumbel2inv.c
  ${GSL_DIR}/cdf/hypergeometric.c
  ${GSL_DIR}/cdf/laplace.c
  ${GSL_DIR}/cdf/laplaceinv.c
  ${GSL_DIR}/cdf/logistic.c
  ${GSL_DIR}/cdf/logisticinv.c
  ${GSL_DIR}/cdf/lognormal.c
  ${GSL_DIR}/cdf/lognormalinv.c
  ${GSL_DIR}/cdf/nbinomial.c
  ${GSL_DIR}/cdf/pareto.c
  ${GSL_DIR}/cdf/paretoinv.c
  ${GSL_DIR}/cdf/pascal.c
  ${GSL_DIR}/cdf/poisson.c
  ${GSL_DIR}/cdf/rayleigh.c
  ${GSL_DIR}/cdf/rayleighinv.c
  ${GSL_DIR}/cdf/tdist.c
  ${GSL_DIR}/cdf/tdistinv.c
  ${GSL_DIR}/cdf/weibull.c
  ${GSL_DIR}/cdf/weibullinv.c
  ${GSL_DIR}/cheb/deriv.c
  ${GSL_DIR}/cheb/eval.c
  ${GSL_DIR}/cheb/init.c
  ${GSL_DIR}/cheb/integ.c
  ${GSL_DIR}/combination/combination.c
  ${GSL_DIR}/combination/file.c
  ${GSL_DIR}/combination/init.c
  ${GSL_DIR}/complex/math.c
  ${GSL_DIR}/deriv/deriv.c
  ${GSL_DIR}/dht/dht.c
  ${GSL_DIR}/diff/diff.c
  ${GSL_DIR}/eigen/francis.c
  ${GSL_DIR}/eigen/gen.c
  ${GSL_DIR}/eigen/genherm.c
  ${GSL_DIR}/eigen/genhermv.c
  ${GSL_DIR}/eigen/gensymm.c
  ${GSL_DIR}/eigen/gensymmv.c
  ${GSL_DIR}/eigen/genv.c
  ${GSL_DIR}/eigen/herm.c
  ${GSL_DIR}/eigen/hermv.c
  ${GSL_DIR}/eigen/jacobi.c
  ${GSL_DIR}/eigen/nonsymm.c
  ${GSL_DIR}/eigen/nonsymmv.c
  ${GSL_DIR}/eigen/schur.c
  ${GSL_DIR}/eigen/sort.c
  ${GSL_DIR}/eigen/symm.c
  ${GSL_DIR}/eigen/symmv.c
  ${GSL_DIR}/err/error.c
  ${GSL_DIR}/err/message.c
  ${GSL_DIR}/err/stream.c
  ${GSL_DIR}/err/strerror.c
  ${GSL_DIR}/fit/linear.c
  ${GSL_DIR}/histogram/add.c
  ${GSL_DIR}/histogram/add2d.c
  ${GSL_DIR}/histogram/calloc_range.c
  ${GSL_DIR}/histogram/calloc_range2d.c
  ${GSL_DIR}/histogram/copy.c
  ${GSL_DIR}/histogram/copy2d.c
  ${GSL_DIR}/histogram/file.c
  ${GSL_DIR}/histogram/file2d.c
  ${GSL_DIR}/histogram/get.c
  ${GSL_DIR}/histogram/get2d.c
  ${GSL_DIR}/histogram/init.c
  ${GSL_DIR}/histogram/init2d.c
  ${GSL_DIR}/histogram/maxval.c
  ${GSL_DIR}/histogram/maxval2d.c
  ${GSL_DIR}/histogram/oper.c
  ${GSL_DIR}/histogram/oper2d.c
  ${GSL_DIR}/histogram/params.c
  ${GSL_DIR}/histogram/params2d.c
  ${GSL_DIR}/histogram/pdf.c
  ${GSL_DIR}/histogram/pdf2d.c
  ${GSL_DIR}/histogram/reset.c
  ${GSL_DIR}/histogram/reset2d.c
  ${GSL_DIR}/histogram/stat.c
  ${GSL_DIR}/histogram/stat2d.c
  ${GSL_DIR}/ieee-utils/endian.c
  ${GSL_DIR}/ieee-utils/env.c
  ${GSL_DIR}/ieee-utils/fp.c
  ${GSL_DIR}/ieee-utils/make_rep.c
  ${GSL_DIR}/ieee-utils/print.c
  ${GSL_DIR}/ieee-utils/read.c
  ${GSL_DIR}/ieee-utils/standardize.c
  ${GSL_DIR}/integration/qag.c
  ${GSL_DIR}/integration/qagp.c
  ${GSL_DIR}/integration/qags.c
  ${GSL_DIR}/integration/qawc.c
  ${GSL_DIR}/integration/qawf.c
  ${GSL_DIR}/integration/qawo.c
  ${GSL_DIR}/integration/qaws.c
  ${GSL_DIR}/integration/qcheb.c
  ${GSL_DIR}/integration/qk.c
  ${GSL_DIR}/integration/qk15.c
  ${GSL_DIR}/integration/qk21.c
  ${GSL_DIR}/integration/qk31.c
  ${GSL_DIR}/integration/qk41.c
  ${GSL_DIR}/integration/qk51.c
  ${GSL_DIR}/integration/qk61.c
  ${GSL_DIR}/integration/qmomo.c
  ${GSL_DIR}/integration/qmomof.c
  ${GSL_DIR}/integration/qng.c
  ${GSL_DIR}/integration/workspace.c
  ${GSL_DIR}/interpolation/accel.c
  ${GSL_DIR}/interpolation/akima.c
  ${GSL_DIR}/interpolation/cspline.c
  ${GSL_DIR}/interpolation/interp.c
  ${GSL_DIR}/interpolation/linear.c
  ${GSL_DIR}/interpolation/poly.c
  ${GSL_DIR}/interpolation/spline.c
  ${GSL_DIR}/linalg/balance.c
  ${GSL_DIR}/linalg/balancemat.c
  ${GSL_DIR}/linalg/bidiag.c
  ${GSL_DIR}/linalg/cholesky.c
  ${GSL_DIR}/linalg/choleskyc.c
  ${GSL_DIR}/linalg/exponential.c
  ${GSL_DIR}/linalg/hermtd.c
  ${GSL_DIR}/linalg/hessenberg.c
  ${GSL_DIR}/linalg/hesstri.c
  ${GSL_DIR}/linalg/hh.c
  ${GSL_DIR}/linalg/householder.c
  ${GSL_DIR}/linalg/householdercomplex.c
  ${GSL_DIR}/linalg/lq.c
  ${GSL_DIR}/linalg/lu.c
  ${GSL_DIR}/linalg/luc.c
  ${GSL_DIR}/linalg/multiply.c
  ${GSL_DIR}/linalg/ptlq.c
  ${GSL_DIR}/linalg/qr.c
  ${GSL_DIR}/linalg/qrpt.c
  ${GSL_DIR}/linalg/svd.c
  ${GSL_DIR}/linalg/symmtd.c
  ${GSL_DIR}/linalg/tridiag.c
  ${GSL_DIR}/matrix/copy.c
  ${GSL_DIR}/matrix/file.c
  ${GSL_DIR}/matrix/getset.c
  ${GSL_DIR}/matrix/init.c
  ${GSL_DIR}/matrix/matrix.c
  ${GSL_DIR}/matrix/minmax.c
  ${GSL_DIR}/matrix/oper.c
  ${GSL_DIR}/matrix/prop.c
  ${GSL_DIR}/matrix/rowcol.c
  ${GSL_DIR}/matrix/submatrix.c
  ${GSL_DIR}/matrix/view.c
  ${GSL_DIR}/monte/miser.c
  ${GSL_DIR}/monte/plain.c
  ${GSL_DIR}/monte/vegas.c
  ${GSL_DIR}/multifit/convergence.c
  ${GSL_DIR}/multifit/covar.c
  ${GSL_DIR}/multifit/fsolver.c
  ${GSL_DIR}/multifit/gradient.c
  ${GSL_DIR}/multifit/lmder.c
  ${GSL_DIR}/multifit/multilinear.c
  ${GSL_DIR}/multifit/work.c
  ${GSL_DIR}/multimin/conjugate_fr.c
  ${GSL_DIR}/multimin/conjugate_pr.c
  ${GSL_DIR}/multimin/convergence.c
  ${GSL_DIR}/multimin/diff.c
  ${GSL_DIR}/multimin/fdfminimizer.c
  ${GSL_DIR}/multimin/fminimizer.c
  ${GSL_DIR}/multimin/simplex.c
  ${GSL_DIR}/multimin/simplex2.c
  ${GSL_DIR}/multimin/steepest_descent.c
  ${GSL_DIR}/multimin/vector_bfgs.c
  ${GSL_DIR}/multimin/vector_bfgs2.c
  ${GSL_DIR}/multiroots/broyden.c
  ${GSL_DIR}/multiroots/convergence.c
  ${GSL_DIR}/multiroots/dnewton.c
  ${GSL_DIR}/multiroots/fdfsolver.c
  ${GSL_DIR}/multiroots/fdjac.c
  ${GSL_DIR}/multiroots/fsolver.c
  ${GSL_DIR}/multiroots/gnewton.c
  ${GSL_DIR}/multiroots/hybrid.c
  ${GSL_DIR}/multiroots/hybridj.c
  ${GSL_DIR}/multiroots/newton.c
  ${GSL_DIR}/ntuple/ntuple.c
  ${GSL_DIR}/ode-initval/bsimp.c
  ${GSL_DIR}/ode-initval/control.c
  ${GSL_DIR}/ode-initval/cscal.c
  ${GSL_DIR}/ode-initval/cstd.c
  ${GSL_DIR}/ode-initval/evolve.c
  ${GSL_DIR}/ode-initval/gear1.c
  ${GSL_DIR}/ode-initval/gear2.c
  ${GSL_DIR}/ode-initval/rk2.c
  ${GSL_DIR}/ode-initval/rk2imp.c
  ${GSL_DIR}/ode-initval/rk2simp.c
  ${GSL_DIR}/ode-initval/rk4.c
  ${GSL_DIR}/ode-initval/rk4imp.c
  ${GSL_DIR}/ode-initval/rk8pd.c
  ${GSL_DIR}/ode-initval/rkck.c
  ${GSL_DIR}/ode-initval/rkf45.c
  ${GSL_DIR}/ode-initval/step.c
  ${GSL_DIR}/permutation/canonical.c
  ${GSL_DIR}/permutation/file.c
  ${GSL_DIR}/permutation/init.c
  ${GSL_DIR}/permutation/permutation.c
  ${GSL_DIR}/permutation/permute.c
  ${GSL_DIR}/poly/dd.c
  ${GSL_DIR}/poly/deriv.c
  ${GSL_DIR}/poly/eval.c
  ${GSL_DIR}/poly/solve_cubic.c
  ${GSL_DIR}/poly/solve_quadratic.c
  ${GSL_DIR}/poly/zsolve.c
  ${GSL_DIR}/poly/zsolve_cubic.c
  ${GSL_DIR}/poly/zsolve_init.c
  ${GSL_DIR}/poly/zsolve_quadratic.c
  ${GSL_DIR}/qrng/halton.c
  ${GSL_DIR}/qrng/niederreiter-2.c
  ${GSL_DIR}/qrng/qrng.c
  ${GSL_DIR}/qrng/reversehalton.c
  ${GSL_DIR}/qrng/sobol.c
  ${GSL_DIR}/randist/bernoulli.c
  ${GSL_DIR}/randist/beta.c
  ${GSL_DIR}/randist/bigauss.c
  ${GSL_DIR}/randist/binomial.c
  ${GSL_DIR}/randist/binomial_tpe.c
  ${GSL_DIR}/randist/cauchy.c
  ${GSL_DIR}/randist/chisq.c
  ${GSL_DIR}/randist/dirichlet.c
  ${GSL_DIR}/randist/discrete.c
  ${GSL_DIR}/randist/erlang.c
  ${GSL_DIR}/randist/exponential.c
  ${GSL_DIR}/randist/exppow.c
  ${GSL_DIR}/randist/fdist.c
  ${GSL_DIR}/randist/flat.c
  ${GSL_DIR}/randist/gamma.c
  ${GSL_DIR}/randist/gauss.c
  ${GSL_DIR}/randist/gausstail.c
  ${GSL_DIR}/randist/gausszig.c
  ${GSL_DIR}/randist/geometric.c
  ${GSL_DIR}/randist/gumbel.c
  ${GSL_DIR}/randist/hyperg.c
  ${GSL_DIR}/randist/landau.c
  ${GSL_DIR}/randist/laplace.c
  ${GSL_DIR}/randist/levy.c
  ${GSL_DIR}/randist/logarithmic.c
  ${GSL_DIR}/randist/logistic.c
  ${GSL_DIR}/randist/lognormal.c
  ${GSL_DIR}/randist/multinomial.c
  ${GSL_DIR}/randist/nbinomial.c
  ${GSL_DIR}/randist/pareto.c
  ${GSL_DIR}/randist/pascal.c
  ${GSL_DIR}/randist/poisson.c
  ${GSL_DIR}/randist/rayleigh.c
  ${GSL_DIR}/randist/shuffle.c
  ${GSL_DIR}/randist/sphere.c
  ${GSL_DIR}/randist/tdist.c
  ${GSL_DIR}/randist/weibull.c
  ${GSL_DIR}/rng/borosh13.c
  ${GSL_DIR}/rng/cmrg.c
  ${GSL_DIR}/rng/coveyou.c
  ${GSL_DIR}/rng/default.c
  ${GSL_DIR}/rng/file.c
  ${GSL_DIR}/rng/fishman18.c
  ${GSL_DIR}/rng/fishman20.c
  ${GSL_DIR}/rng/fishman2x.c
  ${GSL_DIR}/rng/gfsr4.c
  ${GSL_DIR}/rng/knuthran.c
  ${GSL_DIR}/rng/knuthran2.c
  ${GSL_DIR}/rng/knuthran2002.c
  ${GSL_DIR}/rng/lecuyer21.c
  ${GSL_DIR}/rng/minstd.c
  ${GSL_DIR}/rng/mrg.c
  ${GSL_DIR}/rng/mt.c
  ${GSL_DIR}/rng/r250.c
  ${GSL_DIR}/rng/ran0.c
  ${GSL_DIR}/rng/ran1.c
  ${GSL_DIR}/rng/ran2.c
  ${GSL_DIR}/rng/ran3.c
  ${GSL_DIR}/rng/rand.c
  ${GSL_DIR}/rng/rand48.c
  ${GSL_DIR}/rng/random.c
  ${GSL_DIR}/rng/randu.c
  ${GSL_DIR}/rng/ranf.c
  ${GSL_DIR}/rng/ranlux.c
  ${GSL_DIR}/rng/ranlxd.c
  ${GSL_DIR}/rng/ranlxs.c
  ${GSL_DIR}/rng/ranmar.c
  ${GSL_DIR}/rng/rng.c
  ${GSL_DIR}/rng/slatec.c
  ${GSL_DIR}/rng/taus.c
  ${GSL_DIR}/rng/taus113.c
  ${GSL_DIR}/rng/transputer.c
  ${GSL_DIR}/rng/tt.c
  ${GSL_DIR}/rng/types.c
  ${GSL_DIR}/rng/uni.c
  ${GSL_DIR}/rng/uni32.c
  ${GSL_DIR}/rng/vax.c
  ${GSL_DIR}/rng/waterman14.c
  ${GSL_DIR}/rng/zuf.c
  ${GSL_DIR}/roots/bisection.c
  ${GSL_DIR}/roots/brent.c
  ${GSL_DIR}/roots/convergence.c
  ${GSL_DIR}/roots/falsepos.c
  ${GSL_DIR}/roots/fdfsolver.c
  ${GSL_DIR}/roots/fsolver.c
  ${GSL_DIR}/roots/newton.c
  ${GSL_DIR}/roots/secant.c
  ${GSL_DIR}/roots/steffenson.c
  ${GSL_DIR}/siman/siman.c
  ${GSL_DIR}/sort/sort.c
  ${GSL_DIR}/sort/sortind.c
  ${GSL_DIR}/sort/sortvec.c
  ${GSL_DIR}/sort/sortvecind.c
  ${GSL_DIR}/sort/subset.c
  ${GSL_DIR}/sort/subsetind.c
  ${GSL_DIR}/specfunc/airy.c
  ${GSL_DIR}/specfunc/airy_der.c
  ${GSL_DIR}/specfunc/airy_zero.c
  ${GSL_DIR}/specfunc/atanint.c
  ${GSL_DIR}/specfunc/bessel.c
  ${GSL_DIR}/specfunc/bessel_amp_phase.c
  ${GSL_DIR}/specfunc/bessel_i.c
  ${GSL_DIR}/specfunc/bessel_I0.c
  ${GSL_DIR}/specfunc/bessel_I1.c
  ${GSL_DIR}/specfunc/bessel_In.c
  ${GSL_DIR}/specfunc/bessel_Inu.c
  ${GSL_DIR}/specfunc/bessel_j.c
  ${GSL_DIR}/specfunc/bessel_J0.c
  ${GSL_DIR}/specfunc/bessel_J1.c
  ${GSL_DIR}/specfunc/bessel_Jn.c
  ${GSL_DIR}/specfunc/bessel_Jnu.c
  ${GSL_DIR}/specfunc/bessel_k.c
  ${GSL_DIR}/specfunc/bessel_K0.c
  ${GSL_DIR}/specfunc/bessel_K1.c
  ${GSL_DIR}/specfunc/bessel_Kn.c
  ${GSL_DIR}/specfunc/bessel_Knu.c
  ${GSL_DIR}/specfunc/bessel_olver.c
  ${GSL_DIR}/specfunc/bessel_sequence.c
  ${GSL_DIR}/specfunc/bessel_temme.c
  ${GSL_DIR}/specfunc/bessel_y.c
  ${GSL_DIR}/specfunc/bessel_Y0.c
  ${GSL_DIR}/specfunc/bessel_Y1.c
  ${GSL_DIR}/specfunc/bessel_Yn.c
  ${GSL_DIR}/specfunc/bessel_Ynu.c
  ${GSL_DIR}/specfunc/bessel_zero.c
  ${GSL_DIR}/specfunc/beta.c
  ${GSL_DIR}/specfunc/beta_inc.c
  ${GSL_DIR}/specfunc/clausen.c
  ${GSL_DIR}/specfunc/coulomb.c
  ${GSL_DIR}/specfunc/coulomb_bound.c
  ${GSL_DIR}/specfunc/coupling.c
  ${GSL_DIR}/specfunc/dawson.c
  ${GSL_DIR}/specfunc/debye.c
  ${GSL_DIR}/specfunc/dilog.c
  ${GSL_DIR}/specfunc/elementary.c
  ${GSL_DIR}/specfunc/ellint.c
  ${GSL_DIR}/specfunc/elljac.c
  ${GSL_DIR}/specfunc/erfc.c
  ${GSL_DIR}/specfunc/exp.c
  ${GSL_DIR}/specfunc/expint.c
  ${GSL_DIR}/specfunc/expint3.c
  ${GSL_DIR}/specfunc/fermi_dirac.c
  ${GSL_DIR}/specfunc/gamma.c
  ${GSL_DIR}/specfunc/gamma_inc.c
  ${GSL_DIR}/specfunc/gegenbauer.c
  ${GSL_DIR}/specfunc/hyperg.c
  ${GSL_DIR}/specfunc/hyperg_0F1.c
  ${GSL_DIR}/specfunc/hyperg_1F1.c
  ${GSL_DIR}/specfunc/hyperg_2F0.c
  ${GSL_DIR}/specfunc/hyperg_2F1.c
  ${GSL_DIR}/specfunc/hyperg_U.c
  ${GSL_DIR}/specfunc/laguerre.c
  ${GSL_DIR}/specfunc/lambert.c
  ${GSL_DIR}/specfunc/legendre_con.c
  ${GSL_DIR}/specfunc/legendre_H3d.c
  ${GSL_DIR}/specfunc/legendre_poly.c
  ${GSL_DIR}/specfunc/legendre_Qn.c
  ${GSL_DIR}/specfunc/log.c
  ${GSL_DIR}/specfunc/mathieu_angfunc.c
  ${GSL_DIR}/specfunc/mathieu_charv.c
  ${GSL_DIR}/specfunc/mathieu_coeff.c
  ${GSL_DIR}/specfunc/mathieu_radfunc.c
  ${GSL_DIR}/specfunc/mathieu_workspace.c
  ${GSL_DIR}/specfunc/poch.c
  ${GSL_DIR}/specfunc/pow_int.c
  ${GSL_DIR}/specfunc/psi.c
  ${GSL_DIR}/specfunc/result.c
  ${GSL_DIR}/specfunc/shint.c
  ${GSL_DIR}/specfunc/sinint.c
  ${GSL_DIR}/specfunc/synchrotron.c
  ${GSL_DIR}/specfunc/transport.c
  ${GSL_DIR}/specfunc/trig.c
  ${GSL_DIR}/specfunc/zeta.c
  ${GSL_DIR}/statistics/absdev.c
  ${GSL_DIR}/statistics/covariance.c
  ${GSL_DIR}/statistics/kurtosis.c
  ${GSL_DIR}/statistics/lag1.c
  ${GSL_DIR}/statistics/mean.c
  ${GSL_DIR}/statistics/median.c
  ${GSL_DIR}/statistics/minmax.c
  ${GSL_DIR}/statistics/p_variance.c
  ${GSL_DIR}/statistics/quantiles.c
  ${GSL_DIR}/statistics/skew.c
  ${GSL_DIR}/statistics/ttest.c
  ${GSL_DIR}/statistics/variance.c
  ${GSL_DIR}/statistics/wabsdev.c
  ${GSL_DIR}/statistics/wkurtosis.c
  ${GSL_DIR}/statistics/wmean.c
  ${GSL_DIR}/statistics/wskew.c
  ${GSL_DIR}/statistics/wvariance.c
  ${GSL_DIR}/sum/levin_u.c
  ${GSL_DIR}/sum/levin_utrunc.c
  ${GSL_DIR}/sum/work_u.c
  ${GSL_DIR}/sum/work_utrunc.c
  ${GSL_DIR}/sys/coerce.c
  ${GSL_DIR}/sys/expm1.c
  ${GSL_DIR}/sys/fcmp.c
  ${GSL_DIR}/sys/fdiv.c
  ${GSL_DIR}/sys/hypot.c
  ${GSL_DIR}/sys/infnan.c
  ${GSL_DIR}/sys/invhyp.c
  ${GSL_DIR}/sys/ldfrexp.c
  ${GSL_DIR}/sys/log1p.c
  ${GSL_DIR}/sys/minmax.c
  ${GSL_DIR}/sys/pow_int.c
  ${GSL_DIR}/sys/prec.c
  ${GSL_DIR}/test/results.c
  ${GSL_DIR}/vector/copy.c
  ${GSL_DIR}/vector/file.c
  ${GSL_DIR}/vector/init.c
  ${GSL_DIR}/vector/minmax.c
  ${GSL_DIR}/vector/oper.c
  ${GSL_DIR}/vector/prop.c
  ${GSL_DIR}/vector/reim.c
  ${GSL_DIR}/vector/subvector.c
  ${GSL_DIR}/vector/swap.c
  ${GSL_DIR}/vector/vector.c
  ${GSL_DIR}/vector/view.c
  ${GSL_DIR}/wavelet/bspline.c
  ${GSL_DIR}/wavelet/daubechies.c
  ${GSL_DIR}/wavelet/dwt.c
  ${GSL_DIR}/wavelet/haar.c
  ${GSL_DIR}/wavelet/wavelet.c
  ${GSL_DIR}/bspline/bspline.c
  
  # prevent linker errors
  ${GSL_DIR}/matrix/swap.c
  ${GSL_DIR}/multifit/fdfsolver.c
  ${GSL_DIR}/block/init.c
)


set(cblas_source_list
  ${GSL_DIR}/cblas/caxpy.c
  ${GSL_DIR}/cblas/ccopy.c
  ${GSL_DIR}/cblas/cdotc_sub.c
  ${GSL_DIR}/cblas/cdotu_sub.c
  ${GSL_DIR}/cblas/cgbmv.c
  ${GSL_DIR}/cblas/cgemm.c
  ${GSL_DIR}/cblas/cgemv.c
  ${GSL_DIR}/cblas/cgerc.c
  ${GSL_DIR}/cblas/cgeru.c
  ${GSL_DIR}/cblas/chbmv.c
  ${GSL_DIR}/cblas/chemm.c
  ${GSL_DIR}/cblas/chemv.c
  ${GSL_DIR}/cblas/cher.c
  ${GSL_DIR}/cblas/cher2.c
  ${GSL_DIR}/cblas/cher2k.c
  ${GSL_DIR}/cblas/cherk.c
  ${GSL_DIR}/cblas/chpmv.c
  ${GSL_DIR}/cblas/chpr.c
  ${GSL_DIR}/cblas/chpr2.c
  ${GSL_DIR}/cblas/cscal.c
  ${GSL_DIR}/cblas/csscal.c
  ${GSL_DIR}/cblas/cswap.c
  ${GSL_DIR}/cblas/csymm.c
  ${GSL_DIR}/cblas/csyr2k.c
  ${GSL_DIR}/cblas/csyrk.c
  ${GSL_DIR}/cblas/ctbmv.c
  ${GSL_DIR}/cblas/ctbsv.c
  ${GSL_DIR}/cblas/ctpmv.c
  ${GSL_DIR}/cblas/ctpsv.c
  ${GSL_DIR}/cblas/ctrmm.c
  ${GSL_DIR}/cblas/ctrmv.c
  ${GSL_DIR}/cblas/ctrsm.c
  ${GSL_DIR}/cblas/ctrsv.c
  ${GSL_DIR}/cblas/dasum.c
  ${GSL_DIR}/cblas/daxpy.c
  ${GSL_DIR}/cblas/dcopy.c
  ${GSL_DIR}/cblas/ddot.c
  ${GSL_DIR}/cblas/dgbmv.c
  ${GSL_DIR}/cblas/dgemm.c
  ${GSL_DIR}/cblas/dgemv.c
  ${GSL_DIR}/cblas/dger.c
  ${GSL_DIR}/cblas/dnrm2.c
  ${GSL_DIR}/cblas/drot.c
  ${GSL_DIR}/cblas/drotg.c
  ${GSL_DIR}/cblas/drotm.c
  ${GSL_DIR}/cblas/drotmg.c
  ${GSL_DIR}/cblas/dsbmv.c
  ${GSL_DIR}/cblas/dscal.c
  ${GSL_DIR}/cblas/dsdot.c
  ${GSL_DIR}/cblas/dspmv.c
  ${GSL_DIR}/cblas/dspr.c
  ${GSL_DIR}/cblas/dspr2.c
  ${GSL_DIR}/cblas/dswap.c
  ${GSL_DIR}/cblas/dsymm.c
  ${GSL_DIR}/cblas/dsymv.c
  ${GSL_DIR}/cblas/dsyr.c
  ${GSL_DIR}/cblas/dsyr2.c
  ${GSL_DIR}/cblas/dsyr2k.c
  ${GSL_DIR}/cblas/dsyrk.c
  ${GSL_DIR}/cblas/dtbmv.c
  ${GSL_DIR}/cblas/dtbsv.c
  ${GSL_DIR}/cblas/dtpmv.c
  ${GSL_DIR}/cblas/dtpsv.c
  ${GSL_DIR}/cblas/dtrmm.c
  ${GSL_DIR}/cblas/dtrmv.c
  ${GSL_DIR}/cblas/dtrsm.c
  ${GSL_DIR}/cblas/dtrsv.c
  ${GSL_DIR}/cblas/dzasum.c
  ${GSL_DIR}/cblas/dznrm2.c
  ${GSL_DIR}/cblas/hypot.c
  ${GSL_DIR}/cblas/icamax.c
  ${GSL_DIR}/cblas/idamax.c
  ${GSL_DIR}/cblas/isamax.c
  ${GSL_DIR}/cblas/izamax.c
  ${GSL_DIR}/cblas/sasum.c
  ${GSL_DIR}/cblas/saxpy.c
  ${GSL_DIR}/cblas/scasum.c
  ${GSL_DIR}/cblas/scnrm2.c
  ${GSL_DIR}/cblas/scopy.c
  ${GSL_DIR}/cblas/sdot.c
  ${GSL_DIR}/cblas/sdsdot.c
  ${GSL_DIR}/cblas/sgbmv.c
  ${GSL_DIR}/cblas/sgemm.c
  ${GSL_DIR}/cblas/sgemv.c
  ${GSL_DIR}/cblas/sger.c
  ${GSL_DIR}/cblas/snrm2.c
  ${GSL_DIR}/cblas/srot.c
  ${GSL_DIR}/cblas/srotg.c
  ${GSL_DIR}/cblas/srotm.c
  ${GSL_DIR}/cblas/srotmg.c
  ${GSL_DIR}/cblas/ssbmv.c
  ${GSL_DIR}/cblas/sscal.c
  ${GSL_DIR}/cblas/sspmv.c
  ${GSL_DIR}/cblas/sspr.c
  ${GSL_DIR}/cblas/sspr2.c
  ${GSL_DIR}/cblas/sswap.c
  ${GSL_DIR}/cblas/ssymm.c
  ${GSL_DIR}/cblas/ssymv.c
  ${GSL_DIR}/cblas/ssyr.c
  ${GSL_DIR}/cblas/ssyr2.c
  ${GSL_DIR}/cblas/ssyr2k.c
  ${GSL_DIR}/cblas/ssyrk.c
  ${GSL_DIR}/cblas/stbmv.c
  ${GSL_DIR}/cblas/stbsv.c
  ${GSL_DIR}/cblas/stpmv.c
  ${GSL_DIR}/cblas/stpsv.c
  ${GSL_DIR}/cblas/strmm.c
  ${GSL_DIR}/cblas/strmv.c
  ${GSL_DIR}/cblas/strsm.c
  ${GSL_DIR}/cblas/strsv.c
  ${GSL_DIR}/cblas/xerbla.c
  ${GSL_DIR}/cblas/zaxpy.c
  ${GSL_DIR}/cblas/zcopy.c
  ${GSL_DIR}/cblas/zdotc_sub.c
  ${GSL_DIR}/cblas/zdotu_sub.c
  ${GSL_DIR}/cblas/zdscal.c
  ${GSL_DIR}/cblas/zgbmv.c
  ${GSL_DIR}/cblas/zgemm.c
  ${GSL_DIR}/cblas/zgemv.c
  ${GSL_DIR}/cblas/zgerc.c
  ${GSL_DIR}/cblas/zgeru.c
  ${GSL_DIR}/cblas/zhbmv.c
  ${GSL_DIR}/cblas/zhemm.c
  ${GSL_DIR}/cblas/zhemv.c
  ${GSL_DIR}/cblas/zher.c
  ${GSL_DIR}/cblas/zher2.c
  ${GSL_DIR}/cblas/zher2k.c
  ${GSL_DIR}/cblas/zherk.c
  ${GSL_DIR}/cblas/zhpmv.c
  ${GSL_DIR}/cblas/zhpr.c
  ${GSL_DIR}/cblas/zhpr2.c
  ${GSL_DIR}/cblas/zscal.c
  ${GSL_DIR}/cblas/zswap.c
  ${GSL_DIR}/cblas/zsymm.c
  ${GSL_DIR}/cblas/zsyr2k.c
  ${GSL_DIR}/cblas/zsyrk.c
  ${GSL_DIR}/cblas/ztbmv.c
  ${GSL_DIR}/cblas/ztbsv.c
  ${GSL_DIR}/cblas/ztpmv.c
  ${GSL_DIR}/cblas/ztpsv.c
  ${GSL_DIR}/cblas/ztrmm.c
  ${GSL_DIR}/cblas/ztrmv.c
  ${GSL_DIR}/cblas/ztrsm.c
  ${GSL_DIR}/cblas/ztrsv.c
)

include_directories(${CMAKE_SOURCE_DIR})

macro(GSL_FILES name folder)
	file(GLOB ${name}_folder_sources ${GSL_DIR}/${folder}/*.c) 
	file(GLOB ${name}_folder_headers ${GSL_DIR}/${folder}/*.h) 
	set(${name}_sources ${${name}_sources} ${${name}_folder_sources})
	set(${name}_headers ${${name}_headers} ${${name}_folder_headers})
	include_directories(${GSL_DIR}/${folder})
endmacro()

set(gsl_folders . blas block bspline cblas cdf cheb combination complex const deriv dht diff eigen err fft fit gsl 
histogram ieee-utils integration interpolation linalg matrix min monte multifit multimin multiroots ntuple ode-initval 
permutation poly qrng randist rng roots siman sort specfunc statistics sum sys test utils vector wavelet)

# collect headers
foreach(current ${gsl_folders})
	GSL_FILES(gsl ${current} ) 
endforeach()

# copy headers to include/gsl
foreach(current ${gsl_headers})
	get_filename_component(filename ${current} NAME)
	configure_file(${current} ${CMAKE_CURRENT_BINARY_DIR}/include/gsl/${filename} COPYONLY) 
endforeach()


if(MSVC)
	add_definitions(-D_CRT_SECURE_NO_WARNINGS)
	set(CMAKE_DEBUG_POSTFIX d)
endif()

include_directories(
  ${GSL_DIR}
  ${CMAKE_CURRENT_BINARY_DIR}/include
)

add_library(gsl STATIC ${gsl_source_list} ${cblas_source_list} ${gsl_headers})

if (NOT CMAKE_INSTALL_PREFIX)
	set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/installed)
endif()

install(FILES ${gsl_headers} DESTINATION include/gsl)
install(TARGETS gsl DESTINATION lib)


