From f525de02aa622329b946b1c7a962950deb128ab4 Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Fri, 12 Jul 2024 12:19:26 +0900 Subject: [PATCH] Add conan packaging related files --- conanfile.py | 56 ++++++++++++++++++++++++++++++ test_package/.gitignore | 1 + test_package/CMakeLists.txt | 7 ++++ test_package/CMakeUserPresets.json | 9 +++++ test_package/conanfile.py | 26 ++++++++++++++ test_package/src/example.cpp | 6 ++++ 6 files changed, 105 insertions(+) create mode 100644 conanfile.py create mode 100644 test_package/.gitignore create mode 100644 test_package/CMakeLists.txt create mode 100644 test_package/CMakeUserPresets.json create mode 100644 test_package/conanfile.py create mode 100644 test_package/src/example.cpp diff --git a/conanfile.py b/conanfile.py new file mode 100644 index 0000000..668f7d3 --- /dev/null +++ b/conanfile.py @@ -0,0 +1,56 @@ +from conan import ConanFile +from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps +import os + + +class SC_3D_collision_helpersRecipe(ConanFile): + name = "3d_collision_helpers" + version = "3.22.1" + package_type = "library" + + # Optional metadata + license = "MIT" + author = "Stephen Seo stephen@seodisparate.com" + url = "https://git.seodisparate.com/stephenseo/3d_collision_helpers" + description = "A library with helpers for 3d space" + topics = ("3D", "collision", "matrix", "vector") + + # Binary configuration + settings = "os", "compiler", "build_type", "arch" + options = {"shared": [True, False], "fPIC": [True, False]} + default_options = {"shared": False, "fPIC": True} + + # Sources are located in the same place as this recipe, copy them to the recipe + exports_sources = "CMakeLists.txt", "src/*" + + def config_options(self): + if self.settings.os == "Windows": + self.options.rm_safe("fPIC") + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + + def layout(self): + cmake_layout(self) + + def generate(self): + deps = CMakeDeps(self) + deps.generate() + tc = CMakeToolchain(self) + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + if not self.conf.get("tools.build:skip_test", default=False): + self.run(os.path.join(self.build_folder, "UnitTest")) + + def package(self): + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.libs = ["SC_3D_CollisionDetectionHelpers"] + diff --git a/test_package/.gitignore b/test_package/.gitignore new file mode 100644 index 0000000..84c048a --- /dev/null +++ b/test_package/.gitignore @@ -0,0 +1 @@ +/build/ diff --git a/test_package/CMakeLists.txt b/test_package/CMakeLists.txt new file mode 100644 index 0000000..1f5717d --- /dev/null +++ b/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.15) +project(PackageTest CXX) + +find_package(3d_collision_helpers CONFIG REQUIRED) + +add_executable(example src/example.cpp) +target_link_libraries(example 3d_collision_helpers::3d_collision_helpers) diff --git a/test_package/CMakeUserPresets.json b/test_package/CMakeUserPresets.json new file mode 100644 index 0000000..402e164 --- /dev/null +++ b/test_package/CMakeUserPresets.json @@ -0,0 +1,9 @@ +{ + "version": 4, + "vendor": { + "conan": {} + }, + "include": [ + "build/gcc-14-x86_64-gnu17-release/generators/CMakePresets.json" + ] +} \ No newline at end of file diff --git a/test_package/conanfile.py b/test_package/conanfile.py new file mode 100644 index 0000000..4535cd3 --- /dev/null +++ b/test_package/conanfile.py @@ -0,0 +1,26 @@ +import os + +from conan import ConanFile +from conan.tools.cmake import CMake, cmake_layout +from conan.tools.build import can_run + + +class SC_3D_collision_helpersTestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "CMakeDeps", "CMakeToolchain" + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def layout(self): + cmake_layout(self) + + def test(self): + if can_run(self): + cmd = os.path.join(self.cpp.build.bindir, "example") + self.run(cmd, env="conanrun") diff --git a/test_package/src/example.cpp b/test_package/src/example.cpp new file mode 100644 index 0000000..109976a --- /dev/null +++ b/test_package/src/example.cpp @@ -0,0 +1,6 @@ +#include "sc_sacd.h" + +int main() { + auto mat3 = SC_SACD_Mat3_Identity(); + return 0; +}