diff --git a/SConstruct b/SConstruct index 7bacf08c8..0923dd5dd 100644 --- a/SConstruct +++ b/SConstruct @@ -124,7 +124,9 @@ for prereq in ('BOOST', 'PNG', 'JPEG', 'TIFF', 'PGSQL', 'PROJ', 'GDAL',): env.ParseConfig(env['FREETYPE_CONFIG'] + ' --libs --cflags') -env.ParseConfig('pkg-config --libs --cflags cairomm-1.0') +if env.Execute('pkg-config --exists cairomm-1.0') == 0: + env.ParseConfig('pkg-config --libs --cflags cairomm-1.0') + env.Append(CXXFLAGS = '-DHAVE_CAIRO'); if env['XMLPARSER'] == 'tinyxml': env.Append(CXXFLAGS = '-DBOOST_PROPERTY_TREE_XML_PARSER_TINYXML -DTIXML_USE_STL') diff --git a/bindings/python/SConscript b/bindings/python/SConscript index e1fad7d8a..19db50f54 100644 --- a/bindings/python/SConscript +++ b/bindings/python/SConscript @@ -24,8 +24,10 @@ import re import os Import('env') - -env.ParseConfig('pkg-config --cflags pycairo') + +if env.Execute('pkg-config --exists pycairo') == 0: + env.ParseConfig('pkg-config --cflags pycairo') + env.Append(CXXFLAGS = '-DHAVE_PYCAIRO'); prefix = env['PYTHON_PREFIX'] + '/' + env['LIBDIR_SCHEMA'] + '/python' + env['PYTHON_VERSION'] + '/site-packages/' install_prefix = env['DESTDIR'] + '/' + prefix diff --git a/bindings/python/mapnik_python.cpp b/bindings/python/mapnik_python.cpp index 71a662abd..8785bea3e 100644 --- a/bindings/python/mapnik_python.cpp +++ b/bindings/python/mapnik_python.cpp @@ -58,14 +58,18 @@ void export_projection(); #include #include +#ifdef HAVE_CAIRO #include +#endif #include #include #include #include #include +#ifdef HAVE_PYCAIRO #include +#endif void render(const mapnik::Map& map,mapnik::Image32& image, unsigned offset_x = 0, unsigned offset_y = 0) { @@ -79,6 +83,8 @@ void render2(const mapnik::Map& map,mapnik::Image32& image) ren.apply(); } +#ifdef HAVE_PYCAIRO + void render3(const mapnik::Map& map,PycairoSurface* surface, unsigned offset_x = 0, unsigned offset_y = 0) { Cairo::RefPtr s(new Cairo::Surface(surface->surface)); @@ -93,6 +99,8 @@ void render4(const mapnik::Map& map,PycairoSurface* surface) ren.apply(); } +#endif + void render_tile_to_file(const mapnik::Map& map, unsigned offset_x, unsigned offset_y, unsigned width, unsigned height, @@ -176,8 +184,10 @@ BOOST_PYTHON_MODULE(_mapnik) def("render_tile_to_file",&render_tile_to_file); def("render",&render); def("render",&render2); +#ifdef HAVE_PYCAIRO def("render",&render3); def("render",&render4); +#endif def("scale_denominator", &scale_denominator); def("load_map", & load_map, load_map_overloads()); diff --git a/bindings/python/python_cairo.cpp b/bindings/python/python_cairo.cpp index d6e73a37b..bb5365852 100644 --- a/bindings/python/python_cairo.cpp +++ b/bindings/python/python_cairo.cpp @@ -21,6 +21,8 @@ *****************************************************************************/ //$Id$ +#ifdef HAVE_PYCAIRO + #include #include @@ -46,3 +48,11 @@ void register_cairo() boost::python::converter::registry::insert(&extract_surface, boost::python::type_id()); } + +#else + +void register_cairo() +{ +} + +#endif diff --git a/src/SConscript b/src/SConscript index a364a6603..b2bb4926e 100644 --- a/src/SConscript +++ b/src/SConscript @@ -43,7 +43,6 @@ else: # Linux and others source = Split( """ agg_renderer.cpp - cairo_renderer.cpp datasource_cache.cpp envelope.cpp filter_factory.cpp @@ -79,7 +78,11 @@ source = Split( """ ) -#source.append("cairo_renderer.cpp") +if 'cairo' in env['LIBS']: + source += Split( + """ + cairo_renderer.cpp + """) if env['XMLPARSER'] == 'tinyxml': source += Split(