Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
15 changes: 12 additions & 3 deletions src/settings_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
#include <filesystem>
#include <cstdlib>


#ifdef _WIN32
#include <windows.h>
#endif

settings_manager::settings_manager() {
load();
}
Expand Down Expand Up @@ -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__)
Expand Down Expand Up @@ -118,4 +127,4 @@ void settings_manager::save() {

settings_manager::logo_style settings_manager::logo() {
return lgo;
}
}
Loading