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

@@ -5,6 +5,10 @@ if (USE_INTERNAL_LIBCORRECT)
add_subdirectory("libcorrect/")
endif (USE_INTERNAL_LIBCORRECT)
if (USE_DOTAPP_DEFAULTS)
add_definitions(-DMACOS_DOTAPP)
endif (USE_DOTAPP_DEFAULTS)
# Main code
file(GLOB_RECURSE SRC "src/*.cpp" "src/*.c")
@@ -25,7 +29,6 @@ else ()
target_compile_options(sdrpp_core PRIVATE -O3 -std=c++17)
endif ()
# Set the install prefix
target_compile_definitions(sdrpp_core PUBLIC INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}")

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";