project('geostat', 'cpp', default_options : ['cpp_std=c++2a'])
curl_dep = dependency('libcurl')
json_dep = dependency('nlohmann_json')
sqlite_dep = dependency('sqlite3')
#tinyxml_dep = dependency('tinyxml2')

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 = ['-lgpx', '-lheatmap']
src = ['geostat.cpp', 'okapi.cpp', 'gpx.cpp', 'cache.cpp', 'debug.cpp', 'heat.cpp', 'ocdb.cpp', 'common.cpp']
src_cli = ['geostat_cli.cpp', 'okapi.cpp', 'gpx.cpp', 'cache.cpp', 'debug.cpp', 'heat.cpp', 'ocdb.cpp', 'common.cpp']
src_db = ['geodb.cpp', 'debug.cpp', 'ocdb.cpp', 'okapi.cpp', 'cache.cpp', 'common.cpp']

executable('geostat', src, dependencies : [curl_dep, json_dep, magick_dep, sqlite_dep], link_args: link, install: true)
executable('geostat_cli', src_cli, dependencies : [curl_dep, json_dep, magick_dep, sqlite_dep], link_args: link, install: true)
executable('geodb', src_db, dependencies : [sqlite_dep, json_dep, curl_dep], install: true)

configure_file(input: 'maps/Poland.png', output: 'Poland.png', copy: true, install: true, install_dir: '.')
configure_file(input: 'maps/Poland_big.png', output: 'Poland_big.png', copy: true, install: true, install_dir: '.')
configure_file(input: 'maps/Poland_relief.png', output: 'Poland_relief.png', copy: true, install: true, install_dir: '.')

configure_file(input: 'maps/Podlaskie.png', output: 'Podlaskie.png', copy: true, install: true, install_dir: '.')
configure_file(input: 'maps/Pomorskie.png', output: 'Pomorskie.png', copy: true, install: true, install_dir: '.')
configure_file(input: 'maps/Malopolskie.png', output: 'Malopolskie.png', copy: true, install: true, install_dir: '.')
configure_file(input: 'maps/Warminsko-Mazurskie.png', output: 'Warminsko-Mazurskie.png', copy: true, install: true, install_dir: '.')
configure_file(input: 'maps/Kujawsko-Pomorskie.png', output: 'Kujawsko-Pomorskie.png', copy: true, install: true, install_dir: '.')
configure_file(input: 'maps/Mazowieckie.png', output: 'Mazowieckie.png', copy: true, install: true, install_dir: '.')
configure_file(input: 'maps/Wielkopolskie.png', output: 'Wielkopolskie.png', copy: true, install: true, install_dir: '.')
configure_file(input: 'maps/Dolnoslaskie.png', output: 'Dolnoslaskie.png', copy: true, install: true, install_dir: '.')
configure_file(input: 'maps/Lubelskie.png', output: 'Lubelskie.png', copy: true, install: true, install_dir: '.')
configure_file(input: 'maps/Lodzkie.png', output: 'Lodzkie.png', copy: true, install: true, install_dir: '.')
configure_file(input: 'maps/Lubuskie.png', output: 'Lubuskie.png', copy: true, install: true, install_dir: '.')
configure_file(input: 'maps/Opolskie.png', output: 'Opolskie.png', copy: true, install: true, install_dir: '.')
configure_file(input: 'maps/Podkarpackie.png', output: 'Podkarpackie.png', copy: true, install: true, install_dir: '.')
configure_file(input: 'maps/Slaskie.png', output: 'Slaskie.png', copy: true, install: true, install_dir: '.')
configure_file(input: 'maps/Swietokrzyskie.png', output: 'Swietokrzyskie.png', copy: true, install: true, install_dir: '.')
configure_file(input: 'maps/Zachodniopomorskie.png', output: 'Zachodniopomorskie.png', copy: true, install: true, install_dir: '.')

configure_file(input: 'maps/Benelux.png', output: 'Benelux.png', copy: true, install: true, install_dir: '.')
configure_file(input: 'maps/France.png', output: 'France.png', copy: true, install: true, install_dir: '.')
configure_file(input: 'maps/Germany.png', output: 'Germany.png', copy: true, install: true, install_dir: '.')
configure_file(input: 'maps/Romania.png', output: 'Romania.png', copy: true, install: true, install_dir: '.')
configure_file(input: 'maps/UK.png', output: 'UK.png', copy: true, install: true, install_dir: '.')
configure_file(input: 'maps/USA.png', output: 'USA.png', copy: true, install: true, install_dir: '.')

configure_file(input: 'maps/Europe.png', output: 'Europe.png', copy: true, install: true, install_dir: '.')
configure_file(input: 'maps/World.png', output: 'World.png', copy: true, install: true, install_dir: '.')

configure_file(input: 'geo.css', output: 'geo.css', copy: true, install: true, install_dir: '.')
