--- 3d-viewer/3d_cache/3d_plugin_manager.cpp +++ 3d-viewer/3d_cache/3d_plugin_manager.cpp @@ -124,7 +124,7 @@ std::list pluginlist; wxFileName fn; -#ifndef __WXMAC__ +#ifndef __MACOSX_APP__ if( wxGetEnv( wxT( "KICAD_RUN_FROM_BUILD_DIR" ), nullptr ) ) { // set up to work from the build directory --- 3d-viewer/3d_cache/sg/CMakeLists.txt +++ 3d-viewer/3d_cache/sg/CMakeLists.txt @@ -35,7 +35,7 @@ endif( MINGW ) 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 set_target_properties( kicad_3dsg PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${OSX_BUNDLE_BUILD_LIB_DIR}" --- CMakeLists.txt +++ CMakeLists.txt @@ -207,6 +207,11 @@ endif() endif() +cmake_dependent_option( KICAD_MACOSX_APP_BUNDLE + "Create macOS Application bundle" + ON "APPLE" + OFF ) + # Global setting: exports are explicit set( CMAKE_CXX_VISIBILITY_PRESET "hidden" ) set( CMAKE_VISIBILITY_INLINES_HIDDEN ON ) @@ -232,6 +237,10 @@ add_definitions( -DKICAD_WIN32_VERIFY_CODESIGN ) endif() +if ( KICAD_MACOSX_APP_BUNDLE ) + add_definitions ( -D__MACOSX_APP__ ) +endif() + # Ensure DEBUG is defined for all platforms in Debug builds # change to add_compile_definitions() after minimum required CMake version is 3.12 set_property( DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$:DEBUG> ) @@ -566,7 +575,7 @@ #================================================ # Locations for install targets. #================================================ -if( NOT APPLE ) +if( NOT KICAD_MACOSX_APP_BUNDLE ) # Everything without leading / is relative to CMAKE_INSTALL_PREFIX. if( WIN32 ) set( KICAD_BIN bin @@ -864,7 +873,7 @@ 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_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}" @@ -975,7 +984,7 @@ endif() endif() -if( APPLE ) +if( KICAD_MACOSX_APP_BUNDLE ) # Remove app bundles in ${KICAD_BIN} before installing anything new. # Must be defined before all includes so that it is executed first. install( CODE " --- bitmap2component/CMakeLists.txt +++ bitmap2component/CMakeLists.txt @@ -35,7 +35,7 @@ if( WIN32 ) endif() endif() -if( APPLE ) +if( KICAD_MACOSX_APP_BUNDLE ) # setup bundle set( BITMAP2COMPONENT_RESOURCES bitmap2component.icns ) set_source_files_properties( "${CMAKE_CURRENT_SOURCE_DIR}/bitmap2component.icns" PROPERTIES @@ -46,7 +46,7 @@ if( APPLE ) set( MACOSX_BUNDLE_NAME bitmap2component ) endif() -add_executable( bitmap2component WIN32 MACOSX_BUNDLE +add_executable( bitmap2component WIN32 ${BITMAP2COMPONENT_SRCS} ${BITMAP2COMPONENT_RESOURCES} ) @@ -57,9 +57,10 @@ target_link_libraries( bitmap2component potrace ) -if( APPLE ) +if( KICAD_MACOSX_APP_BUNDLE ) set_target_properties( bitmap2component PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${PROJECT_BINARY_DIR}/bitmap2component/Info.plist + MACOSX_BUNDLE TRUE ) # put individual bundle outside of main bundle as a first step --- common/gestfich.cpp +++ common/gestfich.cpp @@ -54,7 +54,7 @@ { // Test the presence of the file in the directory shortname of // the KiCad binary path. -#ifndef __WXMAC__ +#ifndef __MACOSX_APP__ wxString fullFileName = Pgm().GetExecutablePath() + shortname; #else wxString fullFileName = Pgm().GetExecutablePath() + wxT( "Contents/MacOS/" ) + shortname; @@ -80,7 +80,7 @@ // Path list for KiCad binary files const static wxChar* possibilities[] = { -#if defined( __WXMAC__ ) +#if defined( __MACOSX_APP__ ) // all internal paths are relative to main bundle kicad.app wxT( "Contents/Applications/pcbnew.app/Contents/MacOS/" ), wxT( "Contents/Applications/eeschema.app/Contents/MacOS/" ), @@ -99,7 +99,7 @@ // find binary file from possibilities list: for( unsigned i=0; i // lowercase or pretty case depending on platform -#if defined( __WXMAC__ ) || defined( __WXMSW__ ) +#if defined( __MACOSX_APP__ ) || defined( __WXMSW__ ) #define KICAD_PATH_STR wxT( "KiCad" ) #else #define KICAD_PATH_STR wxT( "kicad" ) @@ -154,7 +154,7 @@ if( aRespectRunFromBuildDir && wxGetEnv( wxT( "KICAD_RUN_FROM_BUILD_DIR" ), nullptr ) ) { // 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(); fn.RemoveLastDir(); @@ -170,7 +170,7 @@ } else { -#if defined( __WXMAC__ ) +#if defined( __MACOSX_APP__ ) path = GetOSXKicadDataDir(); #elif defined( __WXMSW__ ) path = getWindowsKiCadRoot() + wxT( "share/kicad" ); @@ -198,7 +198,7 @@ { wxString path; -#if defined( __WXMAC__ ) +#if defined( __MACOSX_APP__ ) path = GetOSXKicadMachineDataDir(); #elif defined( __WXMSW__ ) path = GetStockDataPath( false ); @@ -297,7 +297,7 @@ fn.Assign( tfname, "" ); fn.AppendDir( wxT( "kicad" ) ); fn.AppendDir( wxT( "plugins" ) ); -#elif defined( __WXMAC__ ) +#elif defined( __MACOSX_APP__ ) fn.Assign( wxStandardPaths::Get().GetPluginsDir(), wxEmptyString ); // This must be mapped to main bundle for everything but kicad.app @@ -363,7 +363,7 @@ { wxString path; -#if defined( __WXMAC__ ) +#if defined( __MACOSX_APP__ ) path = GetOSXKicadDataDir(); #elif defined( __WXMSW__ ) path = getWindowsKiCadRoot() + wxT( "share/doc/kicad" ); --- common/systemdirsappend.cpp +++ common/systemdirsappend.cpp @@ -53,7 +53,7 @@ // Otherwise don't set it. maybe.AddPaths( wxGetenv( wxT( "KICAD" ) ) ); -#ifdef __WXMAC__ +#ifdef __MACOSX_APP__ // Add the directory for the user-dependent, program specific data files. maybe.AddPaths( PATHS::GetOSXKicadUserDataDir() ); @@ -138,7 +138,7 @@ { wxFileName fn( maybe[i], wxEmptyString ); -#ifndef __WXMAC__ +#ifndef __MACOSX_APP__ if( fn.GetPath().AfterLast( fn.GetPathSeparator() ) == wxT( "bin" ) ) { fn.RemoveLastDir(); @@ -150,7 +150,7 @@ aSearchStack->AddPaths( fn.GetPath() ); -#ifndef __WXMAC__ +#ifndef __MACOSX_APP__ fn.AppendDir( wxT( "kicad" ) ); aSearchStack->AddPaths( fn.GetPath() ); // add maybe[i]/kicad --- cvpcb/CMakeLists.txt +++ cvpcb/CMakeLists.txt @@ -100,7 +100,7 @@ endif() # 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 set_target_properties( cvpcb_kiface PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${OSX_BUNDLE_BUILD_KIFACE_DIR} --- eeschema/CMakeLists.txt +++ eeschema/CMakeLists.txt @@ -410,7 +410,7 @@ OBJECT_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/sch_text_help_md.h ) -if( APPLE ) +if( KICAD_MACOSX_APP_BUNDLE ) # setup bundle set( EESCHEMA_RESOURCES eeschema.icns eeschema_doc.icns ) set_source_files_properties( "${CMAKE_CURRENT_SOURCE_DIR}/eeschema.icns" PROPERTIES @@ -425,7 +425,7 @@ endif() -add_executable( eeschema WIN32 MACOSX_BUNDLE +add_executable( eeschema WIN32 ${CMAKE_SOURCE_DIR}/common/single_top.cpp ${CMAKE_SOURCE_DIR}/common/pgm_base.cpp ${EESCHEMA_RESOURCES} @@ -529,9 +529,10 @@ endif() # these 2 binaries are a matched set, keep them together: -if( APPLE ) +if( KICAD_MACOSX_APP_BUNDLE ) set_target_properties( eeschema PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${PROJECT_BINARY_DIR}/eeschema/Info.plist + MACOSX_BUNDLE TRUE ) # puts binaries into the *.app bundle while linking --- eeschema/sim/ngspice.cpp +++ eeschema/sim/ngspice.cpp @@ -443,7 +443,7 @@ #else const std::vector dllPaths = { "", "/mingw64/bin", "/mingw32/bin" }; #endif +#elif defined(__MACOSX_APP__) -#elif defined(__WXMAC__) const std::vector dllPaths = { PATHS::GetOSXKicadUserDataDir().ToStdString() + "/PlugIns/ngspice", PATHS::GetOSXKicadMachineDataDir().ToStdString() + "/PlugIns/ngspice", --- gerbview/CMakeLists.txt +++ gerbview/CMakeLists.txt @@ -85,7 +85,7 @@ endif() endif() -if( APPLE ) +if( KICAD_MACOSX_APP_BUNDLE ) # setup bundle set( GERBVIEW_RESOURCES gerbview.icns gerbview_doc.icns ) set_source_files_properties( "${CMAKE_CURRENT_SOURCE_DIR}/gerbview.icns" PROPERTIES @@ -99,7 +99,7 @@ set( MACOSX_BUNDLE_NAME gerbview ) endif() -add_executable( gerbview WIN32 MACOSX_BUNDLE +add_executable( gerbview WIN32 ${CMAKE_SOURCE_DIR}/common/single_top.cpp ${CMAKE_SOURCE_DIR}/common/pgm_base.cpp ${GERBVIEW_RESOURCES} @@ -173,9 +173,10 @@ add_dependencies( gerbview gerbview_kiface ) # these 2 binaries are a matched set, keep them together -if( APPLE ) +if( KICAD_MACOSX_APP_BUNDLE ) set_target_properties( gerbview PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${PROJECT_BINARY_DIR}/gerbview/Info.plist + MACOSX_BUNDLE TRUE ) # puts binaries into the *.app bundle while linking --- kicad/CMakeLists.txt +++ kicad/CMakeLists.txt @@ -63,7 +63,7 @@ endif() endif() -if( APPLE ) +if( KICAD_MACOSX_APP_BUNDLE ) set( KICAD_RESOURCES kicad.icns kicad_doc.icns ) set_source_files_properties( "${CMAKE_CURRENT_SOURCE_DIR}/kicad.icns" PROPERTIES MACOSX_PACKAGE_LOCATION Resources @@ -76,7 +76,7 @@ set( MACOSX_BUNDLE_NAME kicad ) endif() -add_executable( kicad WIN32 MACOSX_BUNDLE +add_executable( kicad WIN32 kicad.cpp ${KICAD_SRCS} ${KICAD_EXTRA_SRCS} @@ -110,9 +110,10 @@ ) endif() -if( APPLE ) +if( KICAD_MACOSX_APP_BUNDLE ) set_target_properties( kicad PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${PROJECT_BINARY_DIR}/kicad/Info.plist + MACOSX_BUNDLE TRUE ) target_link_libraries( kicad nlohmann_json @@ -175,7 +176,7 @@ install(FILES $ DESTINATION ${KICAD_BIN}) endif() -if( APPLE ) +if( KICAD_MACOSX_APP_BUNDLE ) # "install( CODE ... )" will launch its own CMake, so no variables from # this CMake instance are accessible... use helper to transfer set( SCRIPTING_HELPER "1" ) --- kicad/tools/kicad_manager_control.cpp +++ kicad/tools/kicad_manager_control.cpp @@ -866,7 +866,7 @@ int KICAD_MANAGER_CONTROL::Execute( const TOOL_EVENT& aEvent ) if( pid > 0 ) { -#ifdef __WXMAC__ +#ifdef __MACOSX_APP__ // This non-parameterized use of wxExecute is fine because execFile is not derived // from user input. wxExecute( "osascript -e 'activate application \"" + execFile + "\"'" ); --- pagelayout_editor/CMakeLists.txt +++ pagelayout_editor/CMakeLists.txt @@ -57,7 +57,7 @@ if( WIN32 ) endif() -if( APPLE ) +if( KICAD_MACOSX_APP_BUNDLE ) # setup bundle set( PL_EDITOR_RESOURCES pagelayout_editor.icns pagelayout_editor_doc.icns ) set_source_files_properties( "${CMAKE_CURRENT_SOURCE_DIR}/pagelayout_editor.icns" PROPERTIES @@ -72,7 +72,7 @@ if( APPLE ) endif() # a very small program launcher for pl_editor_kiface -add_executable( pl_editor WIN32 MACOSX_BUNDLE +add_executable( pl_editor WIN32 ${CMAKE_SOURCE_DIR}/common/single_top.cpp ${CMAKE_SOURCE_DIR}/common/pgm_base.cpp ${PL_EDITOR_RESOURCES} @@ -129,9 +129,10 @@ endif() add_dependencies( pl_editor pl_editor_kiface ) # these 2 binaries are a matched set, keep them together: -if( APPLE ) +if( KICAD_MACOSX_APP_BUNDLE ) set_target_properties( pl_editor PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${PROJECT_BINARY_DIR}/pagelayout_editor/Info.plist + MACOSX_BUNDLE TRUE ) # puts binaries into the *.app bundle while linking --- pcb_calculator/CMakeLists.txt +++ pcb_calculator/CMakeLists.txt @@ -66,7 +66,7 @@ endif() endif() -if( APPLE ) +if( KICAD_MACOSX_APP_BUNDLE ) # setup bundle set( PCB_CALCULATOR_RESOURCES pcb_calculator.icns ) set_source_files_properties( "${CMAKE_CURRENT_SOURCE_DIR}/pcb_calculator.icns" PROPERTIES @@ -77,7 +77,7 @@ set( MACOSX_BUNDLE_NAME pcb_calculator ) endif() -add_executable( pcb_calculator WIN32 MACOSX_BUNDLE +add_executable( pcb_calculator WIN32 ${CMAKE_SOURCE_DIR}/common/single_top.cpp ${CMAKE_SOURCE_DIR}/common/pgm_base.cpp ${PCB_CALCULATOR_RESOURCES} @@ -127,9 +127,10 @@ add_dependencies( pcb_calculator pcb_calculator_kiface ) # these 2 binaries are a matched set, keep them together -if( APPLE ) +if( KICAD_MACOSX_APP_BUNDLE ) set_target_properties( pcb_calculator PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${PROJECT_BINARY_DIR}/pcb_calculator/Info.plist + MACOSX_BUNDLE TRUE ) # puts binaries into the *.app bundle while linking --- pcbnew/CMakeLists.txt +++ pcbnew/CMakeLists.txt @@ -571,7 +571,7 @@ OBJECT_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/panel_setup_rules_help_md.h ) -if( APPLE ) +if( KICAD_MACOSX_APP_BUNDLE ) # setup bundle set( PCBNEW_RESOURCES pcbnew.icns pcbnew_doc.icns ) set_source_files_properties( "${CMAKE_CURRENT_SOURCE_DIR}/pcbnew.icns" PROPERTIES @@ -594,7 +594,7 @@ set( PCBNEW_IO_LIBRARIES pcad2kicadpcb altium2pcbnew cadstar2pcbnew fabmaster CACHE INTERNAL "") # a very small program launcher for pcbnew_kiface -add_executable( pcbnew WIN32 MACOSX_BUNDLE +add_executable( pcbnew WIN32 ${CMAKE_SOURCE_DIR}/common/single_top.cpp ${PCBNEW_RESOURCES} ) @@ -727,9 +727,10 @@ endif() # these 2 binaries are a matched set, keep them together: -if( APPLE ) +if( KICAD_MACOSX_APP_BUNDLE ) set_target_properties( pcbnew PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${PROJECT_BINARY_DIR}/pcbnew/Info.plist + MACOSX_BUNDLE TRUE ) # puts binaries into the *.app bundle while linking @@ -775,7 +776,7 @@ install(FILES $ DESTINATION ${KICAD_KIFACE}) endif() -if( NOT APPLE ) +if( NOT KICAD_MACOSX_APP_BUNDLE ) install( FILES ${CMAKE_BINARY_DIR}/pcbnew/pcbnew.py DESTINATION ${PYTHON_DEST} ) else() # put into bundle at build time, it is relocated at install @@ -800,7 +801,7 @@ if( WIN32 ) install( FILES ${CMAKE_BINARY_DIR}/pcbnew/_pcbnew.pyd DESTINATION ${PYTHON_DEST} ) set( PYMOD_EXT "pyd" ) -elseif( APPLE ) +elseif( KICAD_MACOSX_APP_BUNDLE ) # put everything into bundle at build time, it is relocated at install add_custom_target( ScriptingModulesPcbnewSoCopy ALL COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/pcbnew/_pcbnew.so" "${PYTHON_DEST}/" @@ -816,7 +817,7 @@ install( FILES ${CMAKE_CURRENT_BINARY_DIR}/python/_pcbnew.${PYMOD_EXT} DESTINATION ${PYTHON_DEST} ) endif() -if( APPLE ) +if( KICAD_MACOSX_APP_BUNDLE ) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/_pcbnew.${PYMOD_EXT} DEPENDS pcbnew_kiface COMMAND ${CMAKE_COMMAND} -E copy ${OSX_BUNDLE_BUILD_KIFACE_DIR}/_pcbnew.kiface _pcbnew.${PYMOD_EXT} @@ -870,7 +871,7 @@ ) -if( APPLE ) +if( KICAD_MACOSX_APP_BUNDLE ) # If we don't have wxPython, then we must create the site-packages directory add_custom_target( ScriptingPythonDirectoryCreation ALL COMMAND ${CMAKE_COMMAND} -E make_directory "${PYTHON_DEST}" --- plugins/3d/idf/CMakeLists.txt +++ plugins/3d/idf/CMakeLists.txt @@ -29,7 +29,7 @@ target_link_libraries( s3d_plugin_idf ${OPENGL_LIBRARIES} ${wxWidgets_LIBRARIES} ) -if( APPLE ) +if( KICAD_MACOSX_APP_BUNDLE ) # puts library into the main kicad.app bundle in build tree set_target_properties( s3d_plugin_idf PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${OSX_BUNDLE_BUILD_PLUGIN_DIR}/3d" --- plugins/3d/oce/CMakeLists.txt +++ plugins/3d/oce/CMakeLists.txt @@ -23,7 +23,7 @@ target_include_directories( s3d_plugin_oce PRIVATE $ ) -if( APPLE ) +if( KICAD_MACOSX_APP_BUNDLE ) # puts library into the main kicad.app bundle in build tree set_target_properties( s3d_plugin_oce PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${OSX_BUNDLE_BUILD_PLUGIN_DIR}/3d" --- plugins/3d/vrml/CMakeLists.txt +++ plugins/3d/vrml/CMakeLists.txt @@ -71,7 +71,7 @@ target_include_directories( s3d_plugin_vrml PRIVATE $ ) -if( APPLE ) +if( KICAD_MACOSX_APP_BUNDLE ) # puts library into the main kicad.app bundle in build tree set_target_properties( s3d_plugin_vrml PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${OSX_BUNDLE_BUILD_PLUGIN_DIR}/3d" --- scripting/CMakeLists.txt +++ scripting/CMakeLists.txt @@ -66,7 +66,7 @@ if( MAKE_LINK_MAPS ) LINK_FLAGS "-Wl,-cref,-Map=_scripting.kiface.map" ) endif() -if( APPLE ) +if( KICAD_MACOSX_APP_BUNDLE ) set_target_properties( scripting_kiface PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${OSX_BUNDLE_BUILD_KIFACE_DIR} ) --- scripting/python_scripting.cpp +++ scripting/python_scripting.cpp @@ -253,7 +253,7 @@ wxSetEnv( wxT( "PATH" ), kipython ); } #endif -#elif defined( __WXMAC__ ) +#elif defined( __MACOSX_APP__ ) // Prevent Mac builds from generating JIT versions as this will break // the package signing --- translation/CMakeLists.txt +++ translation/CMakeLists.txt @@ -1,7 +1,7 @@ if( UNIX AND KICAD_I18N_UNIX_STRICT_PATH ) set( KICAD_I18N_PATH ${CMAKE_INSTALL_PREFIX}/share/locale CACHE PATH "Location of KiCad i18n files." ) -elseif( APPLE ) +elseif( KICAD_MACOSX_APP_BUNDLE ) set( KICAD_I18N_PATH ${KICAD_DATA}/internat CACHE PATH "Location of KiCad i18n files." ) else() --- utils/idftools/CMakeLists.txt +++ utils/idftools/CMakeLists.txt @@ -42,7 +42,7 @@ target_link_libraries( idf2vrml ${wxWidgets_LIBRARIES} ) -if( APPLE ) +if( KICAD_MACOSX_APP_BUNDLE ) # puts binaries into the *.app bundle while linking set_target_properties( idfcyl idfrect dxf2idf idf2vrml PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${OSX_BUNDLE_BUILD_BIN_DIR}