diff --git a/CMakeLists.txt b/CMakeLists.txt index 03d31e2..57c7a00 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -86,10 +86,13 @@ set(SOURCES add_executable(${PROJECT_NAME} ${SOURCES}) +set(windows_api "") + if(WIN32 AND MSVC) # Limit assets embeding to msvc compilers only # such as clang-cl and MSVC (there exists no compiler of msvc flags # in the market except these two. Clang-cl is peak tho) target_sources(${PROJECT_NAME} PRIVATE assets/resource.rc) + set(windows_api "kernel32.lib") endif() target_compile_definitions(${PROJECT_NAME} PRIVATE @@ -102,9 +105,19 @@ target_include_directories(${PROJECT_NAME} "${CMAKE_CURRENT_BINARY_DIR}/third_party" ) +if(WIN32) target_link_libraries(${PROJECT_NAME} PRIVATE + ${windows_api} nlohmann_json::nlohmann_json ftxui::ftxui OpenSSL::SSL OpenSSL::Crypto ) +else() +target_link_libraries(${PROJECT_NAME} PRIVATE + nlohmann_json::nlohmann_json + ftxui::ftxui + OpenSSL::SSL + OpenSSL::Crypto +) +endif() diff --git a/src/settings_manager.cpp b/src/settings_manager.cpp index 6425846..f9ded0f 100644 --- a/src/settings_manager.cpp +++ b/src/settings_manager.cpp @@ -22,6 +22,11 @@ #include #include + +#ifdef _WIN32 +#include +#endif + settings_manager::settings_manager() { load(); } @@ -49,9 +54,13 @@ void settings_manager::set_logo(logo_style style) { std::string settings_manager::get_config_dir() const { #ifdef _WIN32 // win32 default appdata - const char* appdata = std::getenv("APPDATA"); + char* appdata = new char[MAX_PATH]; // MAX_PATH from windows + GetEnvironmentVariableA("APPDATA", appdata, MAX_PATH); if (appdata) { - return std::string(appdata) + "/tpedia"; + std::string temp(appdata); + temp += "/tpedia"; + delete appdata; + return temp; } return "./tpedia_config"; #elif defined(__APPLE__) @@ -118,4 +127,4 @@ void settings_manager::save() { settings_manager::logo_style settings_manager::logo() { return lgo; -} \ No newline at end of file +}