Final work on MacOS compatibility

This commit is contained in:
Alexandre
2021-11-15 20:33:09 -06:00
parent 49cf6944f0
commit b81d0c47cf
13 changed files with 224 additions and 35 deletions

View File

@ -102,6 +102,12 @@ static void maximized_callback(GLFWwindow* window, int n) {
int sdrpp_main(int argc, char *argv[]) {
spdlog::info("SDR++ v" VERSION_STR);
#ifdef MACOS_DOTAPP
// If this is a MacOS .app, CD to the correct directory
auto execPath = std::filesystem::absolute(argv[0]);
chdir(execPath.parent_path().string().c_str());
#endif
// Load default options and parse command line
options::loadDefaults();
if (!options::parse(argc, argv)) { return -1; }
@ -239,9 +245,12 @@ int sdrpp_main(int argc, char *argv[]) {
defConfig["vfoColors"]["Radio"] = "#FFFFFF";
#ifdef _WIN32
#if defined(_WIN32)
defConfig["modulesDirectory"] = "./modules";
defConfig["resourcesDirectory"] = "./res";
#elif defined(MACOS_DOTAPP)
defConfig["modulesDirectory"] = "../Plugins";
defConfig["resourcesDirectory"] = "../Resources";
#else
defConfig["modulesDirectory"] = INSTALL_PREFIX "/lib/sdrpp/plugins";
defConfig["resourcesDirectory"] = INSTALL_PREFIX "/share/sdrpp";

View File

@ -6,9 +6,12 @@ namespace options {
CMDLineOptions opts;
void loadDefaults() {
#ifdef _WIN32
#if defined(_WIN32)
opts.root = ".";
opts.showConsole = false;
#elif defined(MACOS_DOTAPP)
std::string homedir = getenv("HOME");
opts.root = homedir + "/Library/Application Support/sdrpp";
#else
std::string homedir = getenv("HOME");
opts.root = homedir + "/.config/sdrpp";