diff --git a/CMakeLists.txt b/CMakeLists.txt index 562a306..0761883 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,8 @@ cmake_minimum_required(VERSION 3.30.5) project(UpAndDown) -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 23) +set(CMAKE_CXX_STANDARD_REQUIRED ON) if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") include(${CMAKE_CURRENT_SOURCE_DIR}/cmake-build-debug/conan_toolchain.cmake) diff --git a/README.md b/README.md index 2132949..61914e1 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,19 @@ +// Установка переменных для Conan +set "VS_DIR=C:\PROGRA~1\MICROS~2\2022\COMMUN~1" +set "VSCMD_INSTALL_DIR=%VS_DIR%" +set "VSCMD_VER=17.0" +set "VCToolsVersion=14.44.35207" + +// Короткий путь для конфига +for %I in ("C:\Program Files\Microsoft Visual Studio\2022\Community") do echo %~sI + +// Загрузка кастомных сценариев установки +conan export custom_recipes/boost/ --user=up_and_down --channel=stable +conan export custom_recipes/openssl_fix/ --user=up_and_down --channel=stable +conan export custom_recipes/lz4_fix/ --user=up_and_down --channel=stable + +// Запуск дебага conan install . -pr ./profiles/debug_profile --output-folder=cmake-build-debug --build=missing +// Запуск релиза conan install . -pr ./profiles/release_profile --output-folder=cmake-build-release --build=missing diff --git a/conanfile.py b/conanfile.py new file mode 100644 index 0000000..3b0fd45 --- /dev/null +++ b/conanfile.py @@ -0,0 +1,27 @@ +from conan import ConanFile +from conan.tools.cmake import CMakeToolchain, CMake + +class UpAndDown(ConanFile): + name = "up_and_down" + version = "1.0.0" + settings = "os", "compiler", "build_type", "arch" + generators = "CMakeToolchain", "CMakeDeps" + + def requirements(self): + self.requires("boost/1.87.0@up_and_down/stable") + self.requires("libmysqlclient/8.1.0") + self.requires("lz4/1.10.0@up_and_down/stable", override=True) + + # Явно добавляем новую версию zstd с override + self.requires("zstd/1.5.7", override=True) + self.requires("openssl/3.5.0@up_and_down/stable", force=True) + + def configure(self): + # Настройки для boost + self.options["boost/*"].toolset = "msvc-14.3" + self.options["boost/*"].without_stacktrace = True + self.options["boost/*"].without_context = True + self.options["openssl"].shared = True + + def layout(self): + cmake_layout(self) diff --git a/conanfile.txt b/conanfile.txt deleted file mode 100644 index 6a55361..0000000 --- a/conanfile.txt +++ /dev/null @@ -1,6 +0,0 @@ -[requires] -boost/1.78.0 - -[generators] -CMakeDeps -CMakeToolchain diff --git a/custom_recipes/boost/conanfile.py b/custom_recipes/boost/conanfile.py new file mode 100644 index 0000000..4ae5673 --- /dev/null +++ b/custom_recipes/boost/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.files import get, copy +import os + +class CustomBoostConan(ConanFile): + name = "boost" + version = "1.87.0" + settings = "os", "compiler", "arch", "build_type" + + def source(self): + # Используем прямой URL с GitHub + get(self, "https://github.com/boostorg/boost/archive/refs/tags/boost-1.87.0.zip", + destination=self.source_folder, strip_root=True) + + def build(self): + pass # Пропускаем сборку + + def package(self): + # Копируем заголовочные файлы + copy(self, "*", + os.path.join(self.source_folder, "boost"), + os.path.join(self.package_folder, "include", "boost")) + + def package_info(self): + self.cpp_info.includedirs = ["include"] + self.cpp_info.libdirs = [] # Только заголовочная библиотека \ No newline at end of file diff --git a/custom_recipes/lz4_fix/conanfile.py b/custom_recipes/lz4_fix/conanfile.py new file mode 100644 index 0000000..87eab65 --- /dev/null +++ b/custom_recipes/lz4_fix/conanfile.py @@ -0,0 +1,65 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain +from conan.tools.files import get, replace_in_file, load +import os +import re + +class Lz4Conan(ConanFile): + name = "lz4" + version = "1.10.0" + settings = "os", "compiler", "arch", "build_type" + + def source(self): + # Скачиваем исходники + url = f"https://github.com/lz4/lz4/archive/refs/tags/v{self.version}.tar.gz" + get(self, url, strip_root=True) + + # Находим CMakeLists.txt в правильном месте + cmakelists_path = os.path.join(self.source_folder, "build", "cmake", "CMakeLists.txt") + if not os.path.exists(cmakelists_path): + # Для более новых версий lz4 путь может быть другим + cmakelists_path = os.path.join(self.source_folder, "CMakeLists.txt") + + # Применяем исправление для VS2022 + if os.path.exists(cmakelists_path): + content = load(self, cmakelists_path) + + # Добавляем исправление, если его еще нет + if "CMP0091" not in content: + # Ищем место для вставки после cmake_minimum_required + new_content = re.sub( + r'(cmake_minimum_required\(VERSION [\d.]+\))', + r'\1\n\n# Fix for VS2022\ncmake_policy(SET CMP0091 NEW)', + content + ) + + with open(cmakelists_path, "w", encoding="utf-8") as f: + f.write(new_content) + self.output.info("Applied VS2022 fix to CMakeLists.txt") + + def generate(self): + tc = CMakeToolchain(self) + # Явно указываем генератор для VS2022 + if self.settings.compiler == "msvc" and self.settings.compiler.version == "193": + tc.generator = "Visual Studio 17 2022" + + # Дополнительные настройки для MSVC + tc.preprocessor_definitions["_CRT_SECURE_NO_WARNINGS"] = "1" + tc.variables["CMAKE_MSVC_RUNTIME_LIBRARY"] = "MultiThreaded$<$:Debug>" + tc.generate() + + def build(self): + cmake = CMake(self) + # Автоматически определяем папку со скриптами CMake + if os.path.exists(os.path.join(self.source_folder, "build", "cmake")): + cmake.configure(build_script_folder=os.path.join("build", "cmake")) + else: + cmake.configure() + cmake.build() + + def package(self): + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.libs = ["lz4"] \ No newline at end of file diff --git a/custom_recipes/openssl_fix/conanfile.py b/custom_recipes/openssl_fix/conanfile.py new file mode 100644 index 0000000..f7589ed --- /dev/null +++ b/custom_recipes/openssl_fix/conanfile.py @@ -0,0 +1,28 @@ +from conan import ConanFile +from conan.tools.microsoft import msvs_toolset, is_msvc +from conan.tools.env import VirtualBuildEnv + +class OpenSSLConan(ConanFile): + name = "openssl" + version = "3.5.0" + settings = "os", "compiler", "arch", "build_type" + + def generate(self): + vs_version = None + if is_msvc(self): + # Получаем версию тулсета (v143 для VS2022) + toolset = msvs_toolset(self) + self.output.info(f"Detected toolset: {toolset}") + + # Сопоставляем тулсет с версией VS + if "v143" in toolset: + vs_version = "17" # VS2022 + elif "v142" in toolset: + vs_version = "16" # VS2019 + + if vs_version: + # Правильный способ установки переменных окружения в Conan 2.x + build_env = VirtualBuildEnv(self) + build_env.environment().define("CONAN_VS_VERSION", vs_version) + build_env.generate() + self.output.info(f"Setting VS version to: {vs_version}") \ No newline at end of file diff --git a/profiles/debug_profile b/profiles/debug_profile index e0d4d57..bcca976 100644 --- a/profiles/debug_profile +++ b/profiles/debug_profile @@ -2,7 +2,14 @@ arch=x86_64 build_type=Debug compiler=msvc -compiler.cppstd=17 +compiler.cppstd=23 compiler.runtime=dynamic compiler.version=193 +compiler.toolset=v143:version=14.44.35207 os=Windows + +[conf] +tools.microsoft:winsdk_version=10.0.20348.0 +tools.microsoft.msbuild:installation_path="C:\\VS2022" +tools.microsoft.msbuild:vs_version=2022 +tools.cmake.cmaketoolchain:generator="Visual Studio 17 2022" diff --git a/profiles/release_profile b/profiles/release_profile index fa6e904..309fa93 100644 --- a/profiles/release_profile +++ b/profiles/release_profile @@ -2,7 +2,14 @@ arch=x86_64 build_type=Release compiler=msvc -compiler.cppstd=17 +compiler.cppstd=23 compiler.runtime=dynamic compiler.version=193 +compiler.toolset=v143:version=14.44.35207 os=Windows + +[conf] +tools.microsoft:winsdk_version=10.0.20348.0 +tools.microsoft.msbuild:installation_path="C:\\VS2022" +tools.microsoft.msbuild:vs_version=2022 +tools.cmake.cmaketoolchain:generator="Visual Studio 17 2022"