forked from conan-io/conan-center-index
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a new package for libtommath that supports conan v2
- Loading branch information
Showing
12 changed files
with
138 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
versions: | ||
"1.2.0-dev": | ||
folder: "development" | ||
"1.2.0": | ||
folder: "all" | ||
folder: "release" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from conan import ConanFile | ||
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps | ||
from conan.tools.scm import Git | ||
|
||
class LibTomMathRecipe(ConanFile): | ||
name = "libtommath" | ||
version = "1.2.0-dev" | ||
|
||
# Optional metadata | ||
license = "Unlicense" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
homepage = "https://www.libtom.net/" | ||
topics = ("libtommath", "math", "multiple", "precision") | ||
|
||
# Binary configuration | ||
settings = "os", "compiler", "build_type", "arch" | ||
options = {"shared": [True, False], "fPIC": [True, False]} | ||
default_options = {"shared": False, "fPIC": True} | ||
|
||
def source(self): | ||
git = Git(self) | ||
git.clone(url="https://github.com/libtom/libtommath.git", target=".") | ||
git.checkout("03de03dee753442d4b23166982514639c4ccbc39") | ||
|
||
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() | ||
|
||
def package(self): | ||
cmake = CMake(self) | ||
cmake.install() | ||
|
||
def package_info(self): | ||
self.cpp_info.libs = ["tommath"] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
cmake_minimum_required(VERSION 3.15) | ||
project(PackageTest C) | ||
|
||
find_package(libtommath CONFIG REQUIRED) | ||
|
||
|
||
|
||
add_executable(example src/test_package.c) | ||
target_link_libraries(example libtommath::libtommath) |
9 changes: 9 additions & 0 deletions
9
recipes/libtommath/development/test_package/CMakeUserPresets.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"version": 4, | ||
"vendor": { | ||
"conan": {} | ||
}, | ||
"include": [ | ||
"C:\\Users\\jowr\\Repos\\TMP\\conan-center-index.win.git\\recipes\\libtommath\\development\\test_package\\build\\msvc-193-x86_64-14-release\\generators\\CMakePresets.json" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import os | ||
|
||
from conan import ConanFile | ||
from conan.tools.cmake import CMake, cmake_layout | ||
from conan.tools.build import can_run | ||
|
||
|
||
class LibTomMathTestConan(ConanFile): | ||
name = "libtommathtest" | ||
version = "1.2.0-dev" | ||
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): | ||
self.folders.source = "src" | ||
cmake_layout(self) | ||
|
||
def test(self): | ||
if can_run(self): | ||
cmd = os.path.join(self.cpp.build.bindir, "example") | ||
self.run(cmd, env="conanrun") |
34 changes: 34 additions & 0 deletions
34
recipes/libtommath/development/test_package/src/test_package.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#include "libtommath/tommath.h" | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
#define check(V) \ | ||
if ((V) != MP_OKAY) { \ | ||
fprintf(stderr, #V " FAILURE\n"); \ | ||
return 1; \ | ||
} | ||
|
||
int main() { | ||
mp_int a, b, c; | ||
|
||
check(mp_init(&a)); | ||
check(mp_init(&b)); | ||
check(mp_init(&c)); | ||
|
||
check(mp_rand(&a, 30)); | ||
check(mp_rand(&b, 30)); | ||
|
||
check(mp_add(&a, &b, &c)); | ||
|
||
printf("a = "); | ||
check(mp_fwrite(&a, 10, stdout)); | ||
printf("\nb = "); | ||
check(mp_fwrite(&b, 10, stdout)); | ||
printf("\na + b = "); | ||
check(mp_fwrite(&c, 10, stdout)); | ||
printf("\n"); | ||
|
||
mp_clear_multi(&a, &b, &c, NULL); | ||
return 0; | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.