diff --git a/.github/workflows/requirements-conan-package.txt b/.github/workflows/requirements-conan-package.txt index 82124ae..cf67557 100644 --- a/.github/workflows/requirements-conan-package.txt +++ b/.github/workflows/requirements-conan-package.txt @@ -1 +1 @@ -conan \ No newline at end of file +conan>=1.56.0,<2.0.0 \ No newline at end of file diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 6386606..763345c 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -113,7 +113,7 @@ jobs: run: | . ./activate_github_actions_runenv.sh . ./activate_github_actions_buildenv.sh - working-directory: build/generators/ + working-directory: build/Release/generators/ - name: Build Unit Test run: | diff --git a/conandata.yml b/conandata.yml deleted file mode 100644 index c6b5e8d..0000000 --- a/conandata.yml +++ /dev/null @@ -1,20 +0,0 @@ -"5.3.0-alpha": - requirements: - - "pugixml/1.12.1" - build_requirements_testing: - - "gtest/1.12.1" -"5.2.2": - requirements: - - "pugixml/1.12.1" - build_requirements_testing: - - "gtest/1.12.1" -"5.2.0": - requirements: - - "pugixml/1.12.1" - build_requirements_testing: - - "gtest/1.12.1" -"5.1.0": - requirements: - - "pugixml/1.12.1" - build_requirements_testing: - - "gtest/[>=1.10.0]" diff --git a/conanfile.py b/conanfile.py index 176a24a..ef9c12d 100644 --- a/conanfile.py +++ b/conanfile.py @@ -1,9 +1,17 @@ +from os import path + + +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration from conan.tools.cmake import CMakeToolchain, CMakeDeps, CMake, cmake_layout -from conan.tools.files import AutoPackager +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import AutoPackager, copy from conan.tools.build import check_min_cppstd -from conan import ConanFile +from conan.tools.microsoft import check_min_vs, is_msvc, is_msvc_static_runtime +from conan.tools.scm import Version -required_conan_version = ">=1.50.0" + +required_conan_version = ">=1.56.0" class SavitarConan(ConanFile): @@ -18,9 +26,6 @@ class SavitarConan(ConanFile): exports = "LICENSE*" generators = "CMakeDeps", "VirtualBuildEnv", "VirtualRunEnv" - python_requires = "umbase/[>=0.1.7]@ultimaker/stable" - python_requires_extend = "umbase.UMBaseConanfile" - options = { "shared": [True, False], "fPIC": [True, False], @@ -31,49 +36,79 @@ class SavitarConan(ConanFile): "fPIC": True, "enable_testing": False } - scm = { - "type": "git", - "subfolder": ".", - "url": "auto", - "revision": "auto" - } def set_version(self): if self.version is None: - self.version = self._umdefault_version() + self.version = "5.3.0-alpha" - def build_requirements(self): - if self.options.enable_testing: - for req in self._um_data()["build_requirements_testing"]: - self.test_requires(req) + + @property + def _min_cppstd(self): + return 17 + + @property + def _compilers_minimum_version(self): + return { + "gcc": "9", + "clang": "9", + "apple-clang": "9", + "msvc": "192", + "visual_studio": "14", + } + + def export_sources(self): + copy(self, "CMakeLists.txt", self.recipe_folder, self.export_sources_folder) + copy(self, "*", path.join(self.recipe_folder, "src"), path.join(self.export_sources_folder, "src")) + copy(self, "*", path.join(self.recipe_folder, "include"), path.join(self.export_sources_folder, "include")) + copy(self, "*", path.join(self.recipe_folder, "tests"), path.join(self.export_sources_folder, "tests")) + + def layout(self): + cmake_layout(self) + self.cpp.package.libs = ["Savitar"] + + if self.settings.get_safe("build_type", "Release") == "Debug": + self.cpp.package.defines = ["SAVITAR_DEBUG"] def requirements(self): - self.requires("standardprojectsettings/[>=0.1.0]@ultimaker/stable") - for req in self._um_data()["requirements"]: - self.requires(req) + self.requires("pugixml/1.12.1", transitive_headers=True) + + def validate(self): + if self.settings.compiler.cppstd: + check_min_cppstd(self, self._min_cppstd) + check_min_vs(self, 192) # TODO: remove in Conan 2.0 + if not is_msvc(self): + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if minimum_version and Version(self.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support." + ) + + def build_requirements(self): + self.test_requires("standardprojectsettings/[>=0.1.0]@ultimaker/stable") + if self.options.enable_testing: + self.test_requires("gtest/1.12.1") def config_options(self): - if self.options.shared and self.settings.compiler == "Visual Studio": + if self.settings.os == "Windows": del self.options.fPIC def configure(self): - self.options["pugixml"].shared = self.options.shared - - def validate(self): - if self.settings.compiler.get_safe("cppstd"): - check_min_cppstd(self, 17) + if self.options.shared: + self.options.rm_safe("fPIC") def generate(self): tc = CMakeToolchain(self) + if is_msvc(self): + tc.variables["USE_MSVC_RUNTIME_LIBRARY_DLL"] = not is_msvc_static_runtime(self) + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" tc.variables["ENABLE_TESTING"] = self.options.enable_testing tc.generate() - def layout(self): - cmake_layout(self) - self.cpp.package.libs = ["Savitar"] + tc = CMakeDeps(self) + tc.generate() - if self.settings.build_type == "Debug": - self.cpp.package.defines = ["SAVITAR_DEBUG"] + tc = VirtualBuildEnv(self) + tc.generate(scope="build") def build(self): cmake = CMake(self) @@ -81,5 +116,6 @@ def build(self): cmake.build() def package(self): + copy(self, pattern="LICENSE*", dst="licenses", src=self.source_folder) packager = AutoPackager(self) packager.run() diff --git a/test_package/conanfile.py b/test_package/conanfile.py index ef93d38..5c532db 100644 --- a/test_package/conanfile.py +++ b/test_package/conanfile.py @@ -1,12 +1,17 @@ from conan import ConanFile +from conan.tools.build import can_run from conan.tools.cmake import CMakeToolchain, CMakeDeps, CMake from conan.tools.env import VirtualRunEnv -from conans import tools +from conan.tools.files import copy class SavitarTestConan(ConanFile): settings = "os", "compiler", "build_type", "arch" generators = "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) def generate(self): cmake = CMakeDeps(self) @@ -15,23 +20,21 @@ def generate(self): venv = VirtualRunEnv(self) venv.generate() - tc = CMakeToolchain(self, generator = "Ninja") - if self.settings.compiler == "Visual Studio": - tc.blocks["generic_system"].values["generator_platform"] = None - tc.blocks["generic_system"].values["toolset"] = None + tc = CMakeToolchain(self) tc.generate() + for dep in self.dependencies.values(): + for bin_dir in dep.cpp_info.bindirs: + copy(self, "*.dll", src = bin_dir, dst = self.build_folder) + def build(self): cmake = CMake(self) cmake.configure() cmake.build() - def imports(self): - if self.settings.os == "Windows" and not tools.cross_building(self, skip_x64_x86 = True): - self.copy("*.dll", dst=".", src="@bindirs") def test(self): - if not tools.cross_building(self): + if can_run(self): ext = ".exe" if self.settings.os == "Windows" else "" prefix_path = "" if self.settings.os == "Windows" else "./" self.run(f"{prefix_path}test{ext}", env = "conanrun") diff --git a/tests/namespaces.xml b/tests/namespaces.xml index 1ea4f8c..edfeb3b 100644 --- a/tests/namespaces.xml +++ b/tests/namespaces.xml @@ -1,4 +1,4 @@ - +
diff --git a/tests/problem_model.xml b/tests/problem_model.xml index b142be1..73f76de 100644 --- a/tests/problem_model.xml +++ b/tests/problem_model.xml @@ -1,4 +1,4 @@ - + diff --git a/tests/test_model.xml b/tests/test_model.xml index cd3ba5b..931939e 100644 --- a/tests/test_model.xml +++ b/tests/test_model.xml @@ -1,4 +1,4 @@ - +