diff --git a/CMakeLists.txt b/CMakeLists.txt index fb83af5e..2565ca23 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,8 @@ option(GLFW_BUILD_TESTS "Build the GLFW test programs" ON) option(BUILD_SHARED_LIBS "Build shared libraries" OFF) if (APPLE) - option(GLFW_CD_RESOURCES "Make glfwInit chdir to Contents/Resources" ON) + option(GLFW_USE_CHDIR "Make glfwInit chdir to Contents/Resources" ON) + option(GLFW_USE_MENUBAR "Populate the menu bar on first window creation" ON) else() option(GLFW_USE_EGL "Use EGL for context creation" OFF) endif() @@ -288,8 +289,12 @@ if (_GLFW_COCOA AND _GLFW_NSGL) option(GLFW_BUILD_UNIVERSAL "Build GLFW as a Universal Binary" OFF) - if (GLFW_CD_RESOURCES) - set(_GLFW_CD_RESOURCES 1) + if (GLFW_USE_MENUBAR) + set(_GLFW_USE_MENUBAR 1) + endif() + + if (GLFW_USE_CHDIR) + set(_GLFW_USE_CHDIR 1) endif() # Universal build diff --git a/src/cocoa_init.m b/src/cocoa_init.m index 943ee702..fc82a656 100644 --- a/src/cocoa_init.m +++ b/src/cocoa_init.m @@ -34,7 +34,7 @@ // Change to our application bundle's resources directory, if present //======================================================================== -#if defined(_GLFW_CD_RESOURCES) +#if defined(_GLFW_USE_CHDIR) static void changeToResourcesDirectory(void) { @@ -70,7 +70,7 @@ static void changeToResourcesDirectory(void) chdir(resourcesPath); } -#endif /* _GLFW_CD_RESOURCES */ +#endif /* _GLFW_USE_CHDIR */ ////////////////////////////////////////////////////////////////////////// @@ -94,7 +94,7 @@ int _glfwPlatformInit(void) return GL_FALSE; } -#if defined(_GLFW_CD_RESOURCES) +#if defined(_GLFW_USE_CHDIR) changeToResourcesDirectory(); #endif diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 22a792ea..44e8fccd 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -581,6 +581,8 @@ static NSString* findAppName(void) // doesn't seem like a good thing to require of GLFW's clients. //======================================================================== +#if defined(_GLFW_USE_MENUBAR) + static void createMenuBar(void) { NSString* appName = findAppName(); @@ -640,6 +642,8 @@ static void createMenuBar(void) [NSApp performSelector:@selector(setAppleMenu:) withObject:appMenu]; } +#endif /* _GLFW_USE_MENUBAR */ + //======================================================================== // Initialize the Cocoa Application Kit @@ -653,10 +657,12 @@ static GLboolean initializeAppKit(void) // Implicitly create shared NSApplication instance [GLFWApplication sharedApplication]; +#if defined(_GLFW_USE_MENUBAR) // Menu bar setup must go between sharedApplication above and // finishLaunching below, in order to properly emulate the behavior // of NSApplicationMain createMenuBar(); +#endif [NSApp finishLaunching]; diff --git a/src/config.h.in b/src/config.h.in index b4f713d9..d7f19055 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -65,7 +65,7 @@ #cmakedefine _GLFW_HAS_GLXGETPROCADDRESSEXT // Define this to 1 if glfwInit should change the current directory -#cmakedefine _GLFW_CD_RESOURCES +#cmakedefine _GLFW_USE_CHDIR // Define this to 1 if using OpenGL as the client library #cmakedefine _GLFW_USE_OPENGL