project('geostat', 'cpp', default_options : ['cpp_std=c++2a'])
curl_dep = dependency('libcurl')
json_dep = dependency('nlohmann_json')
sqlite_dep = dependency('sqlite3')
gpx_dep = dependency('gpxlib')
#boost_dep = dependency('boost', modules : ['geometry'])
boost_dep = dependency('boost')

magick_dep = dependency('Magick++', required : false)
if not magick_dep.found()
	magick_dep = dependency('GraphicsMagick++', required : false)
	add_global_arguments('-Dgraphicsmagick', language : 'cpp')
endif
if not magick_dep.found()
	error('ImageMagick++ or GraphicsMagick++ not found.')
endif

link = ['-lheatmap']
src = ['geostat.cpp']
src_fr = ['geofriends.cpp']
src_lst = ['geolist.cpp']
src_cli = ['geostat_cli.cpp', 'gpx.cpp']
src_db = ['geodb.cpp']
src_traildb = ['traildb.cpp']

lib_geostat = library('okapi', ['okapi.cpp', 'debug.cpp', 'cache.cpp', 'powertrail.cpp', 'common.cpp', 'heat.cpp', 'ocdb.cpp', 'region.cpp', 'user.cpp'], dependencies : [curl_dep, json_dep, magick_dep, sqlite_dep, boost_dep], link_args: link, install: true)

executable('geostat', src, link_args: link, install: true, link_with : lib_geostat)
executable('geofriends', src_fr, install: true, link_with : lib_geostat)
executable('geolist', src_lst, install: true, link_with : lib_geostat)
executable('geostat_cli', src_cli, dependencies : [gpx_dep], link_args: link, install: true, link_with : lib_geostat)
executable('geodb', src_db, install: true, link_with : lib_geostat)
executable('traildb', src_traildb, install: true, link_with : lib_geostat)

#configure_file(input: 'rating-star.png', output: '@PLAINNAME@', copy: true, install: true, install_dir: '.')
#configure_file(input: 'geo.css', output: '@PLAINNAME@', copy: true, install: true, install_dir: '.')

#subdir('maps')
#subdir('geojson')
