mirror of
https://github.com/obsqrbtz/clrsync.git
synced 2026-04-08 20:19:04 +03:00
create windows installed with nsis
This commit is contained in:
@@ -6,6 +6,14 @@ include(GNUInstallDirs)
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
if(WIN32)
|
||||
set(CMAKE_INSTALL_PREFIX "C:/Program Files/clrsync")
|
||||
set(CMAKE_INSTALL_BINDIR "bin")
|
||||
set(CMAKE_INSTALL_LIBDIR "lib")
|
||||
set(CMAKE_INSTALL_DATADIR "share")
|
||||
set(CMAKE_INSTALL_FULL_DATADIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}")
|
||||
endif()
|
||||
|
||||
set(CMAKE_SKIP_BUILD_RPATH FALSE)
|
||||
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
|
||||
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||
@@ -122,33 +130,78 @@ target_compile_definitions(imgui PUBLIC IMGUI_ENABLE_FREETYPE)
|
||||
|
||||
install(TARGETS clrsync_core
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
COMPONENT Core
|
||||
)
|
||||
|
||||
install(TARGETS clrsync_cli
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
COMPONENT CLI
|
||||
)
|
||||
|
||||
install(TARGETS clrsync_gui
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
COMPONENT GUI
|
||||
)
|
||||
|
||||
install(FILES
|
||||
example_config/config.toml
|
||||
DESTINATION ${CMAKE_INSTALL_DATADIR}/clrsync
|
||||
COMPONENT Core
|
||||
)
|
||||
|
||||
install(DIRECTORY example_config/templates
|
||||
DESTINATION ${CMAKE_INSTALL_DATADIR}/clrsync
|
||||
COMPONENT Core
|
||||
FILES_MATCHING PATTERN "*"
|
||||
)
|
||||
|
||||
install(DIRECTORY example_config/palettes
|
||||
DESTINATION ${CMAKE_INSTALL_DATADIR}/clrsync
|
||||
COMPONENT Core
|
||||
FILES_MATCHING PATTERN "*.toml"
|
||||
)
|
||||
|
||||
if(UNIX AND NOT APPLE)
|
||||
install(FILES resources/clrsync.desktop
|
||||
DESTINATION ${CMAKE_INSTALL_DATADIR}/applications
|
||||
COMPONENT Core
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE.txt")
|
||||
set(CPACK_COMPONENTS_ALL Core GUI CLI)
|
||||
|
||||
set(CPACK_PACKAGE_NAME "clrsync")
|
||||
set(CPACK_PACKAGE_VENDOR "Daniel Dada")
|
||||
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
|
||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Color scheme manager")
|
||||
|
||||
set(CPACK_COMPONENTS_ALL Core GUI CLI)
|
||||
set(CPACK_COMPONENT_CORE_DISPLAY_NAME "Core Library")
|
||||
set(CPACK_COMPONENT_CORE_DESCRIPTION "clrsync core library and default configs (required)")
|
||||
set(CPACK_COMPONENT_CORE_REQUIRED ON)
|
||||
set(CPACK_COMPONENT_GUI_DISPLAY_NAME "GUI Application")
|
||||
set(CPACK_COMPONENT_GUI_DESCRIPTION "clrsync GUI app")
|
||||
set(CPACK_COMPONENT_GUI_DEPENDS Core)
|
||||
set(CPACK_COMPONENT_CLI_DISPLAY_NAME "Command Line Tool")
|
||||
set(CPACK_COMPONENT_CLI_DESCRIPTION "clrsync CLI app")
|
||||
set(CPACK_COMPONENT_CLI_DEPENDS Core)
|
||||
|
||||
set(CPACK_GENERATOR "NSIS")
|
||||
|
||||
set(CPACK_NSIS_INSTALLED_NAME "clrsync")
|
||||
set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES64")
|
||||
|
||||
set(CPACK_NSIS_MODIFY_PATH ON)
|
||||
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
|
||||
|
||||
set(CPACK_NSIS_MENU_LINKS "bin/clrsync_gui.exe" "clrsync")
|
||||
set(CPACK_NSIS_CREATE_DESKTOP_LINKS "bin/clrsync_gui.exe;clrsync")
|
||||
|
||||
message(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
|
||||
message(STATUS "CMAKE_INSTALL_DATADIR: ${CMAKE_INSTALL_DATADIR}")
|
||||
message(STATUS "CMAKE_INSTALL_FULL_DATADIR: ${CMAKE_INSTALL_FULL_DATADIR}")
|
||||
message(STATUS "CMAKE_SIZEOF_VOID_P: ${CMAKE_SIZEOF_VOID_P}")
|
||||
|
||||
include(CPack)
|
||||
|
||||
@@ -5,6 +5,10 @@
|
||||
#include <filesystem>
|
||||
#include <stdexcept>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "windows.h"
|
||||
#endif
|
||||
|
||||
namespace clrsync::core
|
||||
{
|
||||
config &config::instance()
|
||||
@@ -33,10 +37,22 @@ std::filesystem::path config::get_user_config_dir()
|
||||
#endif
|
||||
}
|
||||
|
||||
std::filesystem::path config::get_data_dir() {
|
||||
#ifdef _WIN32
|
||||
char buffer[MAX_PATH];
|
||||
GetModuleFileNameA(nullptr, buffer, MAX_PATH);
|
||||
std::filesystem::path exe_path(buffer);
|
||||
std::filesystem::path data_dir = exe_path.parent_path().parent_path() / "share" / "clrsync";
|
||||
return data_dir;
|
||||
#else
|
||||
return {CLRSYNC_DATADIR};
|
||||
#endif
|
||||
}
|
||||
|
||||
void config::copy_default_configs()
|
||||
{
|
||||
std::filesystem::path user_config = get_user_config_dir();
|
||||
std::filesystem::path default_dir = CLRSYNC_DATADIR;
|
||||
std::filesystem::path default_dir = get_data_dir();
|
||||
|
||||
if (!std::filesystem::exists(user_config))
|
||||
{
|
||||
|
||||
@@ -32,6 +32,7 @@ class config
|
||||
|
||||
void update_template(const std::string &key,
|
||||
const clrsync::core::theme_template &theme_template);
|
||||
static std::filesystem::path get_data_dir();
|
||||
|
||||
private:
|
||||
config() = default;
|
||||
|
||||
@@ -28,7 +28,7 @@ void palette_controller::select_palette(const std::string& name)
|
||||
|
||||
void palette_controller::create_palette(const std::string& name)
|
||||
{
|
||||
clrsync::core::palette new_palette = m_palette_manager.load_palette_from_file(std::string(CLRSYNC_DATADIR) + "/palettes/cursed.toml");
|
||||
clrsync::core::palette new_palette = m_palette_manager.load_palette_from_file(clrsync::core::config::get_data_dir().string() + "/palettes/cursed.toml");
|
||||
new_palette.set_name(name);
|
||||
|
||||
auto dir = clrsync::core::config::instance().palettes_path();
|
||||
|
||||
Reference in New Issue
Block a user