cmake: adding KICAD_MACOSX_APP_BUNDLE option

ADDED: with cmake KICAD_MACOSX_APP_BUNDLE option the user can disable
the macOS app bundle creation when compiling on macOS. This permit to
use/install KiCad like any other *nix platform (/usr/bin, /usr/share,
ecc.). By default, cmake build the app bundle.
This commit is contained in:
Davide Gerhard 2022-01-22 20:35:32 +01:00 committed by Seth Hillbrand
parent 7277fd6218
commit ea9f960cc1
27 changed files with 94 additions and 57 deletions

View File

@ -124,7 +124,7 @@ void S3D_PLUGIN_MANAGER::loadPlugins( void )
std::list< wxString > pluginlist; std::list< wxString > pluginlist;
wxFileName fn; wxFileName fn;
#ifndef __WXMAC__ #ifndef __MACOSX_APP__
#ifdef DEBUG #ifdef DEBUG
// set up to work from the build directory // set up to work from the build directory

View File

@ -35,7 +35,7 @@ endif( MINGW )
add_library( kicad_3dsg SHARED ${SG_FILES} ) add_library( kicad_3dsg SHARED ${SG_FILES} )
if( APPLE ) if( KICAD_MACOSX_APP_BUNDLE )
# puts library into the main kicad.app bundle in build tree # puts library into the main kicad.app bundle in build tree
set_target_properties( kicad_3dsg PROPERTIES set_target_properties( kicad_3dsg PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${OSX_BUNDLE_BUILD_LIB_DIR}" LIBRARY_OUTPUT_DIRECTORY "${OSX_BUNDLE_BUILD_LIB_DIR}"

View File

@ -166,6 +166,11 @@ if( KICAD_USE_3DCONNEXION )
endif() endif()
endif() endif()
cmake_dependent_option( KICAD_MACOSX_APP_BUNDLE
"Create macOS Application bundle"
ON "APPLE"
OFF )
# Global setting: exports are explicit # Global setting: exports are explicit
set( CMAKE_CXX_VISIBILITY_PRESET "hidden" ) set( CMAKE_CXX_VISIBILITY_PRESET "hidden" )
set( CMAKE_VISIBILITY_INLINES_HIDDEN ON ) set( CMAKE_VISIBILITY_INLINES_HIDDEN ON )
@ -187,6 +192,10 @@ if( KICAD_GAL_PROFILE )
add_definitions( -DKICAD_GAL_PROFILE ) add_definitions( -DKICAD_GAL_PROFILE )
endif() endif()
if ( KICAD_MACOSX_APP_BUNDLE )
add_definitions ( -D__MACOSX_APP__ )
endif()
# Ensure DEBUG is defined for all platforms in Debug builds # Ensure DEBUG is defined for all platforms in Debug builds
# change to add_compile_definitions() after minimum required CMake version is 3.12 # change to add_compile_definitions() after minimum required CMake version is 3.12
set_property( DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:DEBUG> ) set_property( DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:DEBUG> )
@ -518,7 +527,7 @@ set( KIFACE_PREFIX "_" )
#================================================ #================================================
# Locations for install targets. # Locations for install targets.
#================================================ #================================================
if( NOT APPLE ) if( NOT KICAD_MACOSX_APP_BUNDLE )
# Everything without leading / is relative to CMAKE_INSTALL_PREFIX. # Everything without leading / is relative to CMAKE_INSTALL_PREFIX.
set( KICAD_BIN bin set( KICAD_BIN bin
CACHE PATH "Location of KiCad binaries." ) CACHE PATH "Location of KiCad binaries." )
@ -814,7 +823,7 @@ if( NOT PYTHON_SITE_PACKAGE_PATH )
endif() endif()
endif() endif()
if( APPLE ) if( KICAD_MACOSX_APP_BUNDLE )
set( OSX_BUNDLE_PYTHON_SITE_PACKAGES_DIR ${OSX_BUNDLE_LIB_DIR}/Python.framework/Versions/${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages) set( OSX_BUNDLE_PYTHON_SITE_PACKAGES_DIR ${OSX_BUNDLE_LIB_DIR}/Python.framework/Versions/${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages)
set( OSX_BUNDLE_INSTALL_PYTHON_SITE_PACKAGES_DIR "${OSX_BUNDLE_INSTALL_DIR}/${OSX_BUNDLE_PYTHON_SITE_PACKAGES_DIR}") set( OSX_BUNDLE_INSTALL_PYTHON_SITE_PACKAGES_DIR "${OSX_BUNDLE_INSTALL_DIR}/${OSX_BUNDLE_PYTHON_SITE_PACKAGES_DIR}")
set( PYTHON_DEST "${OSX_BUNDLE_BUILD_DIR}/${OSX_BUNDLE_PYTHON_SITE_PACKAGES_DIR}" set( PYTHON_DEST "${OSX_BUNDLE_BUILD_DIR}/${OSX_BUNDLE_PYTHON_SITE_PACKAGES_DIR}"
@ -907,7 +916,7 @@ if( MINGW )
endif() endif()
endif() endif()
if( APPLE ) if( KICAD_MACOSX_APP_BUNDLE )
# Remove app bundles in ${KICAD_BIN} before installing anything new. # Remove app bundles in ${KICAD_BIN} before installing anything new.
# Must be defined before all includes so that it is executed first. # Must be defined before all includes so that it is executed first.
install( CODE " install( CODE "

View File

@ -35,7 +35,7 @@ if( WIN32 )
endif() endif()
endif() endif()
if( APPLE ) if( KICAD_MACOSX_APP_BUNDLE )
# setup bundle # setup bundle
set( BITMAP2COMPONENT_RESOURCES bitmap2component.icns ) set( BITMAP2COMPONENT_RESOURCES bitmap2component.icns )
set_source_files_properties( "${CMAKE_CURRENT_SOURCE_DIR}/bitmap2component.icns" PROPERTIES set_source_files_properties( "${CMAKE_CURRENT_SOURCE_DIR}/bitmap2component.icns" PROPERTIES
@ -57,7 +57,11 @@ target_link_libraries( bitmap2component
potrace potrace
) )
if( APPLE ) set_target_properties( bitmap2component PROPERTIES
MACOSX_BUNDLE $<BOOL:KICAD_MACOSX_APP_BUNDLE>
)
if( KICAD_MACOSX_APP_BUNDLE )
set_target_properties( bitmap2component PROPERTIES set_target_properties( bitmap2component PROPERTIES
MACOSX_BUNDLE_INFO_PLIST ${PROJECT_BINARY_DIR}/bitmap2component/Info.plist MACOSX_BUNDLE_INFO_PLIST ${PROJECT_BINARY_DIR}/bitmap2component/Info.plist
) )

View File

@ -53,7 +53,7 @@ wxString FindKicadFile( const wxString& shortname )
{ {
// Test the presence of the file in the directory shortname of // Test the presence of the file in the directory shortname of
// the KiCad binary path. // the KiCad binary path.
#ifndef __WXMAC__ #ifndef __MACOSX_APP__
wxString fullFileName = Pgm().GetExecutablePath() + shortname; wxString fullFileName = Pgm().GetExecutablePath() + shortname;
#else #else
wxString fullFileName = Pgm().GetExecutablePath() + wxT( "Contents/MacOS/" ) + shortname; wxString fullFileName = Pgm().GetExecutablePath() + wxT( "Contents/MacOS/" ) + shortname;
@ -79,7 +79,7 @@ wxString FindKicadFile( const wxString& shortname )
// Path list for KiCad binary files // Path list for KiCad binary files
const static wxChar* possibilities[] = { const static wxChar* possibilities[] = {
#if defined( __WXMAC__ ) #if defined( __MACOSX_APP__ )
// all internal paths are relative to main bundle kicad.app // all internal paths are relative to main bundle kicad.app
wxT( "Contents/Applications/pcbnew.app/Contents/MacOS/" ), wxT( "Contents/Applications/pcbnew.app/Contents/MacOS/" ),
wxT( "Contents/Applications/eeschema.app/Contents/MacOS/" ), wxT( "Contents/Applications/eeschema.app/Contents/MacOS/" ),
@ -97,7 +97,7 @@ wxString FindKicadFile( const wxString& shortname )
// find binary file from possibilities list: // find binary file from possibilities list:
for( unsigned i=0; i<arrayDim(possibilities); ++i ) for( unsigned i=0; i<arrayDim(possibilities); ++i )
{ {
#ifndef __WXMAC__ #ifndef __MACOSX_APP__
fullFileName = possibilities[i] + shortname; fullFileName = possibilities[i] + shortname;
#else #else
// make relative paths absolute // make relative paths absolute

View File

@ -122,7 +122,7 @@ const wxString KIWAY::dso_search_path( FACE_T aFaceId )
return wxEmptyString; return wxEmptyString;
} }
#ifndef __WXMAC__ #ifndef __MACOSX_APP__
wxString path; wxString path;
if( m_ctl & (KFCTL_STANDALONE | KFCTL_CPP_PROJECT_SUITE) ) if( m_ctl & (KFCTL_STANDALONE | KFCTL_CPP_PROJECT_SUITE) )
@ -148,7 +148,7 @@ const wxString KIWAY::dso_search_path( FACE_T aFaceId )
if( wxGetEnv( wxT( "KICAD_RUN_FROM_BUILD_DIR" ), nullptr ) ) if( wxGetEnv( wxT( "KICAD_RUN_FROM_BUILD_DIR" ), nullptr ) )
{ {
#ifdef __WXMAC__ #ifdef __MACOSX_APP__
// On Mac, all of the kifaces are placed in the kicad.app bundle, even though the individual // On Mac, all of the kifaces are placed in the kicad.app bundle, even though the individual
// standalone binaries are placed in separate bundles before the make install step runs. // standalone binaries are placed in separate bundles before the make install step runs.
// So, we have to jump up to the kicad directory, then the PlugIns section of the kicad // So, we have to jump up to the kicad directory, then the PlugIns section of the kicad

View File

@ -29,7 +29,7 @@
#include <config.h> #include <config.h>
// lowercase or pretty case depending on platform // lowercase or pretty case depending on platform
#if defined( __WXMAC__ ) || defined( __WXMSW__ ) #if defined( __MACOSX_APP__ ) || defined( __WXMSW__ )
#define KICAD_PATH_STR "KiCad" #define KICAD_PATH_STR "KiCad"
#else #else
#define KICAD_PATH_STR "kicad" #define KICAD_PATH_STR "kicad"
@ -154,7 +154,7 @@ wxString PATHS::GetStockDataPath( bool aRespectRunFromBuildDir )
if( aRespectRunFromBuildDir && wxGetEnv( wxT( "KICAD_RUN_FROM_BUILD_DIR" ), nullptr ) ) if( aRespectRunFromBuildDir && wxGetEnv( wxT( "KICAD_RUN_FROM_BUILD_DIR" ), nullptr ) )
{ {
// Allow debugging from build dir by placing relevant files/folders in the build root // Allow debugging from build dir by placing relevant files/folders in the build root
#if defined( __WXMAC__ ) #if defined( __MACOSX_APP__ )
wxFileName fn = wxStandardPaths::Get().GetExecutablePath(); wxFileName fn = wxStandardPaths::Get().GetExecutablePath();
fn.RemoveLastDir(); fn.RemoveLastDir();
@ -170,7 +170,7 @@ wxString PATHS::GetStockDataPath( bool aRespectRunFromBuildDir )
} }
else else
{ {
#if defined( __WXMAC__ ) #if defined( __MACOSX_APP__ )
path = GetOSXKicadDataDir(); path = GetOSXKicadDataDir();
#elif defined( __WXMSW__ ) #elif defined( __WXMSW__ )
path = getWindowsKiCadRoot() + wxT( "share/kicad" ); path = getWindowsKiCadRoot() + wxT( "share/kicad" );
@ -187,7 +187,7 @@ wxString PATHS::GetStockEDALibraryPath()
{ {
wxString path; wxString path;
#if defined( __WXMAC__ ) #if defined( __MACOSX_APP__ )
path = GetOSXKicadMachineDataDir(); path = GetOSXKicadMachineDataDir();
#elif defined( __WXMSW__ ) #elif defined( __WXMSW__ )
path = GetStockDataPath( false ); path = GetStockDataPath( false );
@ -266,7 +266,7 @@ wxString PATHS::GetStockPlugins3DPath()
fn.Assign( tfname, "" ); fn.Assign( tfname, "" );
fn.AppendDir( wxT( "kicad" ) ); fn.AppendDir( wxT( "kicad" ) );
fn.AppendDir( wxT( "plugins" ) ); fn.AppendDir( wxT( "plugins" ) );
#elif defined( __WXMAC__ ) #elif defined( __MACOSX_APP__ )
fn.Assign( wxStandardPaths::Get().GetPluginsDir(), wxEmptyString ); fn.Assign( wxStandardPaths::Get().GetPluginsDir(), wxEmptyString );
#else #else
fn.AssignDir( Pgm().GetExecutablePath() ); fn.AssignDir( Pgm().GetExecutablePath() );
@ -306,7 +306,7 @@ wxString PATHS::GetDocumentationPath()
{ {
wxString path; wxString path;
#if defined( __WXMAC__ ) #if defined( __MACOSX_APP__ )
path = GetOSXKicadDataDir(); path = GetOSXKicadDataDir();
#elif defined( __WXMSW__ ) #elif defined( __WXMSW__ )
path = getWindowsKiCadRoot() + "share/doc/kicad"; path = getWindowsKiCadRoot() + "share/doc/kicad";

View File

@ -52,7 +52,7 @@ 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" ) ) );
#ifdef __WXMAC__ #ifdef __MACOSX_APP__
// Add the directory for the user-dependent, program specific data files. // Add the directory for the user-dependent, program specific data files.
maybe.AddPaths( PATHS::GetOSXKicadUserDataDir() ); maybe.AddPaths( PATHS::GetOSXKicadUserDataDir() );
@ -137,7 +137,7 @@ void SystemDirsAppend( SEARCH_STACK* aSearchStack )
{ {
wxFileName fn( maybe[i], wxEmptyString ); wxFileName fn( maybe[i], wxEmptyString );
#ifndef __WXMAC__ #ifndef __MACOSX_APP__
if( fn.GetPath().AfterLast( fn.GetPathSeparator() ) == wxT( "bin" ) ) if( fn.GetPath().AfterLast( fn.GetPathSeparator() ) == wxT( "bin" ) )
{ {
fn.RemoveLastDir(); fn.RemoveLastDir();
@ -149,7 +149,7 @@ void SystemDirsAppend( SEARCH_STACK* aSearchStack )
aSearchStack->AddPaths( fn.GetPath() ); aSearchStack->AddPaths( fn.GetPath() );
#ifndef __WXMAC__ #ifndef __MACOSX_APP__
fn.AppendDir( wxT( "kicad" ) ); fn.AppendDir( wxT( "kicad" ) );
aSearchStack->AddPaths( fn.GetPath() ); // add maybe[i]/kicad aSearchStack->AddPaths( fn.GetPath() ); // add maybe[i]/kicad

View File

@ -99,7 +99,7 @@ if( MAKE_LINK_MAPS )
endif() endif()
# these 2 binaries are a matched set, keep them together: # these 2 binaries are a matched set, keep them together:
if( APPLE ) if( KICAD_MACOSX_APP_BUNDLE )
# puts binaries into the *.app bundle while linking # puts binaries into the *.app bundle while linking
set_target_properties( cvpcb_kiface PROPERTIES set_target_properties( cvpcb_kiface PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${OSX_BUNDLE_BUILD_KIFACE_DIR} LIBRARY_OUTPUT_DIRECTORY ${OSX_BUNDLE_BUILD_KIFACE_DIR}

View File

@ -354,7 +354,7 @@ set_source_files_properties( sch_text.cpp
OBJECT_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/sch_text_help_md.h OBJECT_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/sch_text_help_md.h
) )
if( APPLE ) if( KICAD_MACOSX_APP_BUNDLE )
# setup bundle # setup bundle
set( EESCHEMA_RESOURCES eeschema.icns eeschema_doc.icns ) set( EESCHEMA_RESOURCES eeschema.icns eeschema_doc.icns )
set_source_files_properties( "${CMAKE_CURRENT_SOURCE_DIR}/eeschema.icns" PROPERTIES set_source_files_properties( "${CMAKE_CURRENT_SOURCE_DIR}/eeschema.icns" PROPERTIES
@ -385,6 +385,10 @@ target_link_libraries( eeschema
${wxWidgets_LIBRARIES} ${wxWidgets_LIBRARIES}
) )
set_target_properties( eeschema PROPERTIES
MACOSX_BUNDLE $<BOOL:KICAD_MACOSX_APP_BUNDLE>
)
# the main Eeschema program, in DSO form. # the main Eeschema program, in DSO form.
add_library( eeschema_kiface_objects OBJECT add_library( eeschema_kiface_objects OBJECT
${EESCHEMA_SRCS} ${EESCHEMA_SRCS}
@ -453,7 +457,7 @@ if( MAKE_LINK_MAPS )
endif() endif()
# these 2 binaries are a matched set, keep them together: # these 2 binaries are a matched set, keep them together:
if( APPLE ) if( KICAD_MACOSX_APP_BUNDLE )
set_target_properties( eeschema PROPERTIES set_target_properties( eeschema PROPERTIES
MACOSX_BUNDLE_INFO_PLIST ${PROJECT_BINARY_DIR}/eeschema/Info.plist MACOSX_BUNDLE_INFO_PLIST ${PROJECT_BINARY_DIR}/eeschema/Info.plist
) )

View File

@ -75,7 +75,7 @@ BOM_GENERATOR_HANDLER::BOM_GENERATOR_HANDLER( const wxString& aFile )
#else #else
// For macOS, we want to use the Python we bundle along, rather than just PYTHON_EXECUTABLE. // For macOS, we want to use the Python we bundle along, rather than just PYTHON_EXECUTABLE.
// For non-Windows, non-macOS, we can call out to PYTHON_EXECUTABLE. // For non-Windows, non-macOS, we can call out to PYTHON_EXECUTABLE.
#ifdef __APPLE__ #ifdef __MACOSX_APP__
// python is at Contents/Frameworks/Python.framework/Versions/Current/bin/python3 // python is at Contents/Frameworks/Python.framework/Versions/Current/bin/python3
// Of course, for macOS, it's not quite that simple, since the relative path // Of course, for macOS, it's not quite that simple, since the relative path

View File

@ -673,7 +673,7 @@ void NETLIST_DIALOG_ADD_GENERATOR::OnBrowseGenerators( wxCommandEvent& event )
{ {
wxString FullFileName, Path; wxString FullFileName, Path;
#ifndef __WXMAC__ #ifndef __MACOSX_APP__
Path = Pgm().GetExecutablePath(); Path = Pgm().GetExecutablePath();
#else #else
Path = PATHS::GetOSXKicadDataDir() + wxT( "/plugins" ); Path = PATHS::GetOSXKicadDataDir() + wxT( "/plugins" );

View File

@ -431,7 +431,7 @@ void NGSPICE::init_dll()
#else #else
const vector<string> dllPaths = { "", "/mingw64/bin", "/mingw32/bin" }; const vector<string> dllPaths = { "", "/mingw64/bin", "/mingw32/bin" };
#endif #endif
#elif defined(__WXMAC__) #elif defined(__MACOSX_APP__)
const vector<string> dllPaths = { const vector<string> dllPaths = {
PATHS::GetOSXKicadUserDataDir().ToStdString() + "/PlugIns/ngspice", PATHS::GetOSXKicadUserDataDir().ToStdString() + "/PlugIns/ngspice",
PATHS::GetOSXKicadMachineDataDir().ToStdString() + "/PlugIns/ngspice", PATHS::GetOSXKicadMachineDataDir().ToStdString() + "/PlugIns/ngspice",

View File

@ -89,7 +89,7 @@ if( WIN32 )
endif() endif()
endif() endif()
if( APPLE ) if( KICAD_MACOSX_APP_BUNDLE )
# setup bundle # setup bundle
set( GERBVIEW_RESOURCES gerbview.icns gerbview_doc.icns ) set( GERBVIEW_RESOURCES gerbview.icns gerbview_doc.icns )
set_source_files_properties( "${CMAKE_CURRENT_SOURCE_DIR}/gerbview.icns" PROPERTIES set_source_files_properties( "${CMAKE_CURRENT_SOURCE_DIR}/gerbview.icns" PROPERTIES
@ -120,6 +120,10 @@ target_link_libraries( gerbview
${wxWidgets_LIBRARIES} ${wxWidgets_LIBRARIES}
) )
set_target_properties( gerbview PROPERTIES
MACOSX_BUNDLE $<BOOL:KICAD_MACOSX_APP_BUNDLE>
)
if( MAKE_LINK_MAPS ) if( MAKE_LINK_MAPS )
set_target_properties( gerbview PROPERTIES set_target_properties( gerbview PROPERTIES
LINK_FLAGS "-Wl,-cref,-Map=gerbview.map" ) LINK_FLAGS "-Wl,-cref,-Map=gerbview.map" )
@ -168,7 +172,7 @@ endif()
add_dependencies( gerbview gerbview_kiface ) add_dependencies( gerbview gerbview_kiface )
# these 2 binaries are a matched set, keep them together # these 2 binaries are a matched set, keep them together
if( APPLE ) if( KICAD_MACOSX_APP_BUNDLE )
set_target_properties( gerbview PROPERTIES set_target_properties( gerbview PROPERTIES
MACOSX_BUNDLE_INFO_PLIST ${PROJECT_BINARY_DIR}/gerbview/Info.plist MACOSX_BUNDLE_INFO_PLIST ${PROJECT_BINARY_DIR}/gerbview/Info.plist
) )

View File

@ -43,7 +43,7 @@ if( WIN32 )
endif() endif()
endif() endif()
if( APPLE ) if( KICAD_MACOSX_APP_BUNDLE )
set( KICAD_RESOURCES kicad.icns kicad_doc.icns ) set( KICAD_RESOURCES kicad.icns kicad_doc.icns )
set_source_files_properties( "${CMAKE_CURRENT_SOURCE_DIR}/kicad.icns" PROPERTIES set_source_files_properties( "${CMAKE_CURRENT_SOURCE_DIR}/kicad.icns" PROPERTIES
MACOSX_PACKAGE_LOCATION Resources MACOSX_PACKAGE_LOCATION Resources
@ -62,6 +62,10 @@ add_executable( kicad WIN32 MACOSX_BUNDLE
${KICAD_RESOURCES} ${KICAD_RESOURCES}
) )
set_target_properties( kicad PROPERTIES
MACOSX_BUNDLE $<BOOL:KICAD_MACOSX_APP_BUNDLE>
)
if( UNIX ) if( UNIX )
# for build directory: create kiface symlinks so kicad (exe) can be run in-situ # for build directory: create kiface symlinks so kicad (exe) can be run in-situ
add_custom_target( kiface_sym_links add_custom_target( kiface_sym_links
@ -72,7 +76,7 @@ if( UNIX )
) )
endif() endif()
if( APPLE ) if( KICAD_MACOSX_APP_BUNDLE )
set_target_properties( kicad PROPERTIES set_target_properties( kicad PROPERTIES
MACOSX_BUNDLE_INFO_PLIST ${PROJECT_BINARY_DIR}/kicad/Info.plist MACOSX_BUNDLE_INFO_PLIST ${PROJECT_BINARY_DIR}/kicad/Info.plist
) )
@ -104,7 +108,7 @@ if( KICAD_WIN32_INSTALL_PDBS )
install(FILES $<TARGET_PDB_FILE:kicad> DESTINATION ${KICAD_BIN}) install(FILES $<TARGET_PDB_FILE:kicad> DESTINATION ${KICAD_BIN})
endif() endif()
if( APPLE ) if( KICAD_MACOSX_APP_BUNDLE )
# "install( CODE ... )" will launch its own CMake, so no variables from # "install( CODE ... )" will launch its own CMake, so no variables from
# this CMake instance are accessible... use helper to transfer # this CMake instance are accessible... use helper to transfer
set( SCRIPTING_HELPER "1" ) set( SCRIPTING_HELPER "1" )

View File

@ -799,7 +799,7 @@ int KICAD_MANAGER_CONTROL::Execute( const TOOL_EVENT& aEvent )
wxString msg = wxString::Format( _( "%s %s opened [pid=%ld]\n" ), execFile, param, pid ); wxString msg = wxString::Format( _( "%s %s opened [pid=%ld]\n" ), execFile, param, pid );
m_frame->PrintMsg( msg ); m_frame->PrintMsg( msg );
#ifdef __WXMAC__ #ifdef __MACOSX_APP__
// This non-parameterized use of wxExecute is fine because execFile is not derived // This non-parameterized use of wxExecute is fine because execFile is not derived
// from user input. // from user input.
wxExecute( "osascript -e 'activate application \"" + execFile + "\"'" ); wxExecute( "osascript -e 'activate application \"" + execFile + "\"'" );

View File

@ -62,7 +62,7 @@ if( WIN32 )
endif() endif()
if( APPLE ) if( KICAD_MACOSX_APP_BUNDLE )
# setup bundle # setup bundle
set( PL_EDITOR_RESOURCES pagelayout_editor.icns pagelayout_editor_doc.icns ) set( PL_EDITOR_RESOURCES pagelayout_editor.icns pagelayout_editor_doc.icns )
set_source_files_properties( "${CMAKE_CURRENT_SOURCE_DIR}/pagelayout_editor.icns" PROPERTIES set_source_files_properties( "${CMAKE_CURRENT_SOURCE_DIR}/pagelayout_editor.icns" PROPERTIES
@ -93,6 +93,10 @@ target_link_libraries( pl_editor
${wxWidgets_LIBRARIES} ${wxWidgets_LIBRARIES}
) )
set_target_properties( pl_editor PROPERTIES
MACOSX_BUNDLE $<BOOL:KICAD_MACOSX_APP_BUNDLE>
)
if( MAKE_LINK_MAPS ) if( MAKE_LINK_MAPS )
set_target_properties( pl_editor PROPERTIES set_target_properties( pl_editor PROPERTIES
LINK_FLAGS "-Wl,-cref,-Map=pl_editor.map" ) LINK_FLAGS "-Wl,-cref,-Map=pl_editor.map" )
@ -130,7 +134,7 @@ endif()
add_dependencies( pl_editor pl_editor_kiface ) add_dependencies( pl_editor pl_editor_kiface )
# these 2 binaries are a matched set, keep them together: # these 2 binaries are a matched set, keep them together:
if( APPLE ) if( KICAD_MACOSX_APP_BUNDLE )
set_target_properties( pl_editor PROPERTIES set_target_properties( pl_editor PROPERTIES
MACOSX_BUNDLE_INFO_PLIST ${PROJECT_BINARY_DIR}/pagelayout_editor/Info.plist MACOSX_BUNDLE_INFO_PLIST ${PROJECT_BINARY_DIR}/pagelayout_editor/Info.plist
) )

View File

@ -58,7 +58,7 @@ if( WIN32 )
endif() endif()
endif() endif()
if( APPLE ) if( KICAD_MACOSX_APP_BUNDLE )
# setup bundle # setup bundle
set( PCB_CALCULATOR_RESOURCES pcb_calculator.icns ) set( PCB_CALCULATOR_RESOURCES pcb_calculator.icns )
set_source_files_properties( "${CMAKE_CURRENT_SOURCE_DIR}/pcb_calculator.icns" PROPERTIES set_source_files_properties( "${CMAKE_CURRENT_SOURCE_DIR}/pcb_calculator.icns" PROPERTIES
@ -84,6 +84,10 @@ target_link_libraries( pcb_calculator
${wxWidgets_LIBRARIES} ${wxWidgets_LIBRARIES}
) )
set_target_properties( pcb_calculator PROPERTIES
MACOSX_BUNDLE $<BOOL:KICAD_MACOSX_APP_BUNDLE>
)
if( MAKE_LINK_MAPS ) if( MAKE_LINK_MAPS )
set_target_properties( pcb_calculator PROPERTIES set_target_properties( pcb_calculator PROPERTIES
LINK_FLAGS "-Wl,-cref,-Map=pcb_calculator.map" ) LINK_FLAGS "-Wl,-cref,-Map=pcb_calculator.map" )
@ -119,7 +123,7 @@ endif()
add_dependencies( pcb_calculator pcb_calculator_kiface ) add_dependencies( pcb_calculator pcb_calculator_kiface )
# these 2 binaries are a matched set, keep them together # these 2 binaries are a matched set, keep them together
if( APPLE ) if( KICAD_MACOSX_APP_BUNDLE )
set_target_properties( pcb_calculator PROPERTIES set_target_properties( pcb_calculator PROPERTIES
MACOSX_BUNDLE_INFO_PLIST ${PROJECT_BINARY_DIR}/pcb_calculator/Info.plist MACOSX_BUNDLE_INFO_PLIST ${PROJECT_BINARY_DIR}/pcb_calculator/Info.plist
) )

View File

@ -586,7 +586,7 @@ set_source_files_properties( dialogs/panel_setup_rules.cpp
OBJECT_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/panel_setup_rules_help_md.h OBJECT_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/panel_setup_rules_help_md.h
) )
if( APPLE ) if( KICAD_MACOSX_APP_BUNDLE )
# setup bundle # setup bundle
set( PCBNEW_RESOURCES pcbnew.icns pcbnew_doc.icns ) set( PCBNEW_RESOURCES pcbnew.icns pcbnew_doc.icns )
set_source_files_properties( "${CMAKE_CURRENT_SOURCE_DIR}/pcbnew.icns" PROPERTIES set_source_files_properties( "${CMAKE_CURRENT_SOURCE_DIR}/pcbnew.icns" PROPERTIES
@ -626,6 +626,10 @@ target_link_libraries( pcbnew
${wxWidgets_LIBRARIES} ${wxWidgets_LIBRARIES}
) )
set_target_properties( pcbnew PROPERTIES
MACOSX_BUNDLE $<BOOL:KICAD_MACOSX_APP_BUNDLE>
)
if( PCBNEW_LINK_MAPS ) if( PCBNEW_LINK_MAPS )
set_target_properties( pcbnew PROPERTIES set_target_properties( pcbnew PROPERTIES
LINK_FLAGS "-Wl,-cref,-Map=pcbnew.map" ) LINK_FLAGS "-Wl,-cref,-Map=pcbnew.map" )
@ -739,7 +743,7 @@ if( WIN32 )
endif() endif()
# these 2 binaries are a matched set, keep them together: # these 2 binaries are a matched set, keep them together:
if( APPLE ) if( KICAD_MACOSX_APP_BUNDLE )
set_target_properties( pcbnew PROPERTIES set_target_properties( pcbnew PROPERTIES
MACOSX_BUNDLE_INFO_PLIST ${PROJECT_BINARY_DIR}/pcbnew/Info.plist MACOSX_BUNDLE_INFO_PLIST ${PROJECT_BINARY_DIR}/pcbnew/Info.plist
) )
@ -787,7 +791,7 @@ if( KICAD_WIN32_INSTALL_PDBS )
install(FILES $<TARGET_PDB_FILE:pcbnew_kiface> DESTINATION ${KICAD_BIN}) install(FILES $<TARGET_PDB_FILE:pcbnew_kiface> DESTINATION ${KICAD_BIN})
endif() endif()
if( NOT APPLE ) if( NOT KICAD_MACOSX_APP_BUNDLE )
install( FILES ${CMAKE_BINARY_DIR}/pcbnew/pcbnew.py DESTINATION ${PYTHON_DEST} ) install( FILES ${CMAKE_BINARY_DIR}/pcbnew/pcbnew.py DESTINATION ${PYTHON_DEST} )
else() else()
# put into bundle at build time, it is relocated at install # put into bundle at build time, it is relocated at install
@ -812,7 +816,7 @@ install( DIRECTORY ${PROJECT_SOURCE_DIR}/pcbnew/python/plugins/
if( MINGW OR VCPKG_TOOLCHAIN ) if( MINGW OR VCPKG_TOOLCHAIN )
install( FILES ${CMAKE_BINARY_DIR}/pcbnew/_pcbnew.pyd DESTINATION ${PYTHON_DEST} ) install( FILES ${CMAKE_BINARY_DIR}/pcbnew/_pcbnew.pyd DESTINATION ${PYTHON_DEST} )
set( PYMOD_EXT "pyd" ) set( PYMOD_EXT "pyd" )
elseif( APPLE ) elseif( KICAD_MACOSX_APP_BUNDLE )
# put everything into bundle at build time, it is relocated at install # put everything into bundle at build time, it is relocated at install
add_custom_target( ScriptingModulesPcbnewSoCopy ALL add_custom_target( ScriptingModulesPcbnewSoCopy ALL
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/pcbnew/_pcbnew.so" "${PYTHON_DEST}/" COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/pcbnew/_pcbnew.so" "${PYTHON_DEST}/"
@ -826,7 +830,7 @@ else() # only linux remains among supported platforms
set( PYMOD_EXT "so" ) set( PYMOD_EXT "so" )
endif() endif()
if( APPLE ) if( KICAD_MACOSX_APP_BUNDLE )
add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/_pcbnew.${PYMOD_EXT} add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/_pcbnew.${PYMOD_EXT}
DEPENDS pcbnew_kiface DEPENDS pcbnew_kiface
COMMAND ${CMAKE_COMMAND} -E copy ${OSX_BUNDLE_BUILD_KIFACE_DIR}/_pcbnew.kiface _pcbnew.${PYMOD_EXT} COMMAND ${CMAKE_COMMAND} -E copy ${OSX_BUNDLE_BUILD_KIFACE_DIR}/_pcbnew.kiface _pcbnew.${PYMOD_EXT}
@ -850,7 +854,7 @@ else()
endif() endif()
if( APPLE ) if( KICAD_MACOSX_APP_BUNDLE )
# If we don't have wxPython, then we must create the site-packages directory # If we don't have wxPython, then we must create the site-packages directory
add_custom_target( ScriptingPythonDirectoryCreation ALL add_custom_target( ScriptingPythonDirectoryCreation ALL
COMMAND ${CMAKE_COMMAND} -E make_directory "${PYTHON_DEST}" COMMAND ${CMAKE_COMMAND} -E make_directory "${PYTHON_DEST}"

View File

@ -29,7 +29,7 @@ target_link_libraries( s3d_plugin_idf
${OPENGL_LIBRARIES} ${OPENGL_LIBRARIES}
${wxWidgets_LIBRARIES} ) ${wxWidgets_LIBRARIES} )
if( APPLE ) if( KICAD_MACOSX_APP_BUNDLE )
# puts library into the main kicad.app bundle in build tree # puts library into the main kicad.app bundle in build tree
set_target_properties( s3d_plugin_idf PROPERTIES set_target_properties( s3d_plugin_idf PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${OSX_BUNDLE_BUILD_PLUGIN_DIR}/3d" LIBRARY_OUTPUT_DIRECTORY "${OSX_BUNDLE_BUILD_PLUGIN_DIR}/3d"

View File

@ -23,7 +23,7 @@ target_include_directories( s3d_plugin_oce PRIVATE
$<TARGET_PROPERTY:gzip-hpp,INTERFACE_INCLUDE_DIRECTORIES> $<TARGET_PROPERTY:gzip-hpp,INTERFACE_INCLUDE_DIRECTORIES>
) )
if( APPLE ) if( KICAD_MACOSX_APP_BUNDLE )
# puts library into the main kicad.app bundle in build tree # puts library into the main kicad.app bundle in build tree
set_target_properties( s3d_plugin_oce PROPERTIES set_target_properties( s3d_plugin_oce PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${OSX_BUNDLE_BUILD_PLUGIN_DIR}/3d" LIBRARY_OUTPUT_DIRECTORY "${OSX_BUNDLE_BUILD_PLUGIN_DIR}/3d"

View File

@ -71,7 +71,7 @@ target_include_directories( s3d_plugin_vrml PRIVATE
$<TARGET_PROPERTY:gzip-hpp,INTERFACE_INCLUDE_DIRECTORIES> $<TARGET_PROPERTY:gzip-hpp,INTERFACE_INCLUDE_DIRECTORIES>
) )
if( APPLE ) if( KICAD_MACOSX_APP_BUNDLE )
# puts library into the main kicad.app bundle in build tree # puts library into the main kicad.app bundle in build tree
set_target_properties( s3d_plugin_vrml PROPERTIES set_target_properties( s3d_plugin_vrml PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${OSX_BUNDLE_BUILD_PLUGIN_DIR}/3d" LIBRARY_OUTPUT_DIRECTORY "${OSX_BUNDLE_BUILD_PLUGIN_DIR}/3d"

View File

@ -62,7 +62,7 @@ if( MAKE_LINK_MAPS )
LINK_FLAGS "-Wl,-cref,-Map=_scripting.kiface.map" ) LINK_FLAGS "-Wl,-cref,-Map=_scripting.kiface.map" )
endif() endif()
if( APPLE ) if( KICAD_MACOSX_APP_BUNDLE )
set_target_properties( scripting_kiface PROPERTIES set_target_properties( scripting_kiface PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${OSX_BUNDLE_BUILD_KIFACE_DIR} LIBRARY_OUTPUT_DIRECTORY ${OSX_BUNDLE_BUILD_KIFACE_DIR}
) )

View File

@ -154,7 +154,7 @@ bool SCRIPTING::scriptingSetup()
wxSetEnv( wxT( "PATH" ), kipython ); wxSetEnv( wxT( "PATH" ), kipython );
} }
#endif #endif
#elif defined( __WXMAC__ ) #elif defined( __MACOSX_APP__ )
// Add default paths to PYTHONPATH // Add default paths to PYTHONPATH
wxString pypath; wxString pypath;

View File

@ -1,7 +1,7 @@
if( UNIX AND KICAD_I18N_UNIX_STRICT_PATH ) if( UNIX AND KICAD_I18N_UNIX_STRICT_PATH )
set( KICAD_I18N_PATH ${CMAKE_INSTALL_PREFIX}/share/locale set( KICAD_I18N_PATH ${CMAKE_INSTALL_PREFIX}/share/locale
CACHE PATH "Location of KiCad i18n files." ) CACHE PATH "Location of KiCad i18n files." )
elseif( APPLE ) elseif( KICAD_MACOSX_APP_BUNDLE )
set( KICAD_I18N_PATH ${KICAD_DATA}/internat set( KICAD_I18N_PATH ${KICAD_DATA}/internat
CACHE PATH "Location of KiCad i18n files." ) CACHE PATH "Location of KiCad i18n files." )
else() else()

View File

@ -42,7 +42,7 @@ target_link_libraries( idf2vrml
${wxWidgets_LIBRARIES} ${wxWidgets_LIBRARIES}
) )
if( APPLE ) if( KICAD_MACOSX_APP_BUNDLE )
# puts binaries into the *.app bundle while linking # puts binaries into the *.app bundle while linking
set_target_properties( idfcyl idfrect dxf2idf idf2vrml PROPERTIES set_target_properties( idfcyl idfrect dxf2idf idf2vrml PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${OSX_BUNDLE_BUILD_BIN_DIR} RUNTIME_OUTPUT_DIRECTORY ${OSX_BUNDLE_BUILD_BIN_DIR}

View File

@ -59,7 +59,7 @@ target_include_directories( kicad2step_lib PRIVATE
set_target_properties( kicad2step_bin set_target_properties( kicad2step_bin
PROPERTIES OUTPUT_NAME kicad2step) PROPERTIES OUTPUT_NAME kicad2step)
if( APPLE ) if( KICAD_MACOSX_APP_BUNDLE )
# puts binaries into the *.app bundle while linking # puts binaries into the *.app bundle while linking
set_target_properties( kicad2step_bin PROPERTIES set_target_properties( kicad2step_bin PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${OSX_BUNDLE_BUILD_BIN_DIR} RUNTIME_OUTPUT_DIRECTORY ${OSX_BUNDLE_BUILD_BIN_DIR}