Skip to content

Commit caf1d41

Browse files
danttiuilianriesfranramirez688
authored
kdalgorithms: Add new recipe kdalgorithms/1.4 (#28255)
* kdalgorithms: Add new recipe Signed-off-by: Daniel Nicoletti <[email protected]> * Use official release sources Signed-off-by: Uilian Ries <[email protected]> * Requires Conan 2.x Signed-off-by: Uilian Ries <[email protected]> * Remove unused import Signed-off-by: Uilian Ries <[email protected]> * Use CMake install to avoid mistakes Signed-off-by: Uilian Ries <[email protected]> * Align cmake targets according to the upstream Signed-off-by: Uilian Ries <[email protected]> * Simplify test package Signed-off-by: Uilian Ries <[email protected]> * Fix package name Signed-off-by: Uilian Ries <[email protected]> * Add EOF in test package Signed-off-by: Uilian Ries <[email protected]> * Remove cmake installed files Signed-off-by: Uilian Ries <[email protected]> * Avoid no_copy_source * Move cmake setup to package step Co-authored-by: Francisco Ramírez <[email protected]> --------- Signed-off-by: Daniel Nicoletti <[email protected]> Signed-off-by: Uilian Ries <[email protected]> Co-authored-by: Uilian Ries <[email protected]> Co-authored-by: Uilian Ries <[email protected]> Co-authored-by: Francisco Ramírez <[email protected]>
1 parent 6b7b89c commit caf1d41

File tree

6 files changed

+97
-0
lines changed

6 files changed

+97
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
sources:
2+
"1.4":
3+
url: "https://github.com/KDAB/KDAlgorithms/releases/download/1.4/kdalgorithms-1.4.tar.gz"
4+
sha256: "7abce0c714e5766aaf1d62d0c8771c6fbf5266ec90fd084b3258a008bcec85d8"
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
from conan import ConanFile
2+
from conan.tools.build import check_min_cppstd
3+
from conan.tools.files import get, copy, rmdir
4+
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
5+
import os
6+
7+
required_conan_version = ">=2.0"
8+
9+
class KDAlgorithmsConan(ConanFile):
10+
name = "kdalgorithms"
11+
license = "MIT"
12+
description = "C++ Algorithm wrappers"
13+
url = "https://github.com/conan-io/conan-center-index"
14+
homepage = "https://github.com/KDAB/KDAlgorithms"
15+
topics = ("c++14", "algorithmns", "kdab", "header-only")
16+
package_type = "header-library"
17+
settings = "os", "arch", "compiler", "build_type"
18+
19+
def layout(self):
20+
cmake_layout(self, src_folder="src")
21+
22+
def package_id(self):
23+
self.info.clear()
24+
25+
def source(self):
26+
get(self, **self.conan_data["sources"][self.version], strip_root=True)
27+
28+
def validate(self):
29+
check_min_cppstd(self, "14")
30+
31+
def generate(self):
32+
tc = CMakeToolchain(self)
33+
tc.cache_variables["BUILD_TESTING"] = False
34+
tc.generate()
35+
36+
def package(self):
37+
copy(self, "LICENSES/*", dst=os.path.join(self.package_folder,"licenses"), src=self.source_folder)
38+
cmake = CMake(self)
39+
cmake.configure()
40+
cmake.install()
41+
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
42+
43+
44+
def package_info(self):
45+
self.cpp_info.bindirs = []
46+
self.cpp_info.libdirs = []
47+
self.cpp_info.set_property("cmake_file_name", "KDAlgorithms")
48+
self.cpp_info.set_property("cmake_target_name", "KDAB::kdalgorithms")
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(KDAlgorithms REQUIRED CONFIG)
5+
6+
add_executable(${PROJECT_NAME} main.cpp)
7+
target_link_libraries(${PROJECT_NAME} PRIVATE KDAB::kdalgorithms)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
7+
class TestPackageConan(ConanFile):
8+
settings = "os", "arch", "compiler", "build_type"
9+
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"
10+
11+
def layout(self):
12+
cmake_layout(self)
13+
14+
def requirements(self):
15+
self.requires(self.tested_reference_str)
16+
17+
def build(self):
18+
cmake = CMake(self)
19+
cmake.configure()
20+
cmake.build()
21+
22+
def test(self):
23+
if can_run(self):
24+
bin_path = os.path.join(self.cpp.build.bindir, "test_package")
25+
self.run(bin_path, env="conanrun")
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include <cstdlib>
2+
#include <iostream>
3+
4+
#include <kdalgorithms/kdalgorithms.h>
5+
6+
int main() {
7+
auto vec = kdalgorithms::iota(1, 10);
8+
std::cout << "kdalgorithms::iota: " << vec[0] << "\n";
9+
return EXIT_SUCCESS;
10+
}

recipes/kdalgorithms/config.yml

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

0 commit comments

Comments
 (0)