Skip to content

Commit e6c709f

Browse files
committed
Merge branch 'topic/math#34-migration_conan2' into develop
2 parents 8c49b88 + e771bd2 commit e6c709f

File tree

8 files changed

+102
-44
lines changed

8 files changed

+102
-44
lines changed

.github/workflows/develop-build_test_deploy.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,10 @@ on:
88

99
jobs:
1010
build-test-deployrecipe:
11-
uses: shredeagle/reusable-workflows/.github/workflows/[email protected]
11+
#uses: shredeagle/reusable-workflows/.github/workflows/[email protected]
12+
uses: shredeagle/reusable-workflows/.github/workflows/main_build.yml@topic/math#34-migration_conan2
1213
with:
13-
# Disable macOS
14-
# apple-clang 13 is being a little itch with deduction guides for template aliases.
15-
os: >-
16-
["ubuntu-24.04", "windows-2022"]
17-
deployrecipe_userchannel: adnn/develop
14+
deployrecipe_user: adnn
1815
step_conancache: false
1916
secrets:
2017
SHREDROBOT_GITHUB_TOKEN: ${{ secrets.SHREDROBOT_GITHUB_TOKEN }}

.github/workflows/topics-build_test.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ on:
99

1010
jobs:
1111
build-test:
12-
uses: shredeagle/reusable-workflows/.github/workflows/[email protected]
12+
#uses: shredeagle/reusable-workflows/.github/workflows/[email protected]
13+
uses: shredeagle/reusable-workflows/.github/workflows/main_build.yml@topic/math#34-migration_conan2
1314
with:
1415
# Disable macOS
1516
# apple-clang 13 is being a little itch with deduction guides for template aliases.
16-
os: >-
17-
["ubuntu-24.04", "windows-2022"]
17+
#os: >-
18+
# ["ubuntu-24.04", "windows-2022"]
1819
step_conancache: false
1920
secrets:
2021
SHREDROBOT_GITHUB_TOKEN: ${{ secrets.SHREDROBOT_GITHUB_TOKEN }}

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ cmc_include_conan_configuration()
1010
# Enable the grouping target in folders, when available in IDE.
1111
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
1212

13+
# see: https://cmake.org/cmake/help/latest/module/CTest.html
14+
# To be included in the top CMakeLists.txt, creates BUILD_TESTING option (ON by default)
15+
# Invokes enable_testing() to enable add_test(), unless BUILD_TESTING is OFF.
16+
# note: Conan can set BUILD_TESTING to OFF through tools.build:skip_test configuration.
17+
include(CTest)
18+
1319
# Note: also set by conanuser_config.cmake
1420
option (BUILD_CONF_WarningAsError "Enable warning as error compiler option." False)
1521

conan/conanfile.py

Lines changed: 70 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
from conans import ConanFile, tools
2-
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
1+
from conan import ConanFile
2+
from conan.tools.build import can_run, check_min_cppstd
3+
from conan.tools.cmake import CMake, cmake_layout
4+
from conan.tools.files import copy, update_conandata
5+
from conan.tools.scm import Git
36

4-
5-
from os import path
7+
import os
68

79

810
class MathConan(ConanFile):
@@ -15,19 +17,71 @@ class MathConan(ConanFile):
1517
url = "https://github.com/Adnn/math"
1618
description = "A mathematic library implementation, first concentrating on linear algrebra."
1719
topics = ("math", "linear algebra", "geometry", "graphics",)
20+
1821
settings = ("os", "compiler", "build_type", "arch")
19-
options = {
20-
"shared": [True, False],
21-
"build_tests": [True, False],
22-
}
23-
default_options = {
24-
"shared": False,
25-
"build_tests": False,
26-
}
27-
28-
build_policy = "missing"
22+
options = {}
23+
default_options = {}
24+
2925
generators = "CMakeDeps", "CMakeToolchain"
26+
revision_mode = "scm"
27+
28+
29+
def validate(self):
30+
if self.settings.compiler.get_safe("cppstd"):
31+
check_min_cppstd(self, "20")
32+
33+
34+
# Note: We expect the profile to require it in a specific version
35+
# but having it here makes it simpler for external users.
36+
def build_requirements(self):
37+
self.tool_requires("cmake/[>=3.23]")
38+
39+
40+
def layout(self):
41+
# The root of the project is one level above
42+
self.folders.root = ".."
43+
cmake_layout(self)
44+
45+
46+
def export(self):
47+
git = Git(self, self.recipe_folder)
48+
# Save the url and commit in conandata.yml
49+
# Unsafe atm since it is missing the repository argument,
50+
# so we save the coordinates manually
51+
#git.coordinates_to_conandata()
52+
url, commit = git.get_url_and_commit(repository=True)
53+
update_conandata(self, {"scm": {"url": url, "commit": commit}})
54+
55+
56+
def source(self):
57+
# recover the url and commit from conandata.yml, use them to get sources
58+
git = Git(self)
59+
git.checkout_from_conandata_coordinates()
60+
git.run("submodule update --init")
61+
62+
63+
def build(self):
64+
cmake = CMake(self)
65+
cmake.configure()
66+
cmake.build()
67+
if can_run(self):
68+
cmake.test()
69+
70+
71+
def package(self):
72+
cmake = CMake(self)
73+
cmake.install()
74+
copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
75+
3076

