Skip to content

Commit

Permalink
(conan-io#18230) rtm: migrate to Conan v2
Browse files Browse the repository at this point in the history
* rtm: migrate to Conan v2

* rtm: restore test_v1_package

* rtm: add cmake_find_package_multi generator to test_v1_package
  • Loading branch information
valgur authored and pezy committed Jul 15, 2023
1 parent 17d0ea1 commit fae82db
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 23 deletions.
42 changes: 30 additions & 12 deletions recipes/rtm/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,46 @@
import os
from conans import ConanFile, tools

from conan import ConanFile
from conan.tools.build import check_min_cppstd
from conan.tools.files import copy, get
from conan.tools.layout import basic_layout

required_conan_version = ">=1.52.0"


class Rtmonan(ConanFile):
name = "rtm"
description = "Realtime Math"
topics = ("realtime", "math")
license = "MIT"
homepage = "https://github.com/nfrechette/rtm"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/nfrechette/rtm"
topics = ("realtime", "math", "header-only")

package_type = "header-library"
settings = "os", "arch", "compiler", "build_type"
no_copy_source = True

@property
def _source_subfolder(self):
return "source_subfolder"
def _min_cppstd(self):
return 11

def layout(self):
basic_layout(self, src_folder="src")

def package_id(self):
self.info.clear()

def validate(self):
if self.settings.compiler.get_safe("cppstd"):
check_min_cppstd(self, self._min_cppstd)

def source(self):
tools.get(**self.conan_data["sources"][self.version])
extracted_dir = self.name + "-" + self.version
os.rename(extracted_dir, self._source_subfolder)
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def package(self):
self.copy("LICENSE", dst="licenses", src=self._source_subfolder)
self.copy("*.h", dst="include", src=os.path.join(self._source_subfolder, "includes"))
copy(self, "LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder)
copy(self, "*.h", dst=os.path.join(self.package_folder, "include"), src=os.path.join(self.source_folder, "includes"))

def package_id(self):
self.info.header_only()
def package_info(self):
self.cpp_info.bindirs = []
self.cpp_info.libdirs = []
9 changes: 4 additions & 5 deletions recipes/rtm/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
cmake_minimum_required(VERSION 3.1)
project(test_package)
cmake_minimum_required(VERSION 3.15)
project(test_package LANGUAGES CXX)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
find_package(rtm REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
target_link_libraries(${PROJECT_NAME} PRIVATE rtm::rtm)
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11)
21 changes: 15 additions & 6 deletions recipes/rtm/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout, CMake
import os
from conans import ConanFile, CMake, tools


class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeDeps", "CMakeToolchain"
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 not tools.cross_building(self.settings):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindir, "test_package")
self.run(bin_path, env="conanrun")
3 changes: 3 additions & 0 deletions recipes/rtm/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// workaround for a missing include in rtm
#include <limits>

#include <rtm/constants.h>
#include <rtm/scalarf.h>
#include <rtm/scalard.h>
Expand Down
8 changes: 8 additions & 0 deletions recipes/rtm/all/test_v1_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.15)
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/)
17 changes: 17 additions & 0 deletions recipes/rtm/all/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import os
from conans import ConanFile, CMake, tools


class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake", "cmake_find_package_multi"

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self.settings):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)

0 comments on commit fae82db

Please sign in to comment.