Commit f06bfe6d authored by Bernhard Stegmaier's avatar Bernhard Stegmaier Committed by Wayne Stambaugh

Commit the rest of the OSX build fixes missed in the previous commit.

parent 816974b8
......@@ -349,8 +349,9 @@ if( APPLE )
set( OSX_BUNDLE_MAIN "kicad.app" )
set( OSX_BUNDLE_BIN_DIR "Contents/MacOS" )
set( OSX_BUNDLE_LIB_DIR "Contents/Frameworks" )
set( OSX_BUNDLE_KIFACE_DIR "Contents/Plugins" )
set( OSX_BUNDLE_KIFACE_DIR "Contents/PlugIns" )
set( OSX_BUNDLE_SUP_DIR "Contents/SharedSupport" )
set( OSX_BUNDLE_APP_DIR "Contents/Applications" )
set( OSX_BUNDLE_BUILD_DIR "${CMAKE_BINARY_DIR}/kicad/${OSX_BUNDLE_MAIN}" )
set( OSX_BUNDLE_BUILD_BIN_DIR "${OSX_BUNDLE_BUILD_DIR}/${OSX_BUNDLE_BIN_DIR}" )
set( OSX_BUNDLE_BUILD_LIB_DIR "${OSX_BUNDLE_BUILD_DIR}/${OSX_BUNDLE_LIB_DIR}" )
......@@ -377,6 +378,24 @@ if( APPLE )
# used to set DEFAULT_FP_LIB_PATH in config.h.cmake, but then never used
# set it to correct value just in case (see common.cpp)
set( KICAD_FP_LIB_INSTALL_PATH "~/Library/Preferences/kicad" )
# Override default paths for fixup_bundle
set( OSX_BUNDLE_OVERRIDE_PATHS "
function( gp_item_default_embedded_path_override item default_embedded_path_var )
# by default, embed things right next to the main bundle executable:
set( path \"@executable_path/../../Contents/MacOS\" )
set( overridden 0 )
# embed .dylibs right next to the main bundle executable:
if( item MATCHES \"\\\\.dylib$\" )
set( path \"@executable_path/../Frameworks\" )
set( overridden 1 )
endif()
set( \${default_embedded_path_var} \"\${path}\" PARENT_SCOPE )
endfunction(gp_item_default_embedded_path_override)
"
)
endif()
mark_as_advanced( KICAD_BIN
......@@ -614,7 +633,7 @@ if( KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES )
)
else()
# relative path for python in bundle
set( PYTHON_LIB_DIR "python" )
set( PYTHON_LIB_DIR "python/site-packages" )
# install into bundle Frameworks folder
set( PYTHON_DEST "${OSX_BUNDLE_BUILD_LIB_DIR}/${PYTHON_LIB_DIR}"
CACHE PATH "Python module install path."
......@@ -655,6 +674,25 @@ endif()
# 'CMakeLists.txt' files to process
#================================================
if( APPLE )
# Remove app bundles in ${KICAD_BIN} before installing anything new.
# Must be defined before all includes so that it is executed first.
install( CODE "
message( STATUS \"Removing existing application bundles...\" )
# Remove links to standalone apps
file( REMOVE ${KICAD_BIN}/bitmap2component.app )
file( REMOVE ${KICAD_BIN}/eeschema.app )
file( REMOVE ${KICAD_BIN}/cvpcb.app )
file( REMOVE ${KICAD_BIN}/gerbview.app )
file( REMOVE ${KICAD_BIN}/pcb_calculator.app )
file( REMOVE ${KICAD_BIN}/pcbnew.app )
file( REMOVE ${KICAD_BIN}/pl_editor.app )
# Remove main bundle
file( REMOVE_RECURSE ${KICAD_BIN}/${OSX_BUNDLE_MAIN} )
" COMPONENT Runtime
)
endif()
############################
# Binaries ( CMake targets ) #
############################
......
......@@ -100,6 +100,8 @@ 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).
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.
CAUTION: The script will erase existing wx-build and target folders (wx-bin)
without any confirmation!
......
......@@ -142,8 +142,11 @@ wxString FindKicadFile( const wxString& shortname )
{
// Test the presence of the file in the directory shortname of
// the KiCad binary path.
#ifndef __WXMAC__
wxString fullFileName = Pgm().GetExecutablePath() + shortname;
#else
wxString fullFileName = Pgm().GetExecutablePath() + wxT( "Contents/MacOS/" ) + shortname;
#endif
if( wxFileExists( fullFileName ) )
return fullFileName;
......@@ -157,16 +160,22 @@ wxString FindKicadFile( const wxString& shortname )
return fullFileName;
}
// find binary file from possibilities list:
// /usr/local/kicad/linux or c:/kicad/winexe
// Path list for KiCad binary files
const static wxChar* possibilities[] = {
#ifdef __WINDOWS__
#if defined( __WINDOWS__ )
wxT( "c:/kicad/bin/" ),
wxT( "d:/kicad/bin/" ),
wxT( "c:/Program Files/kicad/bin/" ),
wxT( "d:/Program Files/kicad/bin/" ),
#elif defined( __WXMAC__ )
// all internal paths are relative to main bundle kicad.app
wxT( "Contents/Applications/cvpcb.app/Contents/MacOS/" ),
wxT( "Contents/Applications/pcbnew.app/Contents/MacOS/" ),
wxT( "Contents/Applications/eeschema.app/Contents/MacOS/" ),
wxT( "Contents/Applications/gerbview.app/Contents/MacOS/" ),
wxT( "Contents/Applications/bitmap2component.app/Contents/MacOS/" ),
wxT( "Contents/Applications/pcb_calculator.app/Contents/MacOS/" ),
wxT( "Contents/Applications/pl_editor.app/Contents/MacOS/" ),
#else
wxT( "/usr/bin/" ),
wxT( "/usr/local/bin/" ),
......@@ -174,9 +183,15 @@ wxString FindKicadFile( const wxString& shortname )
#endif
};
// find binary file from possibilities list:
for( unsigned i=0; i<DIM(possibilities); ++i )
{
#ifndef __WXMAC__
fullFileName = possibilities[i] + shortname;
#else
// make relative paths absolute
fullFileName = Pgm().GetExecutablePath() + possibilities[i] + shortname;
#endif
if( wxFileExists( fullFileName ) )
return fullFileName;
......@@ -189,31 +204,25 @@ wxString FindKicadFile( const wxString& shortname )
int ExecuteFile( wxWindow* frame, const wxString& ExecFile, const wxString& param,
wxProcess *callback )
{
wxString fullFileName;
fullFileName = FindKicadFile( ExecFile );
wxString fullFileName = FindKicadFile( ExecFile );
#ifdef __WXMAC__
if( wxFileExists( fullFileName ) || wxDir::Exists( fullFileName ) )
if( wxFileExists( fullFileName ) )
{
return ProcessExecute( Pgm().GetExecutablePath() + wxT( "/" )
+ ExecFile + wxT( " " )
+ param, wxEXEC_ASYNC, callback );
if( !param.IsEmpty() )
fullFileName += wxT( " " ) + param;
return ProcessExecute( fullFileName, wxEXEC_ASYNC, callback );
}
#ifdef __WXMAC__
else
{
return ProcessExecute( wxT( "/usr/bin/open " ) + param, wxEXEC_ASYNC, callback );
}
#else
if( wxFileExists( fullFileName ) )
{
if( !param.IsEmpty() )
fullFileName += wxT( " " ) + param;
return ProcessExecute( fullFileName, wxEXEC_ASYNC, callback );
return ProcessExecute( wxT( "/usr/bin/open -a " ) + fullFileName, wxEXEC_ASYNC, callback );
}
#endif
wxString msg;
msg.Printf( _( "Command <%s> could not found" ), GetChars( fullFileName ) );
DisplayError( frame, msg, 20 );
......@@ -233,6 +242,7 @@ wxString KicadDatasPath()
}
else // Path of executables.
{
#ifndef __WXMAC__
wxString tmp = Pgm().GetExecutablePath();
#ifdef __WINDOWS__
tmp.MakeLower();
......@@ -303,6 +313,11 @@ wxString KicadDatasPath()
break;
}
}
#else
// On OSX point to Contents/SharedSupport folder of main bundle
data_path = GetOSXKicadDataDir();
found = true;
#endif
}
if( found )
......
......@@ -113,11 +113,13 @@ const wxString KIWAY::dso_full_path( FACE_T aFaceId )
return wxEmptyString;
}
#ifndef __WXMAC__
wxFileName fn = wxStandardPaths::Get().GetExecutablePath();
#ifdef __WXMAC__
// we have the dso's in @executable_path/../Plugins in OSX bundle
fn.RemoveLastDir();
fn.AppendDir( wxT( "Plugins" ) );
#else
// we have the dso's in main OSX bundle kicad.app/Contents/PlugIns
wxFileName fn = Pgm().GetExecutablePath();
fn.AppendDir( wxT( "Contents" ) );
fn.AppendDir( wxT( "PlugIns" ) );
#endif
fn.SetName( name );
......
......@@ -412,38 +412,30 @@ bool PGM_BASE::initPgm()
bool PGM_BASE::setExecutablePath()
{
#ifdef __APPLE__ // Apple MacOSx
// Derive path from location of the app bundle
CFBundleRef mainBundle = CFBundleGetMainBundle();
if( mainBundle == NULL )
return false;
CFURLRef urlref = CFBundleCopyBundleURL( mainBundle );
if( urlref == NULL )
return false;
CFStringRef str = CFURLCopyFileSystemPath( urlref, kCFURLPOSIXPathStyle );
if( str == NULL )
return false;
char* native_str = NULL;
int len = CFStringGetMaximumSizeForEncoding( CFStringGetLength( str ),
kCFStringEncodingUTF8 ) + 1;
native_str = new char[len];
CFStringGetCString( str, native_str, len, kCFStringEncodingUTF8 );
m_bin_dir = FROM_UTF8( native_str );
delete[] native_str;
#else
m_bin_dir = wxStandardPaths::Get().GetExecutablePath();
#endif
#ifdef __WXMAC__
// On OSX Pgm().GetExecutablePath() will always point to main
// bundle directory, e.g., /Applications/kicad.app/
wxFileName fn( m_bin_dir );
if( fn.GetName() == wxT( "kicad" ) )
{
// kicad launcher, so just remove the Contents/MacOS part
fn.RemoveLastDir();
fn.RemoveLastDir();
}
else
{
// standalone binaries live in Contents/Applications/<standalone>.app/Contents/MacOS
fn.RemoveLastDir();
fn.RemoveLastDir();
fn.RemoveLastDir();
fn.RemoveLastDir();
fn.RemoveLastDir();
}
m_bin_dir = fn.GetPath() + wxT( "/" );
#else
// Use unix notation for paths. I am not sure this is a good idea,
// but it simplifies compatibility between Windows and Unices.
// However it is a potential problem in path handling under Windows.
......@@ -452,6 +444,7 @@ bool PGM_BASE::setExecutablePath()
// Remove file name form command line:
while( m_bin_dir.Last() != '/' && !m_bin_dir.IsEmpty() )
m_bin_dir.RemoveLast();
#endif
return true;
}
......
......@@ -111,7 +111,12 @@ const wxString PROJECT::FootprintLibTblName() const
// application title which is no longer constant or known. This next line needs
// to be re-thought out.
#ifndef __WXMAC__
fn.AssignDir( wxStandardPaths::Get().GetUserConfigDir() );
#else
// don't pollute home folder, temp folder seems to be more appropriate
fn.AssignDir( wxStandardPaths::Get().GetTempDir() );
#endif
#if defined( __WINDOWS__ )
fn.AppendDir( wxT( "kicad" ) );
......
......@@ -53,8 +53,23 @@ if( MINGW )
endif()
if( APPLE )
# setup bundle
set( CVPCB_RESOURCES cvpcb.icns cvpcb_doc.icns )
set_source_files_properties( "${CMAKE_CURRENT_SOURCE_DIR}/cvpcb.icns" PROPERTIES
MACOSX_PACKAGE_LOCATION Resources
)
set_source_files_properties( "${CMAKE_CURRENT_SOURCE_DIR}/cvpcb_doc.icns" PROPERTIES
MACOSX_PACKAGE_LOCATION Resources
)
set( MACOSX_BUNDLE_ICON_FILE cvpcb.icns )
set( MACOSX_BUNDLE_GUI_IDENTIFIER org.kicad-eda.kicad )
set( MACOSX_BUNDLE_NAME cvpcb )
endif()
if( USE_KIWAY_DLLS )
add_executable( cvpcb WIN32
add_executable( cvpcb WIN32 MACOSX_BUNDLE
../common/single_top.cpp
../common/pgm_base.cpp
${CVPCB_RESOURCES}
......@@ -141,13 +156,32 @@ if( USE_KIWAY_DLLS )
# these 2 binaries are a matched set, keep them together:
if( APPLE )
# puts binaries into the *.app bundle while linking
set_target_properties( cvpcb PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${OSX_BUNDLE_BUILD_BIN_DIR}
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist
)
# puts binaries into the *.app bundle while linking
set_target_properties( cvpcb_kiface PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${OSX_BUNDLE_BUILD_KIFACE_DIR}
)
# put individual bundle outside of main bundle as a first step
# will be pulled into the main bundle when creating main bundle
install( TARGETS cvpcb
DESTINATION ${KICAD_BIN}
COMPONENT binary
)
install( CODE "
# override default embedded path settings
${OSX_BUNDLE_OVERRIDE_PATHS}
# do all the work
include( BundleUtilities )
fixup_bundle( ${KICAD_BIN}/cvpcb.app/Contents/MacOS/cvpcb
\"\"
\"\"
)
" COMPONENT Runtime
)
else()
install( TARGETS cvpcb
DESTINATION ${KICAD_BIN}
......@@ -161,7 +195,7 @@ if( USE_KIWAY_DLLS )
else()
add_executable( cvpcb WIN32
add_executable( cvpcb WIN32 MACOSX_BUNDLE
${CVPCB_SRCS}
${CVPCB_DIALOGS}
${CVPCB_RESOURCES}
......@@ -201,15 +235,8 @@ else()
# Must follow github_plugin
target_link_libraries( cvpcb ${Boost_LIBRARIES} )
if( APPLE )
# puts binaries into the *.app bundle while linking
set_target_properties( cvpcb PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${OSX_BUNDLE_BUILD_BIN_DIR}
)
else()
install( TARGETS cvpcb
DESTINATION ${KICAD_BIN}
COMPONENT binary
)
endif()
install( TARGETS cvpcb
DESTINATION ${KICAD_BIN}
COMPONENT binary
)
endif()
......@@ -233,9 +233,23 @@ set_source_files_properties( dialogs/dialog_bom.cpp
OBJECT_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/dialog_bom_help_html.h
)
if( APPLE )
# setup bundle
set( EESCHEMA_RESOURCES eeschema.icns eeschema_doc.icns )
set_source_files_properties( "${CMAKE_CURRENT_SOURCE_DIR}/eeschema.icns" PROPERTIES
MACOSX_PACKAGE_LOCATION Resources
)
set_source_files_properties( "${CMAKE_CURRENT_SOURCE_DIR}/eeschema_doc.icns" PROPERTIES
MACOSX_PACKAGE_LOCATION Resources
)
set( MACOSX_BUNDLE_ICON_FILE eeschema.icns )
set( MACOSX_BUNDLE_GUI_IDENTIFIER org.kicad-eda.kicad )
set( MACOSX_BUNDLE_NAME eeschema )
endif()
if( USE_KIWAY_DLLS )
add_executable( eeschema WIN32
add_executable( eeschema WIN32 MACOSX_BUNDLE
../common/single_top.cpp
../common/pgm_base.cpp
${EESCHEMA_RESOURCES}
......@@ -292,13 +306,32 @@ if( USE_KIWAY_DLLS )
# these 2 binaries are a matched set, keep them together:
if( APPLE )
# puts binaries into the *.app bundle while linking
set_target_properties( eeschema PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${OSX_BUNDLE_BUILD_BIN_DIR}
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist
)
# puts binaries into the *.app bundle while linking
set_target_properties( eeschema_kiface PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${OSX_BUNDLE_BUILD_KIFACE_DIR}
)
# put individual bundle outside of main bundle as a first step
# will be pulled into the main bundle when creating main bundle
install( TARGETS eeschema
DESTINATION ${KICAD_BIN}
COMPONENT binary
)
install( CODE "
# override default embedded path settings
${OSX_BUNDLE_OVERRIDE_PATHS}
# do all the work
include( BundleUtilities )
fixup_bundle( ${KICAD_BIN}/eeschema.app/Contents/MacOS/eeschema
\"\"
\"\"
)
" COMPONENT Runtime
)
else()
install( TARGETS eeschema
DESTINATION ${KICAD_BIN}
......@@ -313,7 +346,7 @@ if( USE_KIWAY_DLLS )
endif()
else()
add_executable( eeschema WIN32
add_executable( eeschema WIN32 MACOSX_BUNDLE
../common/single_top.cpp
${EESCHEMA_SRCS}
${EESCHEMA_COMMON_SRCS}
......@@ -333,17 +366,10 @@ else()
COMPILE_DEFINITIONS "TOP_FRAME=FRAME_SCH;PGM_DATA_FILE_EXT=\"sch\";BUILD_KIWAY_DLL"
)
if( APPLE )
# puts binaries into the *.app bundle while linking
set_target_properties( eeschema PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${OSX_BUNDLE_BUILD_BIN_DIR}
)
else()
install( TARGETS eeschema
DESTINATION ${KICAD_BIN}
COMPONENT binary
)
endif()
install( TARGETS eeschema
DESTINATION ${KICAD_BIN}
COMPONENT binary
)
endif()
......
......@@ -10,13 +10,11 @@
<array>
<string>sch</string>
</array>
<key>CFBundleTypeIconFile</key> <string>eeschema.icns</string>
<key>CFBundleTypeIconFile</key> <string>eeschema_doc.icns</string>
<key>CFBundleTypeName</key> <string>eeschema document</string>
<key>LSHandlerRank</key> <string>Owner</string>
</dict>
</array>
<key>CFBundleDevelopmentRegion</key> <string>English</string>
<key>CFBundleExecutable</key> <string>eeschema</string>
<key>CFBundleGetInfoString</key> <string></string>
......
......@@ -379,7 +379,11 @@ void DIALOG_BOM::OnAddPlugin( wxCommandEvent& event )
void DIALOG_BOM::OnChoosePlugin( wxCommandEvent& event )
{
wxString mask = wxT( "*" );
#ifndef __WXMAC__
wxString path = Pgm().GetExecutablePath();
#else
wxString path = GetOSXKicadDataDir() + wxT( "/plugins" );
#endif
wxString fullFileName = EDA_FileSelector( _( "Plugin files:" ),
path,
......
......@@ -871,7 +871,11 @@ void NETLIST_DIALOG_ADD_PLUGIN::OnBrowsePlugins( wxCommandEvent& event )
wxString FullFileName, Mask, Path;
Mask = wxT( "*" );
#ifndef __WXMAC__
Path = Pgm().GetExecutablePath();
#else
Path = GetOSXKicadDataDir() + wxT( "/plugins" );
#endif
FullFileName = EDA_FileSelector( _( "Plugin files:" ),
Path,
FullFileName,
......
......@@ -79,9 +79,23 @@ if( MINGW )
mingw_resource_compiler( gerbview )
endif()
if( APPLE )
# setup bundle
set( GERBVIEW_RESOURCES gerbview.icns gerbview_doc.icns )
set_source_files_properties( "${CMAKE_CURRENT_SOURCE_DIR}/gerbview.icns" PROPERTIES
MACOSX_PACKAGE_LOCATION Resources
)
set_source_files_properties( "${CMAKE_CURRENT_SOURCE_DIR}/gerbview_doc.icns" PROPERTIES
MACOSX_PACKAGE_LOCATION Resources
)
set( MACOSX_BUNDLE_ICON_FILE gerbview.icns )
set( MACOSX_BUNDLE_GUI_IDENTIFIER org.kicad-eda.kicad )
set( MACOSX_BUNDLE_NAME gerbview )
endif()
if( USE_KIWAY_DLLS )
add_executable( gerbview WIN32
add_executable( gerbview WIN32 MACOSX_BUNDLE
../common/single_top.cpp
../common/pgm_base.cpp
${GERBVIEW_RESOURCES}
......@@ -135,13 +149,32 @@ if( USE_KIWAY_DLLS )
# these 2 binaries are a matched set, keep them together
if( APPLE )
# puts binaries into the *.app bundle while linking
set_target_properties( gerbview PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${OSX_BUNDLE_BUILD_BIN_DIR}
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist
)
# puts binaries into the *.app bundle while linking
set_target_properties( gerbview_kiface PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${OSX_BUNDLE_BUILD_KIFACE_DIR}
)
# put individual bundle outside of main bundle as a first step
# will be pulled into the main bundle when creating main bundle
install( TARGETS gerbview
DESTINATION ${KICAD_BIN}
COMPONENT binary
)
install( CODE "
# override default embedded path settings
${OSX_BUNDLE_OVERRIDE_PATHS}
# do all the work
include( BundleUtilities )
fixup_bundle( ${KICAD_BIN}/gerbview.app/Contents/MacOS/gerbview
\"\"
\"\"
)
" COMPONENT Runtime
)
else()
install( TARGETS gerbview
DESTINATION ${KICAD_BIN}
......@@ -155,7 +188,7 @@ if( USE_KIWAY_DLLS )
else()
add_executable( gerbview WIN32
add_executable( gerbview WIN32 MACOSX_BUNDLE
gerbview.cpp
${GERBVIEW_SRCS}
${DIALOGS_SRCS}
......@@ -170,16 +203,9 @@ else()
${wxWidgets_LIBRARIES}
${GDI_PLUS_LIBRARIES}
)
if( APPLE )
# puts binaries into the *.app bundle while linking
set_target_properties( gerbview PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${OSX_BUNDLE_BUILD_BIN_DIR}
)
else()
install( TARGETS gerbview
DESTINATION ${KICAD_BIN}
COMPONENT binary
)
endif()
install( TARGETS gerbview
DESTINATION ${KICAD_BIN}
COMPONENT binary
)
endif()
......@@ -89,7 +89,7 @@ if( APPLE )
set( SCRIPTING_HELPER "0" )
endif()
# make bundle relocatable
# make main bundle relocatable
install( CODE "
# find all libs and modules
file( GLOB BUNDLE_FIX_LIBS ${OSX_BUNDLE_INSTALL_KIFACE_DIR}/*.kiface )
......@@ -101,19 +101,7 @@ if( APPLE )
endif()
# override default embedded path settings
function( gp_item_default_embedded_path_override item default_embedded_path_var )
# by default, embed things right next to the main bundle executable:
set( path \"@executable_path/../../Contents/MacOS\" )
set( overridden 0 )
# embed .dylibs right next to the main bundle executable:
if( item MATCHES \"\\\\.dylib$\" )
set( path \"@executable_path/../Frameworks\" )
set( overridden 1 )
endif()
set( \${default_embedded_path_var} \"\${path}\" PARENT_SCOPE )
endfunction(gp_item_default_embedded_path_override)
${OSX_BUNDLE_OVERRIDE_PATHS}
# do all the work
include( BundleUtilities )
......@@ -123,4 +111,32 @@ if( APPLE )
)
" COMPONENT Runtime
)
# move all individual app bundles into main bundle
install( CODE "
# helper function to move a bundle into main bundle
function( move_to_main_bundle bundle_name )
message( STATUS \"Moving \${bundle_name} into main bundle...\" )
file( MAKE_DIRECTORY ${OSX_BUNDLE_INSTALL_DIR}/${OSX_BUNDLE_APP_DIR} )
file( REMOVE_RECURSE ${KICAD_BIN}/\${bundle_name}/${OSX_BUNDLE_LIB_DIR} )
file( RENAME ${KICAD_BIN}/\${bundle_name} ${OSX_BUNDLE_INSTALL_DIR}/${OSX_BUNDLE_APP_DIR}/\${bundle_name} )
execute_process( COMMAND ${CMAKE_COMMAND} -E create_symlink \"../../../Frameworks\" \"Frameworks\"
WORKING_DIRECTORY ${OSX_BUNDLE_INSTALL_DIR}/${OSX_BUNDLE_APP_DIR}/\${bundle_name}/Contents
)
# create a top-level link pointing inside main bundle
execute_process( COMMAND ${CMAKE_COMMAND} -E create_symlink \"${OSX_BUNDLE_MAIN}/${OSX_BUNDLE_APP_DIR}/\${bundle_name}\" \"\${bundle_name}\"
WORKING_DIRECTORY ${KICAD_BIN}
)
endfunction( move_to_main_bundle )
# move all app bundles
move_to_main_bundle( bitmap2component.app )
move_to_main_bundle( eeschema.app )
move_to_main_bundle( cvpcb.app )
move_to_main_bundle( gerbview.app )
move_to_main_bundle( pcb_calculator.app )
move_to_main_bundle( pcbnew.app )
move_to_main_bundle( pl_editor.app )
" COMPONENT Runtime
)
endif()
......@@ -41,6 +41,7 @@
#include <vector>
#include <build_version.h>
#include <macros.h>
#include <common.h>
#include <wx/dir.h>
#include <wx/filename.h>
......@@ -74,6 +75,7 @@ void KICAD_MANAGER_FRAME::CreateNewProject( const wxString& aPrjFullFileName,
wxFileName templatePath;
wxString envStr;
#ifndef __WXMAC__
wxGetEnv( wxT( "KICAD" ), &envStr );
// Add a new tab for system templates
......@@ -101,6 +103,10 @@ void KICAD_MANAGER_FRAME::CreateNewProject( const wxString& aPrjFullFileName,
sep + wxT( ".." ) + sep + wxT( "share" ) + sep + wxT( "template" ) + sep;
}
}
#else
// Use what is provided in the bundle data dir
templatePath = GetOSXKicadDataDir() + sep + wxT( "template" );
#endif
ps->AddPage( _( "System Templates" ), templatePath );
......
......@@ -53,10 +53,25 @@ if( MINGW )
endif()
if( APPLE )
# setup bundle
set( PL_EDITOR_RESOURCES pl_editor.icns pl_editor_doc.icns )
set_source_files_properties( "${CMAKE_CURRENT_SOURCE_DIR}/pl_editor.icns" PROPERTIES
MACOSX_PACKAGE_LOCATION Resources
)
set_source_files_properties( "${CMAKE_CURRENT_SOURCE_DIR}/pl_editor_doc.icns" PROPERTIES
MACOSX_PACKAGE_LOCATION Resources
)
set( MACOSX_BUNDLE_ICON_FILE pl_editor.icns )
set( MACOSX_BUNDLE_GUI_IDENTIFIER org.kicad-eda.kicad )
set( MACOSX_BUNDLE_NAME pl_editor )
endif()
if( USE_KIWAY_DLLS )
# a very small program launcher for pl_editor_kiface
add_executable( pl_editor WIN32
add_executable( pl_editor WIN32 MACOSX_BUNDLE
../common/single_top.cpp
../common/pgm_base.cpp
${PL_EDITOR_RESOURCES}
......@@ -110,13 +125,32 @@ if( USE_KIWAY_DLLS )
# these 2 binaries are a matched set, keep them together:
if( APPLE )
# puts binaries into the *.app bundle while linking
set_target_properties( pl_editor PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${OSX_BUNDLE_BUILD_BIN_DIR}
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist
)
# puts binaries into the *.app bundle while linking
set_target_properties( pl_editor_kiface PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${OSX_BUNDLE_BUILD_KIFACE_DIR}
)
# put individual bundle outside of main bundle as a first step
# will be pulled into the main bundle when creating main bundle
install( TARGETS pl_editor
DESTINATION ${KICAD_BIN}
COMPONENT binary
)
install( CODE "
# override default embedded path settings
${OSX_BUNDLE_OVERRIDE_PATHS}
# do all the work
include( BundleUtilities )
fixup_bundle( ${KICAD_BIN}/pl_editor.app/Contents/MacOS/pl_editor
\"\"
\"\"
)
" COMPONENT Runtime
)
else()
install( TARGETS pl_editor
DESTINATION ${KICAD_BIN}
......@@ -130,7 +164,7 @@ if( USE_KIWAY_DLLS )
else()
add_executable( pl_editor WIN32
add_executable( pl_editor WIN32 MACOSX_BUNDLE
pl_editor.cpp
${PL_EDITOR_SRCS}
${DIALOGS_SRCS}
......@@ -145,15 +179,9 @@ else()
${wxWidgets_LIBRARIES}
${GDI_PLUS_LIBRARIES}
)
if( APPLE )
# puts binaries into the *.app bundle while linking
set_target_properties( pl_editor PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${OSX_BUNDLE_BUILD_BIN_DIR}
)
else()
install( TARGETS pl_editor
DESTINATION ${KICAD_BIN}
COMPONENT binary
)
endif()
install( TARGETS pl_editor
DESTINATION ${KICAD_BIN}
COMPONENT binary
)
endif()
......@@ -10,13 +10,11 @@
<array>
<string>kicad_wks</string>
</array>
<key>CFBundleTypeIconFile</key> <string>pl_editor.icns</string>
<key>CFBundleTypeIconFile</key> <string>pl_editor_doc.icns</string>
<key>CFBundleTypeName</key> <string>pl_editor document</string>
<key>LSHandlerRank</key> <string>Owner</string>
</dict>
</array>
<key>CFBundleDevelopmentRegion</key> <string>English</string>
<key>CFBundleExecutable</key> <string>pl_editor</string>
<key>CFBundleGetInfoString</key> <string></string>
......
......@@ -54,11 +54,22 @@ make_lexer(
datafile_read_write.h
)
if( APPLE )
# setup bundle
set( PCB_CALCULATOR_RESOURCES pcb_calculator.icns )
set_source_files_properties( "${CMAKE_CURRENT_SOURCE_DIR}/pcb_calculator.icns" PROPERTIES
MACOSX_PACKAGE_LOCATION Resources
)
set( MACOSX_BUNDLE_ICON_FILE pcb_calculator.icns )
set( MACOSX_BUNDLE_GUI_IDENTIFIER org.kicad-eda.kicad )
set( MACOSX_BUNDLE_NAME pcb_calculator )
endif()
if( USE_KIWAY_DLLS )
#if( false )
add_executable( pcb_calculator WIN32
add_executable( pcb_calculator WIN32 MACOSX_BUNDLE
../common/single_top.cpp
../common/pgm_base.cpp
${PCB_CALCULATOR_RESOURCES}
......@@ -108,13 +119,32 @@ if( USE_KIWAY_DLLS )
# these 2 binaries are a matched set, keep them together
if( APPLE )
# puts binaries into the *.app bundle while linking
set_target_properties( pcb_calculator PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${OSX_BUNDLE_BUILD_BIN_DIR}
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist
)
# puts binaries into the *.app bundle while linking
set_target_properties( pcb_calculator_kiface PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${OSX_BUNDLE_BUILD_KIFACE_DIR}
)
# put individual bundle outside of main bundle as a first step
# will be pulled into the main bundle when creating main bundle
install( TARGETS pcb_calculator
DESTINATION ${KICAD_BIN}
COMPONENT binary
)
install( CODE "
# override default embedded path settings
${OSX_BUNDLE_OVERRIDE_PATHS}
# do all the work
include( BundleUtilities )
fixup_bundle( ${KICAD_BIN}/pcb_calculator.app/Contents/MacOS/pcb_calculator
\"\"
\"\"
)
" COMPONENT Runtime
)
else()
install( TARGETS pcb_calculator
DESTINATION ${KICAD_BIN}
......@@ -128,7 +158,7 @@ if( USE_KIWAY_DLLS )
else()
add_executable( pcb_calculator WIN32
add_executable( pcb_calculator WIN32 MACOSX_BUNDLE
../common/single_top.cpp
pcb_calculator.cpp
${PCB_CALCULATOR_SRCS}
......@@ -146,16 +176,9 @@ else()
polygon
${wxWidgets_LIBRARIES}
)
if( APPLE )
# puts binaries into the *.app bundle while linking
set_target_properties( pcb_calculator PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${OSX_BUNDLE_BUILD_BIN_DIR}
)
else()
install( TARGETS pcb_calculator
DESTINATION ${KICAD_BIN}
COMPONENT binary
)
endif()
install( TARGETS pcb_calculator
DESTINATION ${KICAD_BIN}
COMPONENT binary
)
endif()
......@@ -217,7 +217,7 @@ static bool scriptingSetup()
{
wxString path_frag;
#ifdef __MINGW32__
#if defined( __MINGW32__ )
// force python environment under Windows:
const wxString python_us( "python27_us" );
......@@ -261,28 +261,24 @@ static bool scriptingSetup()
// [KICAD_PATH]/scripting/plugins
// Add this default search path:
path_frag = Pgm().GetExecutablePath() + wxT( "scripting/plugins" );
#elif defined __WXMAC__
#elif defined( __WXMAC__ )
// User plugin folder is ~/Library/Application Support/kicad/scripting/plugins
path_frag = wxStandardPaths::Get().GetUserDataDir() + wxT( "/scripting/plugins" );
path_frag = GetOSXKicadUserDataDir() + wxT( "/scripting/plugins" );
// Add default paths to PYTHONPATH
wxString pypath;
// User scripting folder (~/Library/Application Support/kicad/scripting/plugins)
pypath = wxStandardPaths::Get().GetUserDataDir() + wxT( "/scripting/plugins" );
pypath = GetOSXKicadUserDataDir() + wxT( "/scripting/plugins" );
// Machine scripting folder (/Library/Application Support/kicad/scripting/plugins)
pypath += wxT( ":/Library/Application Support/kicad/scripting/plugins" );
pypath += wxT( ":" ) + GetOSXKicadMachineDataDir() + wxT( "/scripting/plugins" );
// Bundle scripting folder (<kicad.app>/Contents/SharedSupport/scripting/plugins)
pypath += wxT( ":" ) + wxStandardPaths::Get().GetDataDir() + wxT( "/scripting/plugins" );
// Bundle wxPython folder (<kicad.app>/Contents/Frameworks/python)
wxFileName fn = wxFileName( wxStandardPaths::Get().GetExecutablePath() );
fn.RemoveLastDir();
fn.AppendDir( wxT( "Frameworks" ) );
fn.AppendDir( wxT( "python" ) );
pypath += wxT( ":" ) + fn.GetPath();
// Original content of PYTHONPATH
pypath += wxT( ":" ) + GetOSXKicadDataDir() + wxT( "/scripting/plugins" );
// Bundle wxPython folder (<kicad.app>/Contents/Frameworks/python/site-packages)
pypath += wxT( ":" ) + Pgm().GetExecutablePath() + wxT( "Contents/Frameworks/python/site-packages" );
// Original content of $PYTHONPATH
if( wxGetenv("PYTHONPATH") != NULL )
{
pypath += wxT( ":" ) + wxString( wxGetenv("PYTHONPATH") );
pypath = wxString( wxGetenv("PYTHONPATH") ) + wxT( ":" ) + pypath;
}
// set $PYTHONPATH
......@@ -292,9 +288,6 @@ static bool scriptingSetup()
path_frag = wxT( "/usr/local/kicad/bin/scripting/plugins" );
#endif
// On linux and osx, 2 others paths are
// [HOME]/.kicad_plugins/
// [HOME]/.kicad/scripting/plugins/
if( !pcbnewInitPythonScripting( TO_UTF8( path_frag ) ) )
{
wxLogSysError( wxT( "pcbnewInitPythonScripting() failed." ) );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment