Commit b495ad03 authored by Bernhard Stegmaier's avatar Bernhard Stegmaier Committed by Wayne Stambaugh
Browse files

OSX build fixes.

* Make defintion of OSX build target a requirement.
* Update OSX build documenation to reflect build changes.
* Update OSX build script to reflect build changes.
parent e6ff6af7
Loading
Loading
Loading
Loading
+8 −2
Original line number Original line Diff line number Diff line
@@ -226,8 +226,8 @@ if( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )


    if( APPLE )
    if( APPLE )


        set( CMAKE_C_FLAGS   "${CMAKE_C_FLAGS} -D__ASSERTMACROS__ -mmacosx-version-min=10.5" )
        set( CMAKE_C_FLAGS   "${CMAKE_C_FLAGS} -D__ASSERTMACROS__" )
        set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__ASSERTMACROS__ -mmacosx-version-min=10.5" )
        set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__ASSERTMACROS__" )


        # Allows .dylib relocation in the future - needed by fixbundle
        # Allows .dylib relocation in the future - needed by fixbundle
        set( CMAKE_LD_FLAGS "${CMAKE_LD_FLAGS} -headerpad_max_install_names")
        set( CMAKE_LD_FLAGS "${CMAKE_LD_FLAGS} -headerpad_max_install_names")
