cppfw / svgren

:camera: SVG rendering library in C++
MIT License
206 stars 41 forks source link

CMake support #43

Open gdorion opened 6 years ago

gdorion commented 6 years ago

Hi,

Would you, by any chance, have a CMake script to build your library? Or planned to make one eventually?

Thanks!

igagis commented 6 years ago

Hi! I don't use CMake and I'm not really familiar with it, so I can't create CMake scripts. But I accept patches ;)

JaimeIvanCervantes commented 6 years ago

Hello @gdorion, I use CMake to compile svgren on my Mac, here are the contents of my CMakeLists.txt file:

cmake_minimum_required(VERSION 3.6)
project(code)

include_directories(./
    ./svgren/
        ./svgdom/
        ./svgdom/elements/
        ./utki/
        ./papki/
    /usr/local/Cellar/cairo/1.14.10/include
    /usr/local/Cellar/cairo/1.14.10/include/cairo)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -lcairo")

# Papki code
set(PAPKI_SOURCES
        papki/BufferFile.cpp
        papki/FSFile.cpp
        papki/File.cpp
        papki/MemoryFile.cpp)

# Mikroxml sources
set(MIKROXML_SOURCES
        mikroxml/mikroxml.cpp)

# Unikod source files
set(UNIKOD_SOURCES
        unikod/utf8.cpp)

# Svgren files
set(SVGREN_SOURCES
        svgren/render.cpp
    svgren/Renderer.cpp
    svgren/util.cpp
    svgren/FilterApplyer.cpp
    svgren/Surface.cpp
    svgren/CanvasRegion.cpp)

# Svgdom source files
set(SVGDOM_SOURCES
        svgdom/Length.cpp
        svgdom/Parser.cpp
        svgdom/StreamWriter.cpp
        svgdom/Visitor.cpp
        svgdom/dom.cpp
        svgdom/util.cpp
        svgdom/Finder.cpp
        svgdom/StyleStack.cpp
    svgdom/Cloner.cpp
        svgdom/elements/AspectRatioed.cpp
        svgdom/elements/ImageElement.cpp
        svgdom/elements/Element.cpp
        svgdom/elements/Gradients.cpp
        svgdom/elements/Rectangle.cpp
        svgdom/elements/Referencing.cpp
        svgdom/elements/Shapes.cpp
        svgdom/elements/Structurals.cpp
        svgdom/elements/Styleable.cpp
        svgdom/elements/Transformable.cpp
        svgdom/elements/ViewBoxed.cpp
        svgdom/elements/Filter.cpp)

# My main source file
set(MAIN_SOURCES
        main.cpp)

add_executable(code
        ${PAPKI_SOURCES}
        ${MIKROXML_SOURCES}
    ${UNIKOD_SOURCES}
    ${SVGREN_SOURCES}
        ${SVGDOM_SOURCES}
        ${MAIN_SOURCES})

As you can see, the only real dependency is cairo, all the other dependencies (utki, papki, mikroxml, unikod, and of course svgdom) are found on @igagis github repositories. I use this file only for debugging/testing, and have something more complicated for production, but you can easily adapt this to your requirements.

igagis commented 3 years ago

Just FYI, svgren is now available as conan package for linux and macos, this might be easier to use along with CMake.