Skip to content

Commit

Permalink
(conan-io#8389) Test other generators: run several tests in test_*/co…
Browse files Browse the repository at this point in the history
…nanfile.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 <uilianries@gmail.com>

* 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 <uilianries@gmail.com>
  • Loading branch information
3 people authored and SSE4 committed Feb 21, 2022
1 parent e968d8f commit 82d2263
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
30 changes: 30 additions & 0 deletions recipes/fmt/all/test_cmakedeps/conanfile.py
Original file line number Diff line number Diff line change
@@ -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)
8 changes: 5 additions & 3 deletions recipes/fmt/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)

Expand Down

0 comments on commit 82d2263

Please sign in to comment.