Make web browser app configurable through CMake (for Linux)
so package builders don't need local patches. Also, instead of hardcoded firefox, use "xdg-open" or "sensible-browser" launchers on Linux, to auto-detect user's preferred browser. Override with cmake switch -DWEB_BROWSER=... (Not affecting Mac/Win which are hard-coded anyway).
This commit is contained in:
parent
9c87aeb1fc
commit
59fe04f8e9
6 changed files with 38 additions and 28 deletions
|
@ -28,6 +28,7 @@ endif(InSourceBuild)
|
|||
|
||||
# System detection/default settings
|
||||
include( DetectDistro )
|
||||
include( DetectBrowser )
|
||||
|
||||
set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "add a postfix, usually d on windows")
|
||||
set(CMAKE_RELEASE_POSTFIX "" CACHE STRING "add a postfix, usually empty on windows")
|
||||
|
|
22
CMakeModules/DetectBrowser.cmake
Normal file
22
CMakeModules/DetectBrowser.cmake
Normal file
|
@ -0,0 +1,22 @@
|
|||
# DetectBrowser.cmake -- Detect web browser launcher application
|
||||
|
||||
# Set default command to open browser. Override with -DWEB_BROWSER=...
|
||||
if (APPLE OR MSVC)
|
||||
# opening the web browser is hardcoded for Mac and Windows,
|
||||
# so this doesn't really have an effect...
|
||||
set(WEB_BROWSER "open")
|
||||
else()
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
# "xdg-open" provides run-time detection of user's preferred browser on (most) Linux.
|
||||
if (NOT LINUX_DISTRO MATCHES "Debian")
|
||||
set(WEB_BROWSER "xdg-open" CACHE STRING "Command to open web browser")
|
||||
else()
|
||||
# Debian is different: "sensible-browser" provides auto-detection
|
||||
set(WEB_BROWSER "sensible-browser" CACHE STRING "Command to open web browser")
|
||||
endif()
|
||||
else()
|
||||
# Default for non Linux/non Mac/non Windows platform...
|
||||
set(WEB_BROWSER "firefox" CACHE STRING "Command to open web browser")
|
||||
endif()
|
||||
message(STATUS "Web browser launcher command is: ${WEB_BROWSER}")
|
||||
endif()
|
|
@ -192,22 +192,7 @@ bool openBrowser(string address)
|
|||
}
|
||||
|
||||
cocoaOpenUrl(address);
|
||||
return ok;
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32
|
||||
|
||||
string command = globals->get_browser();
|
||||
string::size_type pos;
|
||||
if ((pos = command.find("%u", 0)) != string::npos)
|
||||
command.replace(pos, 2, address);
|
||||
else
|
||||
command += " " + address;
|
||||
|
||||
command += " &";
|
||||
ok = (system( command.c_str() ) == 0);
|
||||
|
||||
#else // _WIN32
|
||||
#elif defined _WIN32
|
||||
|
||||
// Look for favorite browser
|
||||
char win32_name[1024];
|
||||
|
@ -218,7 +203,17 @@ bool openBrowser(string address)
|
|||
# endif
|
||||
ShellExecute ( NULL, "open", win32_name, NULL, NULL,
|
||||
SW_SHOWNORMAL ) ;
|
||||
#else
|
||||
// Linux, BSD, SGI etc
|
||||
string command = globals->get_browser();
|
||||
string::size_type pos;
|
||||
if ((pos = command.find("%u", 0)) != string::npos)
|
||||
command.replace(pos, 2, address);
|
||||
else
|
||||
command += " \"" + address +"\"";
|
||||
|
||||
command += " &";
|
||||
ok = (system( command.c_str() ) == 0);
|
||||
#endif
|
||||
|
||||
mkDialog("The file is shown in your web browser window.");
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#cmakedefine HAVE_LIBSVN_CLIENT_1
|
||||
|
||||
#define PKGLIBDIR "@FG_DATA_DIR@"
|
||||
#define WEB_BROWSER "@WEB_BROWSER@"
|
||||
|
||||
#cmakedefine FG_HAVE_HLA
|
||||
#cmakedefine FG_JPEG_SERVER
|
||||
|
|
|
@ -1028,7 +1028,9 @@ bool fgInitGeneral() {
|
|||
}
|
||||
SG_LOG( SG_GENERAL, SG_INFO, "FG_ROOT = " << '"' << root << '"' << endl );
|
||||
|
||||
globals->set_browser(fgGetString("/sim/startup/browser-app", "firefox %u"));
|
||||
// Note: browser command is hard-coded for Mac/Windows, so this only affects other platforms
|
||||
globals->set_browser(fgGetString("/sim/startup/browser-app", WEB_BROWSER));
|
||||
fgSetString("/sim/startup/browser-app", globals->get_browser());
|
||||
|
||||
simgear::Dir cwd(simgear::Dir::current());
|
||||
SGPropertyNode *curr = fgGetNode("/sim", true);
|
||||
|
|
|
@ -175,17 +175,6 @@ fgSetDefaults ()
|
|||
// fgSetString("/sim/startup/mouse-pointer", "disabled");
|
||||
fgSetString("/sim/control-mode", "joystick");
|
||||
fgSetBool("/controls/flight/auto-coordination", false);
|
||||
#if defined(WIN32)
|
||||
fgSetString("/sim/startup/browser-app", "webrun.bat");
|
||||
#elif defined(__APPLE__)
|
||||
fgSetString("/sim/startup/browser-app", "open");
|
||||
#elif defined(sgi)
|
||||
fgSetString("/sim/startup/browser-app", "launchWebJumper");
|
||||
#else
|
||||
const char* browserEnv = ::getenv( "WEBBROWSER" );
|
||||
if (!browserEnv) browserEnv = "netscape";
|
||||
fgSetString("/sim/startup/browser-app", browserEnv);
|
||||
#endif
|
||||
fgSetString("/sim/logging/priority", "alert");
|
||||
|
||||
// Features
|
||||
|
|
Loading…
Add table
Reference in a new issue