diff --git a/CMakeLists.txt b/CMakeLists.txt index d72d54d6de..ca9ca67476 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -182,6 +182,9 @@ if( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" ) 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" ) + # Allows .dylib relocation in the future + set( CMAKE_LD_FLAGS "${CMAKE_LD_FLAGS} -headerpad_max_install_names") + if( NOT CMAKE_CXX_COMPILER ) EXEC_PROGRAM( wx-config ARGS --cc OUTPUT_VARIABLE CMAKE_C_COMPILER ) endif( NOT CMAKE_CXX_COMPILER ) @@ -332,6 +335,11 @@ if ( KICAD_BUILD_STATIC OR KICAD_BUILD_DYNAMIC ) set( CAIRO_INCLUDE_DIR "${CAIRO_ROOT}/include/cairo") set( CAIRO_LIBRARY "${CAIRO_ROOT}/lib/libcairo.a") + if( KICAD_BUILD_DYNAMIC AND APPLE ) + add_custom_target( osx_fix_bundles ALL DEPENDS cvpcb eeschema gerbview kicad pcbnew bitmap2component pcb_calculator pl_editor) + add_custom_command(TARGET osx_fix_bundles POST_BUILD COMMAND scripts/osx_fixbundle.sh COMMENT "Migrating dylibs to bundles") + endif() + endif( KICAD_BUILD_STATIC OR KICAD_BUILD_DYNAMIC) @@ -525,8 +533,13 @@ add_dependencies( pcad2kicadpcb lib-dependencies ) add_dependencies( polygon lib-dependencies ) add_dependencies( pl_editor lib-dependencies ) add_dependencies( pnsrouter lib-dependencies ) + if ( BUILD_GITHUB_PLUGIN ) + add_dependencies( github_plugin lib-dependencies ) + endif() endif() +if ( KICAD_BUILD_DYNAMIC ) +endif() ############# # Resources # diff --git a/CMakeModules/download_cairo.cmake b/CMakeModules/download_cairo.cmake index b2b2eaea53..51d136750b 100644 --- a/CMakeModules/download_cairo.cmake +++ b/CMakeModules/download_cairo.cmake @@ -81,6 +81,7 @@ ExternalProject_Add( cairo BUILD_IN_SOURCE 1 #SOURCE_DIR "${PREFIX}" #PATCH_COMMAND "" + UPDATE_COMMAND ${CMAKE_COMMAND} -E remove_directory "${CAIRO_ROOT}" CONFIGURE_COMMAND ./configure --prefix=${CAIRO_ROOT} --enable-static ${CAIRO_BUILDTYPE} PKG_CONFIG=${PROJECT_SOURCE_DIR}/pkgconfig_root/bin/pkg-config diff --git a/CMakeModules/download_glew.cmake b/CMakeModules/download_glew.cmake index 47277fa270..74e28a98f3 100644 --- a/CMakeModules/download_glew.cmake +++ b/CMakeModules/download_glew.cmake @@ -60,6 +60,8 @@ ExternalProject_Add( glew #SOURCE_DIR "${PREFIX}" BUILD_IN_SOURCE 1 + UPDATE_COMMAND ${CMAKE_COMMAND} -E remove_directory "${GLEW_ROOT}" + #PATCH_COMMAND "true" CONFIGURE_COMMAND "" @@ -68,5 +70,18 @@ ExternalProject_Add( glew BUILD_COMMAND $(MAKE) ${GLEW_CFLAGS} ${GLEW_LDFLAGS} ${GLEW_STRIP} INSTALL_DIR "${GLEW_ROOT}" - INSTALL_COMMAND $(MAKE) GLEW_DEST="${GLEW_ROOT}" install && ranlib "${GLEW_ROOT}/lib/libGLEW.a" + INSTALL_COMMAND $(MAKE) GLEW_DEST="${GLEW_ROOT}" install ) + +# +# Optional Steps +# + +if( APPLE ) +# On OSX is needed to run ranlib to make .a indexes for all platforms +ExternalProject_Add_Step( glew glew_osx_ranlib + COMMAND ranlib "${GLEW_ROOT}/lib/libGLEW.a" + COMMENT "ranlib ${GLEW_ROOT}/lib/libGLEW.a - Needed on OSX only" + DEPENDEES install + ) +endif() diff --git a/CMakeModules/download_libpng.cmake b/CMakeModules/download_libpng.cmake index c878770cd6..35de835049 100644 --- a/CMakeModules/download_libpng.cmake +++ b/CMakeModules/download_libpng.cmake @@ -67,6 +67,7 @@ ExternalProject_Add( libpng #PATCH_COMMAND "true" CONFIGURE_COMMAND ./configure --prefix=${LIBPNG_ROOT} ${LIBPNG_OPTS} ${LIBPNG_CFLAGS} --disable-dependency-tracking #BINARY_DIR "${PREFIX}" + UPDATE_COMMAND ${CMAKE_COMMAND} -E remove_directory "${LIBPNG_ROOT}" BUILD_COMMAND $(MAKE) diff --git a/CMakeModules/download_pixman.cmake b/CMakeModules/download_pixman.cmake index 846fa76775..a925d1bf1a 100644 --- a/CMakeModules/download_pixman.cmake +++ b/CMakeModules/download_pixman.cmake @@ -68,6 +68,8 @@ ExternalProject_Add( pixman #SOURCE_DIR "${PREFIX}" BUILD_IN_SOURCE 1 + UPDATE_COMMAND ${CMAKE_COMMAND} -E remove_directory "${PIXMAN_ROOT}" + #PATCH_COMMAND "true" CONFIGURE_COMMAND ./configure --prefix=${PIXMAN_ROOT} ${PIXMAN_OPTS} ${PIXMAN_CPPFLAGS} --disable-dependency-tracking #BINARY_DIR "${PREFIX}" diff --git a/CMakeModules/download_pkgconfig.cmake b/CMakeModules/download_pkgconfig.cmake index 25b35671ee..1960af317a 100644 --- a/CMakeModules/download_pkgconfig.cmake +++ b/CMakeModules/download_pkgconfig.cmake @@ -62,19 +62,17 @@ ExternalProject_Add( pkgconfig CONFIGURE_COMMAND ./configure --prefix=${PKGCONFIG_ROOT} --with-internal-glib ${PKGCONFIG_BUILDTYPE} --disable-silent-rules #BINARY_DIR "${PREFIX}" + UPDATE_COMMAND ${CMAKE_COMMAND} -E remove_directory "${PKGCONFIG_ROOT}" + BUILD_COMMAND $(MAKE) INSTALL_DIR "${PKGCONFIG_ROOT}" INSTALL_COMMAND $(MAKE) install ) -# -# At second execution make install will fail .. -# - -ExternalProject_Add_Step( pkgconfig pkgconfig_erase_dir - COMMAND rm -fr ${PKGCONFIG_ROOT} - COMMENT "*** Erasing pkgconfig directory" +ExternalProject_Add_Step( pkgconfig pkgconfig_cleanup + COMMAND ${CMAKE_COMMAND} -E remove_directory "${PKGCONFIG_ROOT}" + COMMENT "pkgconfig - cleanup destination before proceeding in install" DEPENDEES build ) diff --git a/CMakeModules/download_wxwidgets.cmake b/CMakeModules/download_wxwidgets.cmake index 1c19bd16b4..693d490df3 100644 --- a/CMakeModules/download_wxwidgets.cmake +++ b/CMakeModules/download_wxwidgets.cmake @@ -62,9 +62,11 @@ ExternalProject_Add( libwx BUILD_IN_SOURCE 1 - # wxOverlay PATCH for OSX - http://trac.wxwidgets.org/ticket/12894 - PATCH_COMMAND bzr patch -p0 "${PROJECT_SOURCE_DIR}/patches/wxwidgets-3.0.0_macosx.patch" + PATCH_COMMAND bzr revert + COMMAND bzr patch -p0 "${PROJECT_SOURCE_DIR}/patches/wxwidgets-3.0.0_macosx.patch" + COMMAND bzr patch -p0 "${PROJECT_SOURCE_DIR}/patches/wxwidgets-3.0.0_macosx_bug_15908.patch" + UPDATE_COMMAND ${CMAKE_COMMAND} -E remove_directory "${LIBWX_ROOT}" CONFIGURE_COMMAND ./configure --prefix=${LIBWX_ROOT} -with-opengl --enable-aui --enable-debug_info -with-expat=builtin --with-regex=builtin --enable-utf8 ${LIBWX_ARCHITECTURES} ${LIBWX_BUILDTYPE} #BINARY_DIR "${PREFIX}" diff --git a/patches/wxwidgets-3.0.0_macosx_bug_15908.patch b/patches/wxwidgets-3.0.0_macosx_bug_15908.patch new file mode 100644 index 0000000000..9fdbd5f12e --- /dev/null +++ b/patches/wxwidgets-3.0.0_macosx_bug_15908.patch @@ -0,0 +1,14 @@ +=== modified file 'src/common/translation.cpp' +--- src/common/translation.cpp 2014-01-26 13:59:40 +0000 ++++ src/common/translation.cpp 2014-01-26 15:18:47 +0000 +@@ -1611,6 +1611,9 @@ + /* static */ + const wxString& wxTranslations::GetUntranslatedString(const wxString& str) + { ++ // Marco Serantoni - Dirty Patch ++ // Awaiting for http://trac.wxwidgets.org/ticket/15908 ++ if( gs_translationsOwned == false) return str; + wxLocaleUntranslatedStrings& strings = wxThreadInfo.untranslatedStrings; + + wxLocaleUntranslatedStrings::iterator i = strings.find(str); + diff --git a/scripts/osx_fixbundle.sh b/scripts/osx_fixbundle.sh new file mode 100755 index 0000000000..4eb7be82f1 --- /dev/null +++ b/scripts/osx_fixbundle.sh @@ -0,0 +1,46 @@ +#!/bin/bash +# usage osx_fixbundle.sh + +if [[ ! -f version.h ]]; then + echo "**" + echo "** ERROR: $0 doesn't seems to be launched from the kicad's bzr root !!!" + echo "** Go in the bzr root directory and launch: scripts/osx_fixbundle.sh" + echo "**" + exit 1 +fi + +EXECUTABLES="`find . -name '*.app'`" + + + +# +# Copies libraries under in the bundle and relocates them in the binary +# + +function fixbundle() { + exec="$1" + bzroot="$2" + execpath="$3" + + LIBRARIES="`otool -L ${execpath}${exec}.app/Contents/MacOS/${exec} | cut -d' ' -f1`" + + for library in $LIBRARIES; do + + mkdir -p ${execpath}${exec}.app/Contents/Frameworks + if [[ "$library" =~ "$2" ]]; then + echo "${exec}: Migrating `basename $library` in the bundle" + cp -f $library ${execpath}${exec}.app/Contents/Frameworks + install_name_tool -change $library @executable_path/../Frameworks/`basename $library` ${execpath}${exec}.app/Contents/MacOS/${exec} + fi + done +} + + +#fixbundle $1 $2 $3 + +for executable in $EXECUTABLES; +do + myexecpath="`dirname ${executable}`/" + myexec="`basename ${executable}|sed -e 's/\.app//'`" + fixbundle "${myexec}" "`pwd`" "${myexecpath}" +done