diff --git a/CMakeLists.txt b/CMakeLists.txt index e76edb90f0..d59b96a4dd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -226,8 +226,8 @@ if( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" ) if( APPLE ) - set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__ASSERTMACROS__ -mmacosx-version-min=10.5" ) - set( CMAKE_CXX_FLAGS "${CMAKE_CXX_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__" ) # Allows .dylib relocation in the future - needed by fixbundle 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 ) 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( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" ) diff --git a/CMakeModules/download_boost.cmake b/CMakeModules/download_boost.cmake index 4a0040305e..afb7320749 100644 --- a/CMakeModules/download_boost.cmake +++ b/CMakeModules/download_boost.cmake @@ -140,11 +140,8 @@ endif() if( APPLE ) - # I set this to being compatible with wxWidgets - # wxWidgets still using libstdc++ (gcc), meanwhile OSX - # 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_CXXFLAGS "cxxflags=-mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET} -fno-common" ) + set( BOOST_LINKFLAGS "linkflags=-mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET} -fno-common" ) set( BOOST_TOOLSET "toolset=darwin" ) if( CMAKE_CXX_COMPILER_ID MATCHES "Clang" ) diff --git a/Documentation/compiling/mac-osx.txt b/Documentation/compiling/mac-osx.txt index e1462a4999..c36abe4354 100644 --- a/Documentation/compiling/mac-osx.txt +++ b/Documentation/compiling/mac-osx.txt @@ -1,9 +1,9 @@ Compiling KiCad on Apple Mac OS X ================================= -Building on OSX is very similar to building on Linux. This document will provide -a complete walk-through on what to do but it will focus on OSX specific things. -See general documentation on non-OSX specific KiCad build switches, etc. +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. +See general documentation on non OS X specific KiCad build switches, etc. Prerequisites @@ -24,6 +24,7 @@ Mandatory library dependencies needed to compile KiCad: OR wxPython - A blending of the wxWidgets C++ class library with the Python programming language +* SWIG - Interface compiler (only needed for scripting/wxPython builds) Optional library dependencies, depends on used KiCad features * OpenSSL - The Open Source toolkit for SSL/TLS @@ -31,7 +32,7 @@ Optional library dependencies, depends on used KiCad features All tools (except XCode, of course) and all dependencies except wxWidgets/wxPython can be compiled manually, but it is advised to install them using your favorite -package manager for OSX like MacPorts or Homebrew. +package manager for OS X like MacPorts or Homebrew. Depending on the package manager the development packages of the library dependencies may have to be installed (usually something like -dev or -devel). @@ -44,7 +45,7 @@ automatically by KiCad build process. IMPORTANT: At the moment you *must not* use a wxWidgets/wxPython version installed by any package manager. -KiCad on OSX needs overlay support and some other fixes, which are not yet +KiCad on OS X needs overlay support and some other fixes, which are not yet contained in mainline wxWidgets/wxPython sources and builds. If you don't use a patched wxWidgets you will get graphical artifacts (something like a magnifying glass effect in the upper left corner of KiCad windows) or @@ -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 the patching/configuring/compiling of wxWidgets or wxPython for you. -Go to your working root "KiCad" and run: - # kicad/scripts/osx_build_wx.sh wx-src wx-bin kicad "-j4" +Go to your working root "KiCad" and for example run: + # 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 -target folder for compiled binaries, third parameter is the kicad folder, and -the last optional parameter are make options used during the build (in this -case for building with 4 jobs in parallel). +target folder for compiled binaries, and third parameter is the kicad folder. +The fourth parameter is the minimum OS X version you are building for (see the +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. NOTE: All paths are assumed to be relative to the current directory, i.e., the working root you are in. @@ -132,10 +135,8 @@ work: --with-zlib=builtin \ --with-expat=builtin \ --without-liblzma \ - --with-macosx-version-min=10.5 \ + --with-macosx-version-min= \ --enable-universal-binary=i386,x86_64 \ - CPPFLAGS="-stdlib=libstdc++" \ - LDFLAGS="-stdlib=libstdc++" \ CC=clang \ CXX=clang++ 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 \ -DCMAKE_C_COMPILER=clang \ -DCMAKE_CXX_COMPILER=clang++ \ + -DCMAKE_OSX_DEPLOYMENT_TARGET=10.7 \ -DwxWidgets_CONFIG_EXECUTABLE=../wx-bin/bin/wx-config \ -DKICAD_SCRIPTING=OFF \ -DKICAD_SCRIPTING_MODULES=OFF \ @@ -163,6 +165,7 @@ or, configure KiCad with scripting support: # cmake ../kicad \ -DCMAKE_C_COMPILER=clang \ -DCMAKE_CXX_COMPILER=clang++ \ + -DCMAKE_OSX_DEPLOYMENT_TARGET=10.7 \ -DwxWidgets_CONFIG_EXECUTABLE=../wx-bin/bin/wx-config \ -DPYTHON_EXECUTABLE=`which python` \ -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 `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. See Documentation/compiling/build-config.txt for a list of all CMake options available when compiling KiCad. diff --git a/scripts/osx_build_wx.sh b/scripts/osx_build_wx.sh index 0d2a48605a..e12acc4743 100644 --- a/scripts/osx_build_wx.sh +++ b/scripts/osx_build_wx.sh @@ -6,7 +6,8 @@ # $1 wxWidgets/wxPython source folder (relative to current dir) # $2 Target bin folder # $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() { echo "*** Creating/wiping build and bin folder..." @@ -59,10 +60,8 @@ wxWidgets_configure() { --with-zlib=builtin \ --with-expat=builtin \ --without-liblzma \ - --with-macosx-version-min=10.5 \ + --with-macosx-version-min=$3 \ --enable-universal-binary=i386,x86_64 \ - CPPFLAGS="-stdlib=libstdc++" \ - LDFLAGS="-stdlib=libstdc++" \ CC=clang \ CXX=clang++ if [ $? -ne 0 ]; @@ -119,16 +118,17 @@ wxPython_buildInst() { # check parameters -if [ "$#" -lt 3 ]; +if [ "$#" -lt 4 ]; then echo "OSX wxWidgets/wxPython build script" echo echo "Usage:" - echo " osx_build_wx.sh " + echo " osx_build_wx.sh [makeopts]" echo " wxWidgets/wxPython source folder" echo " Destination folder" echo " KiCad folder" - echo " Optional: make options for building wxWidgets (e.g., -j4)" + echo " OSX target (e.g., 10.7)" + echo " [makeopts] Optional: make options for building wxWidgets (e.g., -j4)" exit 1 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" # configure and build wxWidgets -wxWidgets_configure "$1" "$2" -wxWidgets_buildInst "$4" +wxWidgets_configure "$1" "$2" "$4" +wxWidgets_buildInst "$5" # check if source is wxPython if [ -d $1/wxPython ];