@@ -240,6 +240,12 @@ if( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
            EXEC_PROGRAM( wx-config ARGS --cxx OUTPUT_VARIABLE CMAKE_CXX_COMPILER )
            EXEC_PROGRAM( wx-config ARGS --cxx OUTPUT_VARIABLE CMAKE_CXX_COMPILER )
        endif()
        endif()


        # There seems to be no consistent behavior when -mmacosx-min-version is
        # not specified, so force user to set minimum OSX version to build for
        if( NOT CMAKE_OSX_DEPLOYMENT_TARGET )
            message( FATAL_ERROR "Please specify target OS X version using -DCMAKE_OSX_DEPLOYMENT_TARGET=10.x" )
        endif()

    endif()
    endif()


endif( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
endif( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
+2 −5
Original line number Original line Diff line number Diff line
@@ -140,11 +140,8 @@ endif()




if( APPLE )
if( APPLE )
    # I set this to being compatible with wxWidgets
    set( BOOST_CXXFLAGS  "cxxflags=-mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET} -fno-common" )
    # wxWidgets still using libstdc++ (gcc), meanwhile OSX
    set( BOOST_LINKFLAGS "linkflags=-mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET} -fno-common" )
    # has switched to libc++ (llvm) by default
    set( BOOST_CXXFLAGS  "cxxflags=-mmacosx-version-min=10.5  -fno-common" )
    set( BOOST_LINKFLAGS "linkflags=-mmacosx-version-min=10.5 -fno-common" )
    set( BOOST_TOOLSET   "toolset=darwin" )
    set( BOOST_TOOLSET   "toolset=darwin" )


    if( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
    if( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
+28 −13
Original line number Original line Diff line number Diff line
@@ -3,7 +3,7 @@ Compiling KiCad on Apple Mac OS X


Building on OS X is very similar to building on Linux. This document will provide
Building on OS X is very similar to building on Linux. This document will provide
a complete walk-through on what to do but it will focus on OS X specific things.
a complete walk-through on what to do but it will focus on OS X specific things.
See general documentation on non-OSX specific KiCad build switches, etc.
See general documentation on non OS X specific KiCad build switches, etc.




Prerequisites
Prerequisites
@@ -24,6 +24,7 @@ Mandatory library dependencies needed to compile KiCad:
   OR
   OR
  wxPython  - A blending of the wxWidgets C++ class library with the Python
  wxPython  - A blending of the wxWidgets C++ class library with the Python
              programming language
              programming language
* SWIG      - Interface compiler (only needed for scripting/wxPython builds)


Optional library dependencies, depends on used KiCad features
Optional library dependencies, depends on used KiCad features
* OpenSSL - The Open Source toolkit for SSL/TLS
* OpenSSL - The Open Source toolkit for SSL/TLS
@@ -92,13 +93,15 @@ It is recommended to use the latest stable version. As of this writing this is


There is a little helper script osx_build_wx.sh in kicad/scripts that does all
There is a little helper script osx_build_wx.sh in kicad/scripts that does all
the patching/configuring/compiling of wxWidgets or wxPython for you.
the patching/configuring/compiling of wxWidgets or wxPython for you.
Go to your working root "KiCad" and run:
Go to your working root "KiCad" and for example run:
  # kicad/scripts/osx_build_wx.sh wx-src wx-bin kicad "-j4"
  # kicad/scripts/osx_build_wx.sh wx-src wx-bin kicad 10.7 "-j4"


First parameter is the source folder of wxWidgets/wxPython, second parameter the
First parameter is the source folder of wxWidgets/wxPython, second parameter the
target folder for compiled binaries, third parameter is the kicad folder, and
target folder for compiled binaries, and third parameter is the kicad folder.
the last optional parameter are make options used during the build (in this
The fourth parameter is the minimum OS X version you are building for (see the
case for building with 4 jobs in parallel).
section about compiling KiCad for further notes on minimum OS X version).
The last parameter is optional and contains make options used during the build
(in this example for building with 4 jobs in parallel).
The script will automatically detect if you are compiling wxWidgets or wxPython.
The script will automatically detect if you are compiling wxWidgets or wxPython.
NOTE: All paths are assumed to be relative to the current directory, i.e., the
NOTE: All paths are assumed to be relative to the current directory, i.e., the
working root you are in.
working root you are in.
@@ -132,10 +135,8 @@ work:
      --with-zlib=builtin \
      --with-zlib=builtin \
      --with-expat=builtin \
      --with-expat=builtin \
      --without-liblzma \
      --without-liblzma \
      --with-macosx-version-min=10.5 \
      --with-macosx-version-min=<osxtarget> \
      --enable-universal-binary=i386,x86_64 \
      --enable-universal-binary=i386,x86_64 \
      CPPFLAGS="-stdlib=libstdc++" \
      LDFLAGS="-stdlib=libstdc++" \
      CC=clang \
      CC=clang \
      CXX=clang++
      CXX=clang++
If you know what you are doing, you can of course use different settings.
If you know what you are doing, you can of course use different settings.
@@ -152,6 +153,7 @@ Now, configure KiCad without scripting support:
  # cmake ../kicad \
  # cmake ../kicad \
      -DCMAKE_C_COMPILER=clang \
      -DCMAKE_C_COMPILER=clang \
      -DCMAKE_CXX_COMPILER=clang++ \
      -DCMAKE_CXX_COMPILER=clang++ \
      -DCMAKE_OSX_DEPLOYMENT_TARGET=10.7 \
      -DwxWidgets_CONFIG_EXECUTABLE=../wx-bin/bin/wx-config \
      -DwxWidgets_CONFIG_EXECUTABLE=../wx-bin/bin/wx-config \
      -DKICAD_SCRIPTING=OFF \
      -DKICAD_SCRIPTING=OFF \
      -DKICAD_SCRIPTING_MODULES=OFF \
      -DKICAD_SCRIPTING_MODULES=OFF \
@@ -163,6 +165,7 @@ or, configure KiCad with scripting support:
  # cmake ../kicad \
  # cmake ../kicad \
      -DCMAKE_C_COMPILER=clang \
      -DCMAKE_C_COMPILER=clang \
      -DCMAKE_CXX_COMPILER=clang++ \
      -DCMAKE_CXX_COMPILER=clang++ \
      -DCMAKE_OSX_DEPLOYMENT_TARGET=10.7 \
      -DwxWidgets_CONFIG_EXECUTABLE=../wx-bin/bin/wx-config \
      -DwxWidgets_CONFIG_EXECUTABLE=../wx-bin/bin/wx-config \
      -DPYTHON_EXECUTABLE=`which python` \
      -DPYTHON_EXECUTABLE=`which python` \
      -DPYTHON_SITE_PACKAGE_PATH=`pwd`/../wx-bin/lib/python2.7/site-packages \
      -DPYTHON_SITE_PACKAGE_PATH=`pwd`/../wx-bin/lib/python2.7/site-packages \
@@ -177,6 +180,18 @@ been generated when compiling/installing wxPython. If you want to use a specific
python, you can also specify it via "-DPYTHON_EXECUTABLE" instead of using
python, you can also specify it via "-DPYTHON_EXECUTABLE" instead of using
`which python` (this one will just detect/use you default python).
`which python` (this one will just detect/use you default python).


The parameter "-DCMAKE_OSX_DEPLOYMENT_TARGET=10.x" is mandatory, you have to
specify the (minimum) OS X version you intend to build for. It is important that
at least wxWidgets/wxPython and KiCad (and boost, if you use an external build)
are built using the same or compatible settings. If not, you might get linker
errors, because this parameter influences which standard C++ library is being
used (libstdc++ vs. libc++).
If you don't know what to use and you are only building for your machine, just
set it to your current OS X version (e.g., MacPorts always builds this way).
Binaries built with a target OS X version <10.7 are known to show strange
behavior in some situations on recent systems (maybe because libc++ is standard
on everything >= 10.7 and problems arise due to mixing libstdc++/libc++).

Now KiCad is configured using default features/build-switches.
Now KiCad is configured using default features/build-switches.
See Documentation/compiling/build-config.txt for a list of all CMake options
See Documentation/compiling/build-config.txt for a list of all CMake options
available when compiling KiCad.
available when compiling KiCad.
+9 −9
Original line number Original line Diff line number Diff line
@@ -6,7 +6,8 @@
#   $1  wxWidgets/wxPython source folder (relative to current dir)
#   $1  wxWidgets/wxPython source folder (relative to current dir)
#   $2  Target bin folder
#   $2  Target bin folder
#   $3  KiCad source folder (relative to current dir)
#   $3  KiCad source folder (relative to current dir)
#   $4  Make options (e.g., "-j4")
#   $4  OSX target version (e.g., "10.8")
#   $5  Extra make options (e.g., "-j4")


createPaths() {
createPaths() {
    echo "*** Creating/wiping build and bin folder..."
    echo "*** Creating/wiping build and bin folder..."
@@ -59,10 +60,8 @@ wxWidgets_configure() {
        --with-zlib=builtin \
        --with-zlib=builtin \
        --with-expat=builtin \
        --with-expat=builtin \
        --without-liblzma \
        --without-liblzma \
        --with-macosx-version-min=10.5 \
        --with-macosx-version-min=$3 \
        --enable-universal-binary=i386,x86_64 \
        --enable-universal-binary=i386,x86_64 \
        CPPFLAGS="-stdlib=libstdc++" \
        LDFLAGS="-stdlib=libstdc++" \
        CC=clang \
        CC=clang \
        CXX=clang++
        CXX=clang++
    if [ $? -ne 0 ];
    if [ $? -ne 0 ];
@@ -119,16 +118,17 @@ wxPython_buildInst() {




# check parameters
# check parameters
if [ "$#" -lt 3 ];
if [ "$#" -lt 4 ];
then
then
    echo "OSX wxWidgets/wxPython build script"
    echo "OSX wxWidgets/wxPython build script"
    echo
    echo
    echo "Usage:"
    echo "Usage:"
    echo "  osx_build_wx.sh <src> <bin> <kicad> <makeopts>"
    echo "  osx_build_wx.sh <src> <bin> <kicad> <osxtarget> [makeopts]"
    echo "    <src>       wxWidgets/wxPython source folder"
    echo "    <src>       wxWidgets/wxPython source folder"
    echo "    <bin>       Destination folder"
    echo "    <bin>       Destination folder"
    echo "    <kicad>     KiCad folder"
    echo "    <kicad>     KiCad folder"
    echo "    <makeopts>  Optional: make options for building wxWidgets (e.g., -j4)"
    echo "    <osxtarget> OSX target (e.g., 10.7)"
    echo "    [makeopts]  Optional: make options for building wxWidgets (e.g., -j4)"
    exit 1
    exit 1
fi
fi


@@ -142,8 +142,8 @@ doPatch "$1" "$3/patches/wxwidgets-3.0.0_macosx_bug_15908.patch"
doPatch "$1" "$3/patches/wxwidgets-3.0.0_macosx_soname.patch"
doPatch "$1" "$3/patches/wxwidgets-3.0.0_macosx_soname.patch"


# configure and build wxWidgets
# configure and build wxWidgets
wxWidgets_configure "$1" "$2"
wxWidgets_configure "$1" "$2" "$4"
wxWidgets_buildInst "$4"
wxWidgets_buildInst "$5"


# check if source is wxPython
# check if source is wxPython
if [ -d $1/wxPython ];
if [ -d $1/wxPython ];