← Back to team overview

kicad-developers team mailing list archive

Re: [PATCH] expat dependency for cmake

 

On 15 October 2010 16:32, Wayne Stambaugh <stambaughw@xxxxxxxxxxx> wrote:
> On 10/15/2010 6:37 AM, Brian Sidebotham wrote:
>>> I already had a suspicion my patch was not complete.
>>> I was hoping to achieve that cmake does all the dependency checks and then decides if there is enough to build it or to ask for other dependencies, instead of finding out at linking-time.
>>>
>>>
>>> Probably we need to do the wxWidgets check before the expat check, right?
>>>
>>> So the patch should to the following (?):
>>> # only gl and mono can be detected
>>> find_package(wxWidgets COMPONENTS mono gl REQUIRED)
>
> Why is the wxWidgets monolithic library being used?  I can build separate
> wxWidgets libraries on Windows using both dynamic link and static libraries on
> both Mingw/MSYS and Visual Studio 2005 with no problems.  I usually use static
> because it make my life easier but I have successfully built Kicad both ways.
> If you are going use the monolithic library, use a command line switch as shown
> below.
>
> option(KICAD_USE_WX_MONO "Enable/disable building with wxWidgets monolithic
> library (default OFF)")
>
> if(KICAD_USE_WX_MONO)
>    find_package( wxWidgets COMPONENTS mono gl REQUIRED )
> else(KICAD_USE_WX_MONO)
>    find_package( wxWidgets COMPONENTS gl adv html core net base xml aui REQUIRED )
> endif(KICAD_USE_WX_MONO)
>
> Use the -DKICAD_USE_WX_MONO=ON switch when running CMake.
>
>>> if(NOT WIN32)
>>>        find_package(wxWidgets COMPONENTS gl adv html core net base xml REQUIRED)
>>> endif(NOT WIN32)
>
> There is no reason to use if(NOT WIN32) here.  I know I've said this before and
> I will say it again.  Build tools should test for features not platforms.
> Whenever you see WIN32, APPLE, POSIX, etc., try to replace it with a feature
> test solution.  See the "Recommendations for Writing Autoconf Macros" page of
> http://www.lrde.epita.fr/~adl/dl/autotools.pdf for an excellent explanation of
> why to test for features.  Unfortunately the CMake folks accept and create
> these kinds of tests.
>
> I know you thinking, how does that solve our expat library problem.  There are
> several ways to approach this problem but fortunately for us, the wxWidgets
> folks have a clue and provided a wxUSE_EXPAT definition when wxWidgets is built
> using its own internal version of expat.  You should be able to use the CMake
> CheckSymbolExists macro to check for wxUSE_EXPAT in the setup.h file for the
> version of wxWidgets that was found.  Now you know which expat library to link
> against.  Assuming that the linker paths are defined correctly, you can link to
> the correct library.  This is actually not the optimal way to do it.  On
> platforms that support wx-config, you should use it instead.  So we end up with
> something as following.
>
> find_program( wx-config, HAS_WX_CONFIG )
>
> if( NOT HAS_WX_CONFIG OR CROSS_COMPILING )
>    CheckSymbolExists( wxUSE_EXPAT path_to_correct_wx_version/setup.h
> USE_WX_EXPAT )
>    if( USE_WX_EXPAT )
>        add_library( name_of_wx_widgets_expat_library )
>    else( USE_WX_EXPAT )
>        add_library( expat )
>    endif( USE_WX_EXPAT )
> endif( NOT HAS_WX_CONFIG OR CROSS_COMPILING )

That is a neat check for wx-config. There is already a windows port in
existence, so no doubt one day it'll make it into the standard windows
wxWidgets build. It's so much better than having to use a big list of
libraries in the link command.

Best Regards,

Brian.



Follow ups

References