Skip to content

Commit 4f3f41c

Browse files
author
Fjodor Schelichow
committed
new library: sgltk
1 parent 06fb0be commit 4f3f41c

File tree

6 files changed

+152
-0
lines changed

6 files changed

+152
-0
lines changed

recipes/sgltk/all/conandata.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
sources:
2+
"0.6.1":
3+
url: "https://github.com/pyth/sgltk/archive/refs/tags/v0.6.1.tar.gz"
4+
sha256: "1c530b328af18102768ed82460325996201be821cb457b497047bc7f1a7bc7fd"

recipes/sgltk/all/conanfile.py

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
from conan import ConanFile
2+
from conan.errors import ConanInvalidConfiguration
3+
from conan.tools.build import check_min_cppstd
4+
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
5+
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rm, rmdir
6+
from conan.tools.microsoft import is_msvc, is_msvc_static_runtime
7+
import os
8+
9+
10+
required_conan_version = ">=2.0.9"
11+
12+
class PackageConan(ConanFile):
13+
name = "sgltk"
14+
description = "A collection of easy to use OpenGL tools."
15+
license = "Zlib"
16+
url = "https://github.com/conan-io/conan-center-index"
17+
homepage = "https://github.com/pyth/sgltk"
18+
topics = ("c-plus-plus", "opengl", "sdl2")
19+
package_type = "library"
20+
settings = "os", "arch", "compiler", "build_type"
21+
options = {
22+
"shared": [True, False],
23+
"fPIC": [True, False],
24+
"with_sdl_ttf": [True, False],
25+
"with_assimp": [True, False],
26+
}
27+
default_options = {
28+
"shared": False,
29+
"fPIC": True,
30+
"with_sdl_ttf": True,
31+
"with_assimp": True,
32+
}
33+
implements = ["auto_shared_fpic"]
34+
35+
def export_sources(self):
36+
export_conandata_patches(self)
37+
38+
def configure(self):
39+
if self.options.shared:
40+
self.options.rm_safe("fPIC")
41+
42+
def layout(self):
43+
cmake_layout(self, src_folder="src")
44+
45+
def requirements(self):
46+
self.requires("glm/1.0.1")
47+
self.requires("glew/2.2.0")
48+
self.requires("sdl/2.28.3")
49+
self.requires("sdl_image/2.8.2")
50+
if self.options.with_sdl_ttf:
51+
self.requires("sdl_ttf/2.24.0")
52+
if self.options.with_assimp:
53+
self.requires("assimp/5.4.3")
54+
55+
def build_requirements(self):
56+
self.tool_requires("cmake/[>=3.16 <4]")
57+
58+
def source(self):
59+
get(self, **self.conan_data["sources"][self.version], strip_root=True)
60+
apply_conandata_patches(self)
61+
62+
def generate(self):
63+
tc = CMakeToolchain(self)
64+
tc.cache_variables["PACKAGE_BUILD_TESTS"] = False
65+
if is_msvc(self):
66+
tc.cache_variables["USE_MSVC_RUNTIME_LIBRARY_DLL"] = not is_msvc_static_runtime(self)
67+
tc.generate()
68+
69+
deps = CMakeDeps(self)
70+
deps.generate()
71+
72+
def build(self):
73+
cmake = CMake(self)
74+
cmake.configure()
75+
cmake.build()
76+
77+
def package(self):
78+
copy(self, "LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses"))
79+
cmake = CMake(self)
80+
cmake.install()
81+
82+
def package_info(self):
83+
self.cpp_info.set_property("cmake_file_name", "sgltk")
84+
self.cpp_info.set_property("cmake_target_name", "sgltk::sgltk")
85+
86+
self.cpp_info.libs = ["sgltk" if self.options.shared else "sgltk_static"]
87+
88+
reqs = [
89+
"glm::glm",
90+
"glew::glew",
91+
"sdl::sdl",
92+
"sdl_image::sdl_image",
93+
]
94+
if self.options.with_sdl_ttf:
95+
reqs.append("sdl_ttf::sdl_ttf")
96+
if self.options.with_assimp:
97+
reqs.append("assimp::assimp")
98+
99+
self.cpp_info.requires = reqs
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
cmake_minimum_required(VERSION 3.15)
2+
project(test_package LANGUAGES CXX)
3+
4+
find_package(sgltk REQUIRED CONFIG)
5+
6+
add_executable(${PROJECT_NAME} test_package.cpp)
7+
target_link_libraries(${PROJECT_NAME} PRIVATE sgltk::sgltk)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from conan import ConanFile
2+
from conan.tools.build import can_run
3+
from conan.tools.cmake import cmake_layout, CMake
4+
import os
5+
6+
class TestPackageConan(ConanFile):
7+
settings = "os", "arch", "compiler", "build_type"
8+
generators = "CMakeDeps", "CMakeToolchain"
9+
10+
def layout(self):
11+
cmake_layout(self)
12+
13+
def requirements(self):
14+
self.requires(self.tested_reference_str)
15+
16+
def build(self):
17+
cmake = CMake(self)
18+
cmake.configure()
19+
cmake.build()
20+
21+
def test(self):
22+
if can_run(self):
23+
bin_path = os.path.join(self.cpp.build.bindir, "test_package")
24+
self.run(bin_path, env="conanrun")
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include <iostream>
2+
#include <sgltk/sgltk.h>
3+
4+
int main(void) {
5+
sgltk::App::init();
6+
sgltk::Window win("System info", 1200, 800, 100, 100, SDL_WINDOW_HIDDEN);
7+
std::cout<<"System info"<<std::endl<<std::endl;
8+
std::cout<<"OS: "<<sgltk::App::sys_info.platform_name<<std::endl;
9+
std::cout<<"CPU Cores: "<<sgltk::App::sys_info.num_logical_cores<<std::endl;
10+
std::cout<<"RAM: "<<sgltk::App::sys_info.system_ram<<"MB"<<std::endl;
11+
std::cout<<"Highest supported OpenGL version: "<<win.gl_maj<<"."<<win.gl_min<<std::endl;
12+
std::cout<<"Number of displays: "<<sgltk::App::sys_info.num_displays<<std::endl;
13+
14+
return 0;
15+
}

recipes/sgltk/config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
versions:
2+
"0.6.1":
3+
folder: all

0 commit comments

Comments
 (0)