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

More OSX build fixes.

* Many path related fixes.
* Fix execution of external applications.
* Update mac-osx.txt.
* Add top-level links for standalone applications inside OSX bundle.
* Fix document icons for Eeschema and pl_editor.
* Create individual bundles for standalone applications inside the main application bundle.
* Add usual 'site-packages' to python path in OSX bundle.
* Fix name of OSX bundle plugin folder.
parent e4eddc56
...@@ -20,7 +20,18 @@ set_source_files_properties( bitmap2cmp_gui.cpp PROPERTIES ...@@ -20,7 +20,18 @@ set_source_files_properties( bitmap2cmp_gui.cpp PROPERTIES
COMPILE_DEFINITIONS "COMPILING_DLL" COMPILE_DEFINITIONS "COMPILING_DLL"
) )
add_executable( bitmap2component WIN32 if( APPLE )
# setup bundle
set( BITMAP2COMPONENT_RESOURCES bitmap2component.icns )
set_source_files_properties( "${CMAKE_CURRENT_SOURCE_DIR}/bitmap2component.icns" PROPERTIES
MACOSX_PACKAGE_LOCATION Resources
)
set( MACOSX_BUNDLE_ICON_FILE bitmap2component.icns )
set( MACOSX_BUNDLE_GUI_IDENTIFIER org.kicad-eda.kicad )
set( MACOSX_BUNDLE_NAME bitmap2component )
endif()
add_executable( bitmap2component WIN32 MACOSX_BUNDLE
${BITMAP2COMPONENT_SRCS} ${BITMAP2COMPONENT_SRCS}
${BITMAP2COMPONENT_RESOURCES} ${BITMAP2COMPONENT_RESOURCES}
) )
...@@ -34,9 +45,27 @@ target_link_libraries( bitmap2component ...@@ -34,9 +45,27 @@ target_link_libraries( bitmap2component
) )
if( APPLE ) if( APPLE )
# puts binaries into the *.app bundle while linking
set_target_properties( bitmap2component PROPERTIES set_target_properties( bitmap2component PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${OSX_BUNDLE_BUILD_BIN_DIR} MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist
)
# put individual bundle outside of main bundle as a first step
# will be pulled into the main bundle when creating main bundle
install( TARGETS bitmap2component
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}/bitmap2component.app/Contents/MacOS/bitmap2component
\"\"
\"\"
)
" COMPONENT Runtime
) )
else() else()
install( TARGETS bitmap2component install( TARGETS bitmap2component
......
...@@ -343,3 +343,50 @@ wxString GetKicadConfigPath() ...@@ -343,3 +343,50 @@ wxString GetKicadConfigPath()
return cfgpath.GetPath(); return cfgpath.GetPath();
} }
#ifdef __WXMAC__
wxString GetOSXKicadUserDataDir()
{
// According to wxWidgets documentation for GetUserDataDir:
// Mac: ~/Library/Application Support/appname
wxFileName udir( wxStandardPaths::Get().GetUserDataDir(), wxEmptyString );
// Since appname is different if started via launcher or standalone binary
// map all to "kicad" here
udir.RemoveLastDir();
udir.AppendDir( wxT( "kicad" ) );
return udir.GetPath();
}
wxString GetOSXKicadMachineDataDir()
{
return wxT( "/Library/Application Support/kicad" );
}
wxString GetOSXKicadDataDir()
{
// According to wxWidgets documentation for GetDataDir:
// Mac: appname.app/Contents/SharedSupport bundle subdirectory
wxFileName ddir( wxStandardPaths::Get().GetDataDir(), wxEmptyString );
// This must be mapped to main bundle for everything but kicad.app
const wxArrayString dirs = ddir.GetDirs();
if( dirs[dirs.GetCount() - 3] != wxT( "kicad.app" ) )
{
// Bundle structure resp. current path is
// kicad.app/Contents/Applications/<standalone>.app/Contents/SharedSupport
// and will be mapped to
// kicad.app/Contents/SharedSupprt
ddir.RemoveLastDir();
ddir.RemoveLastDir();
ddir.RemoveLastDir();
ddir.RemoveLastDir();
ddir.AppendDir( wxT( "SharedSupport" ) );
}
return ddir.GetPath();
}
#endif
...@@ -26,30 +26,27 @@ void SystemDirsAppend( SEARCH_STACK* aSearchStack ) ...@@ -26,30 +26,27 @@ void SystemDirsAppend( SEARCH_STACK* aSearchStack )
// Otherwise don't set it. // Otherwise don't set it.
maybe.AddPaths( wxGetenv( wxT( "KICAD" ) ) ); maybe.AddPaths( wxGetenv( wxT( "KICAD" ) ) );
#ifndef __WXMAC__ #ifdef __WXMAC__
// Add the directory for the user-dependent, program specific data files.
maybe.AddPaths( GetOSXKicadUserDataDir() );
// Global machine specific application data
maybe.AddPaths( GetOSXKicadMachineDataDir() );
// Global application specific data files inside bundle
maybe.AddPaths( GetOSXKicadDataDir() );
#else
// This is from CMAKE_INSTALL_PREFIX. // This is from CMAKE_INSTALL_PREFIX.
// Useful when KiCad is installed by `make install`. // Useful when KiCad is installed by `make install`.
// Use as second ranked place. // Use as second ranked place.
maybe.AddPaths( wxT( DEFAULT_INSTALL_PATH ) ); maybe.AddPaths( wxT( DEFAULT_INSTALL_PATH ) );
#endif
// Add the directory for the user-dependent, program specific, data files: // Add the directory for the user-dependent, program specific data files.
// According to wxWidgets documentation:
// Unix: ~/.appname // Unix: ~/.appname
// Windows: C:\Documents and Settings\username\Application Data\appname // Windows: C:\Documents and Settings\username\Application Data\appname
// Mac: ~/Library/Application Support/appname
maybe.AddPaths( wxStandardPaths::Get().GetUserDataDir() ); maybe.AddPaths( wxStandardPaths::Get().GetUserDataDir() );
#ifdef __WXMAC__
// global machine specific application data
maybe.AddPaths( wxT( "/Library/Application Support/kicad" ) );
// Dir of the global (not user-specific), application specific, data files.
// From wx docs:
// Unix: prefix/share/appname
// Windows: the directory where the executable file is located
// Mac: appname.app/Contents/SharedSupport bundle subdirectory
maybe.AddPaths( wxStandardPaths::Get().GetDataDir() );
#else
{ {
// Should be full path to this program executable. // Should be full path to this program executable.
wxString bin_dir = Pgm().GetExecutablePath(); wxString bin_dir = Pgm().GetExecutablePath();
......
...@@ -88,7 +88,6 @@ enum pseudokeys { ...@@ -88,7 +88,6 @@ enum pseudokeys {
#define PCB_CALCULATOR_EXE wxT( "pcb_calculator.exe" ) #define PCB_CALCULATOR_EXE wxT( "pcb_calculator.exe" )
#define PL_EDITOR_EXE wxT( "pl_editor.exe" ) #define PL_EDITOR_EXE wxT( "pl_editor.exe" )
#else #else
#ifndef __WXMAC__
#define CVPCB_EXE wxT( "cvpcb" ) #define CVPCB_EXE wxT( "cvpcb" )
#define PCBNEW_EXE wxT( "pcbnew" ) #define PCBNEW_EXE wxT( "pcbnew" )
#define EESCHEMA_EXE wxT( "eeschema" ) #define EESCHEMA_EXE wxT( "eeschema" )
...@@ -96,16 +95,6 @@ enum pseudokeys { ...@@ -96,16 +95,6 @@ enum pseudokeys {
#define BITMAPCONVERTER_EXE wxT( "bitmap2component" ) #define BITMAPCONVERTER_EXE wxT( "bitmap2component" )
#define PCB_CALCULATOR_EXE wxT( "pcb_calculator" ) #define PCB_CALCULATOR_EXE wxT( "pcb_calculator" )
#define PL_EDITOR_EXE wxT( "pl_editor" ) #define PL_EDITOR_EXE wxT( "pl_editor" )
#else
// All binaries are now in kicad.app bundle
#define CVPCB_EXE wxT( "kicad.app/Contents/MacOS/cvpcb" )
#define PCBNEW_EXE wxT( "kicad.app/Contents/MacOS/pcbnew" )
#define EESCHEMA_EXE wxT( "kicad.app/Contents/MacOS/eeschema" )
#define GERBVIEW_EXE wxT( "kicad.app/Contents/MacOS/gerbview" )
#define BITMAPCONVERTER_EXE wxT( "kicad.app/Contents/MacOS/bitmap2component" )
#define PCB_CALCULATOR_EXE wxT( "kicad.app/Contents/MacOS/pcb_calculator" )
#define PL_EDITOR_EXE wxT( "kicad.app/Contents/MacOS/pl_editor" )
# endif
#endif #endif
...@@ -643,5 +632,24 @@ wxConfigBase* GetNewConfig( const wxString& aProgName ); ...@@ -643,5 +632,24 @@ wxConfigBase* GetNewConfig( const wxString& aProgName );
*/ */
wxString GetKicadConfigPath(); wxString GetKicadConfigPath();
#ifdef __WXMAC__
/**
* OSX specific function GetOSXKicadUserDataDir
* @return A wxString pointing to the user data directory for Kicad
*/
wxString GetOSXKicadUserDataDir();
/**
* OSX specific function GetOSXMachineDataDir
* @return A wxString pointing to the machine data directory for Kicad
*/
wxString GetOSXKicadMachineDataDir();
/**
* OSX specific function GetOSXKicadDataDir
* @return A wxString pointing to the bundle data directory for Kicad
*/
wxString GetOSXKicadDataDir();
#endif
#endif // INCLUDE__COMMON_H_ #endif // INCLUDE__COMMON_H_
...@@ -473,6 +473,22 @@ if( MINGW ) ...@@ -473,6 +473,22 @@ if( MINGW )
mingw_resource_compiler( pcbnew ) mingw_resource_compiler( pcbnew )
endif() endif()
if( APPLE )
# setup bundle
set( PCBNEW_RESOURCES pcbnew.icns pcbnew_doc.icns )
set_source_files_properties( "${CMAKE_CURRENT_SOURCE_DIR}/pcbnew.icns" PROPERTIES
MACOSX_PACKAGE_LOCATION Resources
)
set_source_files_properties( "${CMAKE_CURRENT_SOURCE_DIR}/pcbnew_doc.icns" PROPERTIES
MACOSX_PACKAGE_LOCATION Resources
)
set( MACOSX_BUNDLE_ICON_FILE pcbnew.icns )
set( MACOSX_BUNDLE_GUI_IDENTIFIER org.kicad-eda.kicad )
set( MACOSX_BUNDLE_NAME pcbnew )
endif()
# Create a C++ compilable string initializer containing html text into a *.h file: # Create a C++ compilable string initializer containing html text into a *.h file:
add_custom_command( add_custom_command(
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/dialog_freeroute_exchange_help_html.h OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/dialog_freeroute_exchange_help_html.h
...@@ -513,7 +529,7 @@ if( USE_KIWAY_DLLS ) ...@@ -513,7 +529,7 @@ if( USE_KIWAY_DLLS )
#if( false ) #if( false )
# a very small program launcher for pcbnew_kiface # a very small program launcher for pcbnew_kiface
add_executable( pcbnew WIN32 add_executable( pcbnew WIN32 MACOSX_BUNDLE
../common/single_top.cpp ../common/single_top.cpp
${PCBNEW_RESOURCES} ${PCBNEW_RESOURCES}
) )
...@@ -593,13 +609,32 @@ if( USE_KIWAY_DLLS ) ...@@ -593,13 +609,32 @@ if( USE_KIWAY_DLLS )
# these 2 binaries are a matched set, keep them together: # these 2 binaries are a matched set, keep them together:
if( APPLE ) if( APPLE )
# puts binaries into the *.app bundle while linking
set_target_properties( pcbnew PROPERTIES set_target_properties( pcbnew 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( pcbnew_kiface PROPERTIES set_target_properties( pcbnew_kiface PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${OSX_BUNDLE_BUILD_KIFACE_DIR} 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 pcbnew
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}/pcbnew.app/Contents/MacOS/pcbnew
\"\"
\"\"
)
" COMPONENT Runtime
)
else() else()
install( TARGETS pcbnew install( TARGETS pcbnew
DESTINATION ${KICAD_BIN} DESTINATION ${KICAD_BIN}
...@@ -613,7 +648,7 @@ if( USE_KIWAY_DLLS ) ...@@ -613,7 +648,7 @@ if( USE_KIWAY_DLLS )
else() # milestone A) kills this off: else() # milestone A) kills this off:
add_executable( pcbnew WIN32 add_executable( pcbnew WIN32 MACOSX_BUNDLE
../common/single_top.cpp ../common/single_top.cpp
pcbnew.cpp pcbnew.cpp
${PCBNEW_SRCS} ${PCBNEW_SRCS}
...@@ -666,17 +701,10 @@ else() # milestone A) kills this off: ...@@ -666,17 +701,10 @@ else() # milestone A) kills this off:
) )
endif() endif()
if( APPLE )
# puts binaries into the *.app bundle while linking
set_target_properties( pcbnew PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${OSX_BUNDLE_BUILD_BIN_DIR}
)
else()
install( TARGETS pcbnew install( TARGETS pcbnew
DESTINATION ${KICAD_BIN} DESTINATION ${KICAD_BIN}
COMPONENT binary COMPONENT binary
) )
endif()
endif() endif()
......
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