77+
def package_info(self):
78+
# Let's bite the bullet and repeate ourselve with a complete cpp_info,
79+
# waiting for sufficent Common Package Specification support in Conan an CMake.
80+
## Disable the config package that would otherwise be generated by CMakeDeps
81+
#self.cpp_info.set_property("cmake_find_mode", "none")
82+
## Find CMake-generated package config when consuming the (installed) conan package
83+
#self.cpp_info.builddirs = [os.path.join("lib", "cmake")]
3184

32-
python_requires="shred_conan_base/0.0.5@adnn/stable"
33-
python_requires_extend="shred_conan_base.ShredBaseConanFile"
85+
self.cpp_info.set_property("cmake_find_mode", "config")
86+
self.cpp_info.components["math"].set_property("cmake_target_name", "ad::math")
87+
self.cpp_info.components["math"].includedirs = ["include/math"]

conan/test_package/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
cmake_minimum_required(VERSION 3.16)
22
project(PackageTest CXX)
33

4-
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY $<1:${CMAKE_CURRENT_BINARY_DIR}>)
54
find_package(Math REQUIRED COMPONENTS math)
65

76
add_executable(example example.cpp)

conan/test_package/conanfile.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
1-
import os
1+
from conan import ConanFile
2+
from conan.tools.build import can_run
3+
from conan.tools.cmake import CMake, cmake_layout
24

3-
from conans import ConanFile, tools
4-
from conan.tools.cmake import CMake, CMakeToolchain
5+
import os
56

67

7-
class AunteaterTestConan(ConanFile):
8+
class MathTestConan(ConanFile):
9+
# Simplified recipe version, tailored for test packages
10+
# see: https://github.com/conan-io/conan/issues/15247#issuecomment-1850170100
811
settings = "os", "compiler", "build_type", "arch"
9-
generators = "CMakeToolchain"
12+
generators = "CMakeDeps", "CMakeToolchain"
13+
1014

15+
def requirements(self):
16+
self.requires(self.tested_reference_str)
1117

12-
def generate(self):
13-
tc = CMakeToolchain(self)
14-
tc.generate()
18+
19+
def layout(self):
20+
cmake_layout(self)
1521

1622

1723
def build(self):
@@ -20,12 +26,7 @@ def build(self):
2026
cmake.build()
2127

2228

23-
def imports(self):
24-
self.copy("*.dll", dst="bin", src="bin")
25-
self.copy("*.dylib*", dst="bin", src="lib")
26-
self.copy('*.so*', dst='bin', src='lib')
27-
28-
2929
def test(self):
30-
if not tools.cross_building(self.settings):
31-
self.run(".%sexample" % os.sep)
30+
if can_run(self):
31+
cmd = os.path.join(self.cpp.build.bindir, "example")
32+
self.run(cmd, env="conanrun")

src/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
add_subdirectory(libs/math/math)
22

3-
option(BUILD_tests "Build the test applications" ON)
4-
if(BUILD_tests)
3+
if(BUILD_TESTING)
54
add_subdirectory(apps/tests/tests)
65
endif()

src/apps/tests/tests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ cmc_cpp_all_warnings_as_errors(${TARGET_NAME} ENABLED ${BUILD_CONF_WarningAsErro
5656

5757
cmc_cpp_sanitizer(${TARGET_NAME} ${BUILD_CONF_Sanitizer})
5858

59+
add_test(NAME ${TARGET_NAME} COMMAND ${TARGET_NAME})
5960

6061
##
6162
## Install

0 commit comments

Comments
 (0)