Skip to content

Commit

Permalink
(#12175) entt: improve support of conan v2 & add test_v1_package
Browse files Browse the repository at this point in the history
* improve support of conan v2

* self.info.clear() instead of self.info.header_only()
  • Loading branch information
SpaceIm authored Aug 26, 2022
1 parent 43feb2a commit 0f76703
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 13 deletions.
28 changes: 15 additions & 13 deletions recipes/entt/3.x.x/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.build import check_min_cppstd
from conan.tools.files import copy, get
from conans import tools as tools_legacy
from conan.tools.layout import basic_layout
import os

required_conan_version = ">=1.47.0"
required_conan_version = ">=1.50.0"


class EnttConan(ConanFile):
Expand All @@ -17,17 +18,14 @@ class EnttConan(ConanFile):
no_copy_source = True
settings = "os", "arch", "compiler", "build_type"

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

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

def validate(self):
# TODO: use self.info.settings in validate() instead of self.settings
minimal_cpp_standard = "17"
if self.settings.compiler.get_safe("cppstd"):
tools_legacy.check_min_cppstd(self, minimal_cpp_standard)
check_min_cppstd(self, minimal_cpp_standard)

minimal_version = {
"Visual Studio": "15.9",
Expand Down Expand Up @@ -55,15 +53,19 @@ def lazy_lt_semver(v1, v2):
raise ConanInvalidConfiguration(
"%s requires a compiler that supports at least C++%s" % (self.name, minimal_cpp_standard))

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

def source(self):
get(self, **self.conan_data["sources"][self.version],
destination=self._source_subfolder, strip_root=True)
destination=self.source_folder, strip_root=True)

def build(self):
pass

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

def package_info(self):
self.cpp_info.set_property("cmake_file_name", "EnTT")
Expand Down
14 changes: 14 additions & 0 deletions recipes/entt/3.x.x/test_v1_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
cmake_minimum_required(VERSION 3.8)
project(test_package LANGUAGES CXX)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

find_package(EnTT REQUIRED CONFIG)

add_executable(${PROJECT_NAME} ../test_package/test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE EnTT::EnTT)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)
if(EnTT_VERSION VERSION_LESS "3.4.0")
target_compile_definitions(${PROJECT_NAME} PRIVATE "ENTT_LESS_3_4_0")
endif()
18 changes: 18 additions & 0 deletions recipes/entt/3.x.x/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# pylint: skip-file
from conans import ConanFile, CMake, tools
import os


class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
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):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)

0 comments on commit 0f76703

Please sign in to comment.