Added an option to make a portable executable

This commit is contained in:
Yousef Khadadeh 2025-10-02 14:30:11 +03:00
parent 5070d0dd2d
commit c92edbe28b
2 changed files with 10 additions and 2 deletions

View file

@ -24,6 +24,7 @@ option(USE_MEMORYSAN "Enable Memory Sanitizer" OFF)
option(LINK_SKIA_MANUALLY "Link skia not as a package, but as separate libraries for non-Conan builds" OFF)
option(EMSCRIPTEN_SINGLE_HTML_FILE "Building with emscripten generates a single HTML file" OFF)
option(TBB_NOT_ONETBB "Use TBB::tbb package and not onetbb::onetbb package from conan" OFF)
option(CONFIG_NEXT_TO_EXECUTABLE "Place configuration folder next to executable (portable executable)" OFF)
# Setting sources
set(sources "src/main.cpp"
@ -250,6 +251,10 @@ if(WIN32)
target_compile_definitions(infinipaint PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX)
endif()
if(CONFIG_NEXT_TO_EXECUTABLE)
target_compile_definitions(infinipaint PRIVATE CONFIG_NEXT_TO_EXECUTABLE)
endif()
if(NOT EMSCRIPTEN AND ((GRAPHICS_BACKEND STREQUAL "OpenGL3.3") OR (GRAPHICS_BACKEND STREQUAL "OpenGLES3.0") OR (GRAPHICS_BACKEND STREQUAL "OpenGL2.1")))
find_package(OpenGL REQUIRED)
if(GRAPHICS_BACKEND STREQUAL "OpenGLES3.0")

View file

@ -333,8 +333,6 @@ const char* emscripten_before_unload(int eventType, const void *reserved, void *
#endif
void init_logs(MainStruct& mS) {
std::string CONFIG_FOLDER_NAME = "infinipaint";
mS.homePath = std::filesystem::current_path();
#ifdef __EMSCRIPTEN__
EM_ASM(
@ -352,7 +350,12 @@ void init_logs(MainStruct& mS) {
);
mS.homePath = std::filesystem::path("/");
mS.configPath = std::filesystem::path("/infinipaint");
#elif CONFIG_NEXT_TO_EXECUTABLE
std::string CONFIG_FOLDER_NAME = "config";
std::filesystem::create_directory(CONFIG_FOLDER_NAME);
mS.configPath = mS.homePath / CONFIG_FOLDER_NAME;
#else
std::string CONFIG_FOLDER_NAME = "infinipaint";
std::filesystem::path configHome(sago::getConfigHome());
std::filesystem::create_directory(configHome);
mS.configPath = configHome / CONFIG_FOLDER_NAME;