diff --git a/recipes/games101-cgl/all/conandata.yml b/recipes/games101-cgl/all/conandata.yml new file mode 100644 index 00000000000000..73b714f87c14e5 --- /dev/null +++ b/recipes/games101-cgl/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "0.1.0": + url: "https://github.com/endingly/games101-cgl/archive/refs/tags/v0.1.0.zip" + sha256: dc17b76ed4f2d9222c17a75ab22e07f156f077d0a243f35539b4439cc0cb9ae9 diff --git a/recipes/games101-cgl/all/conanfile.py b/recipes/games101-cgl/all/conanfile.py new file mode 100644 index 00000000000000..370dac22018042 --- /dev/null +++ b/recipes/games101-cgl/all/conanfile.py @@ -0,0 +1,91 @@ +from conan import ConanFile +from conan.tools.files import get, copy, rmdir, rm +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +import os + +required_conan_version = ">=1.55.0" + +class Games101CglConan(ConanFile): + name = "games101-cgl" + description = "The package is for Games101's homework8 subproject" + license = "MIT" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/endingly/games101-cgl" + topics = ("games101", "graphics") + package_type = "library" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + @property + def _min_cppstd(self): + return 11 + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + self.requires("freetype/2.13.2") + self.requires("glew/2.2.0", transitive_headers=True) + self.requires("glfw/3.4", transitive_headers=True) + + def validate(self): + if self.settings.compiler.cppstd: + check_min_cppstd(self, self._min_cppstd) + + def build_requirements(self): + self.tool_requires("cmake/[>=3.25 <4.0.0]") + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + toolchain = CMakeToolchain(self) + toolchain.generate() + deps = CMakeDeps(self) + deps.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, pattern="LICENSE*", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "share")) + rm(self, "*.la", os.path.join(self.package_folder, "lib")) + rm(self, "*.pdb", os.path.join(self.package_folder, "lib")) + rm(self, "*.pdb", os.path.join(self.package_folder, "bin")) + + def package_info(self): + suffix = "d" if self.settings.build_type == "Debug" else "" + self.cpp_info.libs = ["CGL" + suffix] + + self.cpp_info.set_property("cmake_file_name", "games101-cgl") + self.cpp_info.set_property("cmake_target_name", "games101-cgl::games101-cgl") + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.filenames["cmake_find_package"] = "games101-cgl" + self.cpp_info.filenames["cmake_find_package_multi"] = "games101-cgl" + self.cpp_info.names["cmake_find_package"] = "games101-cgl" + self.cpp_info.names["cmake_find_package_multi"] = "games101-cgl" diff --git a/recipes/games101-cgl/all/test_package/CMakeLists.txt b/recipes/games101-cgl/all/test_package/CMakeLists.txt new file mode 100644 index 00000000000000..fbd0be167add6c --- /dev/null +++ b/recipes/games101-cgl/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(games101-cgl REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE games101-cgl::games101-cgl) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/games101-cgl/all/test_package/conanfile.py b/recipes/games101-cgl/all/test_package/conanfile.py new file mode 100644 index 00000000000000..a9fbb7f5431620 --- /dev/null +++ b/recipes/games101-cgl/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/games101-cgl/all/test_package/test_package.cpp b/recipes/games101-cgl/all/test_package/test_package.cpp new file mode 100644 index 00000000000000..94b4226d74ca79 --- /dev/null +++ b/recipes/games101-cgl/all/test_package/test_package.cpp @@ -0,0 +1,8 @@ +#include + +#include + +int main() { + CGL::Vector2D vector{5, 4}; + std::cout << vector << '\n'; +} diff --git a/recipes/games101-cgl/all/test_v1_package/CMakeLists.txt b/recipes/games101-cgl/all/test_v1_package/CMakeLists.txt new file mode 100644 index 00000000000000..be00a8c7f57c71 --- /dev/null +++ b/recipes/games101-cgl/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/games101-cgl/all/test_v1_package/conanfile.py b/recipes/games101-cgl/all/test_v1_package/conanfile.py new file mode 100644 index 00000000000000..20d4d2e28d57e0 --- /dev/null +++ b/recipes/games101-cgl/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/games101-cgl/config.yml b/recipes/games101-cgl/config.yml new file mode 100644 index 00000000000000..6c11a439d0bc21 --- /dev/null +++ b/recipes/games101-cgl/config.yml @@ -0,0 +1,3 @@ +versions: + "0.1.0": + folder: all