link_GraphicsMagick.xcpjh


//////////////////// GraphicsMagick //////////////////////
/*
GraphicsMagick provides a comprehensive collection of utilities, programming interfaces, and GUIs, 
to support file format conversion, image processing, and 2D vector rendering.

GraphicsMagick is distributed under an X11-style license (MIT License).  That means it can be used 
to develop commerical software with almost no restrictions.

Instructions to build the libraries 
-----------------------------------

This was done with VS2013 (i.e. vc12) and version 1.3.19 of GraphicsMagick.

1.  Download GraphicsMagick from source forge and unzip under "$(PATH_TO_ROOT)/ThirdParty.Ceda/GraphicsMagick"

2.  Run VisualMagick/configure/configure.exe

3.  In Target Setup window select
        -   Static Multi-threaded DLL runtimes
        -   Generate Visual Studio 7 format
    (this build static libraries which link against DLL versions of the CRT)

    Click on "Edit magick_config.h

    Comment out the line:
    
        #define ProvideDllMain  

4.  Keep defaults for intermediate files and output files

5.  Launch VisualMagick/VisualStaticMTDLL.sln

6.  Run Configuration Manager in Visual Studio
    Under "Active solution platforms" select New...
    Select x64, copied from x86

7.  Select all 'CORE_xxx" library projects

    Right click properties...
        Set Configuration to "All Configurations"
        Set Platform to "All Platforms"

    Set the following:
        Output Directory                    $(SolutionDir)_Output\$(SolutionName)\vc$(PlatformToolsetVersion)\$(Platform)\
        Intermediate Directory              $(SolutionDir)_Intermediate\$(SolutionName)\vc$(PlatformToolsetVersion)\$(Platform)\$(Configuration)\$(ProjectName)\
        Target Name                         $(ProjectName)_vc$(PlatformToolsetVersion)_$(Platform)_$(Configuration)
        Platform Toolset                    Visual Studio 2013 - Windows XP (v120_xp)
        Precompiled Header Output File      $(IntDir)$(TargetName).pch
        Program Database File Name          $(OutDir)$(TargetName).pdb
        Output File                         $(OutDir)$(TargetName)$(TargetExt)

        Under C/C++ Output Files set   Program Database File Name = $(OutDir)$(Configuration)_$(TargetName)

8.  Repeat steps 1-7 to create VisualMagick/VisualStaticMT.sln 
    (except in step 3 select option for static libraries which link against static versions of the CRT)

9.  Copy $/Ceda/_BUILD/Init/ceda_build_graphicsmagick.bat into the VisualMagick folder

10. Run cmd with current directory set to the VisualMagick folder 
    Run ceda_build_graphicsmagick.bat

    This avoids the need to do this (for VisualStaticMTDLL.sln, and then similarly for VisualStaticMT.sln):

        -   Select Win32 platform
            -   Select Debug
            -   Clean solution
            -   Build solution
            -   Select Release
            -   Clean solution
            -   Build solution
            -   copy files in VisualMagick/lib folder to $(GRAPHICSMAGICK)/vc11_static_lib32_crtdll
        -   Select x64 platform
            -   Select Debug
            -   Clean solution
            -   Build solution
            -   Select Release
            -   Clean solution
            -   Build solution
            -   copy files in VisualMagick/lib folder to $(GRAPHICSMAGICK)/vc11_static_lib64_crtdll

11.  Comment out the following annoying #pragma messages

    magick\common.h:
        #pragma message("Magick lib static interface")
        #pragma message("Magick module static interface)

    Magick++\lib\Magick++\Include.h:
        #pragma message("Magick++ lib static interface)

todo:
    It would be nice to remove this junk from the output:

        CORE_DB_coders_.lib(msl.obj) : warning LNK4049: locally defined symbol xmlMalloc imported
        CORE_DB_coders_.lib(svg.obj) : warning LNK4049: locally defined symbol xmlMalloc imported
        CORE_DB_coders_.lib(msl.obj) : warning LNK4049: locally defined symbol xmlFree imported
        CORE_DB_coders_.lib(svg.obj) : warning LNK4049: locally defined symbol xmlFree imported
        CORE_DB_coders_.lib(url.obj) : warning LNK4049: locally defined symbol xmlFree imported

    It seems that the culprit is in this file:  libxml\include\libxml\globals.h

        XMLPUBVAR xmlMallocFunc xmlMalloc;
*/

@if (IsGccBasedCompiler)
{
    $GRAPHICSMAGICK_VERSION = "1.3.23"

    +cpp
    {
        -DCEDA_USING_GRAPHICSMAGICK
        -I/usr/local/include/GraphicsMagick
    }
    +link
    {
        /*
        The following libraries are installed in /usr/local/lib/GraphicsMagick-1.3.23

        libGraphicsMagick.a
        libGraphicsMagick++.a
        libGraphicsMagick.la
        libGraphicsMagick++.la
        libGraphicsMagickWand.a
        libGraphicsMagickWand.la
        */
        //-lGraphicsMagick++
    }
}

@if (IsWindowsPlatform)
{    
    $GRAPHICSMAGICK_VERSION = "1.3.19"
    $GRAPHICSMAGICK = "$(PATH_TO_ROOT)/ThirdParty.Ceda/GraphicsMagick/GraphicsMagick-$(GRAPHICSMAGICK_VERSION)"

    +cpp
    {
        /I "$(GRAPHICSMAGICK)"
        /I "$(GRAPHICSMAGICK)/Magick++/lib"
        /D "CEDA_USING_GRAPHICSMAGICK"
        /D "_VISUALC_"
        /D "_LIB"
    }

    $CompilerPrefix = "$(COMPILER)0"
    $GraphicsMagickSolutionName = @if(UseStaticCRT){"VisualStaticMT"}@else{"VisualStaticMTDLL"}

    @def gm_lib_names = ["Magick++","bzlib","coders","filters","jbig","jp2","jpeg","lcms","libxml","magick","png","tiff","ttf","wand","wmf","xlib","zlib"]

    +link
    {
        /LIBPATH:"$(GRAPHICSMAGICK)/VisualMagick/_Output/$(GraphicsMagickSolutionName)/$(CompilerPrefix)/$(Platform)"

        @for (name in gm_lib_names)
        {
            @str(@("CORE_" + name + "_$(CompilerPrefix)_$(Platform)_$(Configuration).lib"))

        }

        "winmm.lib"
        "wsock32.lib"
    }
}

@if (IsMacOSXPlatform)
{
    +cpp
    {
        // assumes ImageMagick is installed using brew install imagemagick
        -I"/usr/local/include/GraphicsMagick"
    }
    +link
    {
        -L"/usr/local/lib"
        -l"GraphicsMagick++"
    }
}