add global definitions for all paths

This commit is contained in:
AlexandreRouma
2024-08-25 21:40:01 +02:00
parent d5bc0fa3c3
commit d905d19020
5 changed files with 70 additions and 36 deletions

View File

@ -18,6 +18,10 @@ if (MSVC)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
endif ()
# Add compiler definitions for the directories
add_definitions(-DSDRPP_MODULES_LOAD_DIR=${SDRPP_MODULES_LOAD_DIR})
add_definitions(-DSDRPP_RES_LOAD_DIR=${SDRPP_RES_LOAD_DIR})
# Configure backend sources
if (OPT_BACKEND_GLFW)
file(GLOB_RECURSE BACKEND_SRC "backends/glfw/*.cpp" "backends/glfw/*.c")
@ -33,9 +37,6 @@ add_library(sdrpp_core SHARED ${SRC} ${BACKEND_SRC})
# Set compiler options
target_compile_options(sdrpp_core PRIVATE ${SDRPP_COMPILER_FLAGS})
# Set the install prefix
target_compile_definitions(sdrpp_core PUBLIC INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}")
# Include core headers
target_include_directories(sdrpp_core PUBLIC "src/")
target_include_directories(sdrpp_core PUBLIC "src/imgui")
@ -167,4 +168,4 @@ set(CORE_FILES ${RUNTIME_OUTPUT_DIRECTORY} PARENT_SCOPE)
# cmake .. "-DCMAKE_TOOLCHAIN_FILE=C:/dev/vcpkg/scripts/buildsystems/vcpkg.cmake"
# Install directives
install(TARGETS sdrpp_core DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(TARGETS sdrpp_core DESTINATION ${SDRPP_LIB_INSTALL_DIR})

View File

@ -24,14 +24,16 @@
#include <Windows.h>
#endif
#ifndef INSTALL_PREFIX
#ifdef __APPLE__
#define INSTALL_PREFIX "/usr/local"
#else
#define INSTALL_PREFIX "/usr"
// Default install dirs to make the IDE happy
#ifndef SDRPP_MODULES_LOAD_DIR
#define SDRPP_MODULES_LOAD_DIR ""
#endif
#ifndef SDRPP_RES_LOAD_DIR
#define SDRPP_RES_LOAD_DIR ""
#endif
namespace core {
ConfigManager configManager;
ModuleManager moduleManager;
@ -248,19 +250,14 @@ int sdrpp_main(int argc, char* argv[]) {
defConfig["lockMenuOrder"] = false;
#endif
#if defined(_WIN32)
defConfig["modulesDirectory"] = "./modules";
defConfig["resourcesDirectory"] = "./res";
#elif defined(IS_MACOS_BUNDLE)
defConfig["modulesDirectory"] = "../Plugins";
defConfig["resourcesDirectory"] = "../Resources";
#elif defined(__ANDROID__)
defConfig["modulesDirectory"] = root + "/modules";
defConfig["resourcesDirectory"] = root + "/res";
#if define(__ANDROID__)
defConfig["modulesDirectory"] = root + SDRPP_MODULES_LOAD_DIR;
defConfig["resourcesDirectory"] = root + SDRPP_RES_LOAD_DIR;
#else
defConfig["modulesDirectory"] = INSTALL_PREFIX "/lib/sdrpp/plugins";
defConfig["resourcesDirectory"] = INSTALL_PREFIX "/share/sdrpp";
defConfig["modulesDirectory"] = SDRPP_MODULES_LOAD_DIR;
defConfig["resourcesDirectory"] = SDRPP_RES_LOAD_DIR;
#endif
// Load config
flog::info("Loading config");