From 82d226303f6f83d35e66b6169f337b5a6b2374e0 Mon Sep 17 00:00:00 2001 From: "Javier G. Sogo" Date: Wed, 16 Feb 2022 05:45:19 +0100 Subject: [PATCH] (#8389) Test other generators: run several tests in test_*/conanfile.py * [poc] Test other generators: run several tests in test_*/conanfile.py * use new pattern to access info from dependencies * use rel path * fix import (1.43.1) * Update recipes/fmt/all/test_package/CMakeLists.txt Co-authored-by: SpaceIm <30052553+SpaceIm@users.noreply.github.com> * VS output path for CMakeDeps uses configuration type * make it a string * force output directory * force it for the configuration name \o/ * following team feedback, this should be the way to go * use cmake_layout explicitly * we can delegate the path to the source to the layout * Update recipes/fmt/all/test_cmakedeps/conanfile.py Co-authored-by: Uilian Ries * touch * touch * revert change * revert back, explained in PR review * Update recipes/fmt/all/test_cmakedeps/conanfile.py Co-authored-by: SpaceIm <30052553+SpaceIm@users.noreply.github.com> * touch Co-authored-by: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Co-authored-by: Uilian Ries --- recipes/fmt/all/test_cmakedeps/conanfile.py | 30 +++++++++++++++++++++ recipes/fmt/all/test_package/CMakeLists.txt | 8 +++--- 2 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 recipes/fmt/all/test_cmakedeps/conanfile.py diff --git a/recipes/fmt/all/test_cmakedeps/conanfile.py b/recipes/fmt/all/test_cmakedeps/conanfile.py new file mode 100644 index 00000000000000..12c6f95e3831d8 --- /dev/null +++ b/recipes/fmt/all/test_cmakedeps/conanfile.py @@ -0,0 +1,30 @@ +import os +from conans import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain +from conan.tools.cross_building import cross_building as tools_cross_building +from conan.tools.layout import cmake_layout + +required_conan_version = ">=1.43.0" + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "CMakeDeps" + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["FMT_HEADER_ONLY"] = self.dependencies["fmt"].options.header_only + tc.generate() + + def layout(self): + cmake_layout(self) + self.folders.source = os.path.join("..", "test_package") + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools_cross_building(self): + self.run(os.path.join(self.cpp.build.bindirs[0], "test_package"), run_environment=True) + self.run(os.path.join(self.cpp.build.bindirs[0], "test_ranges"), run_environment=True) diff --git a/recipes/fmt/all/test_package/CMakeLists.txt b/recipes/fmt/all/test_package/CMakeLists.txt index f59c9c07ca3fc8..17d797c7dd0ef7 100644 --- a/recipes/fmt/all/test_package/CMakeLists.txt +++ b/recipes/fmt/all/test_package/CMakeLists.txt @@ -1,8 +1,10 @@ -cmake_minimum_required(VERSION 3.1.2) +cmake_minimum_required(VERSION 3.15) project(test_package CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +if(EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) + include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) + conan_basic_setup(TARGETS) +endif() find_package(fmt REQUIRED CONFIG)