From f3e8908c53d666adb2aaa9184c171853bc2727e3 Mon Sep 17 00:00:00 2001 From: jgsogo Date: Fri, 10 Dec 2021 15:48:45 +0100 Subject: [PATCH 01/19] [poc] Test other generators: run several tests in test_*/conanfile.py --- recipes/fmt/all/test_cmakedeps/conanfile.py | 25 +++++++++++++++++++++ recipes/fmt/all/test_package/CMakeLists.txt | 6 +++-- recipes/fmt/all/test_package/conanfile.py | 2 +- 3 files changed, 30 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 0000000000000..754c6727e96ec --- /dev/null +++ b/recipes/fmt/all/test_cmakedeps/conanfile.py @@ -0,0 +1,25 @@ +import os +from conans import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps +from conan import tools + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "CMakeDeps" + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["FMT_HEADER_ONLY"] = self.options["fmt"].header_only + tc.generate() + + def build(self): + cwd = os.path.dirname(__file__) + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(cwd, "..", "test_package")) + cmake.build() + + def test(self): + if not tools.cross_building.cross_building(self): + self.run("test_package", run_environment=True) + self.run("test_ranges", run_environment=True) diff --git a/recipes/fmt/all/test_package/CMakeLists.txt b/recipes/fmt/all/test_package/CMakeLists.txt index bd15d2410c37e..9b19de012f8e0 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) project(test_package CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +if(EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) + include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) + conan_basic_setup() +endif() find_package(fmt REQUIRED) diff --git a/recipes/fmt/all/test_package/conanfile.py b/recipes/fmt/all/test_package/conanfile.py index 966ad2003426a..cc1cda4ff333b 100644 --- a/recipes/fmt/all/test_package/conanfile.py +++ b/recipes/fmt/all/test_package/conanfile.py @@ -13,6 +13,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): self.run(os.path.join("bin","test_package"), run_environment=True) self.run(os.path.join("bin","test_ranges"), run_environment=True) From 03a4c3bc4d1ee65e73da61f24536893af48d61ae Mon Sep 17 00:00:00 2001 From: jgsogo Date: Mon, 13 Dec 2021 10:24:45 +0100 Subject: [PATCH 02/19] use new pattern to access info from dependencies --- recipes/fmt/all/test_cmakedeps/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/fmt/all/test_cmakedeps/conanfile.py b/recipes/fmt/all/test_cmakedeps/conanfile.py index 754c6727e96ec..2b0f3a57ed8dd 100644 --- a/recipes/fmt/all/test_cmakedeps/conanfile.py +++ b/recipes/fmt/all/test_cmakedeps/conanfile.py @@ -10,7 +10,7 @@ class TestPackageConan(ConanFile): def generate(self): tc = CMakeToolchain(self) - tc.variables["FMT_HEADER_ONLY"] = self.options["fmt"].header_only + tc.variables["FMT_HEADER_ONLY"] = self.dependencies["fmt"].options.header_only tc.generate() def build(self): From 7c1da8d398425cfa4f8c49c8f006a63569102415 Mon Sep 17 00:00:00 2001 From: jgsogo Date: Mon, 13 Dec 2021 10:33:35 +0100 Subject: [PATCH 03/19] use rel path --- recipes/fmt/all/test_cmakedeps/conanfile.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/recipes/fmt/all/test_cmakedeps/conanfile.py b/recipes/fmt/all/test_cmakedeps/conanfile.py index 2b0f3a57ed8dd..1576341591585 100644 --- a/recipes/fmt/all/test_cmakedeps/conanfile.py +++ b/recipes/fmt/all/test_cmakedeps/conanfile.py @@ -14,9 +14,8 @@ def generate(self): tc.generate() def build(self): - cwd = os.path.dirname(__file__) cmake = CMake(self) - cmake.configure(build_script_folder=os.path.join(cwd, "..", "test_package")) + cmake.configure(build_script_folder=os.path.join("..", "test_package")) cmake.build() def test(self): From 9ac268ac9df03899cd5fdaf38119debc2afba895 Mon Sep 17 00:00:00 2001 From: jgsogo Date: Tue, 21 Dec 2021 11:38:53 +0100 Subject: [PATCH 04/19] fix import (1.43.1) --- recipes/fmt/all/test_cmakedeps/conanfile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes/fmt/all/test_cmakedeps/conanfile.py b/recipes/fmt/all/test_cmakedeps/conanfile.py index 1576341591585..ff6dcbb372671 100644 --- a/recipes/fmt/all/test_cmakedeps/conanfile.py +++ b/recipes/fmt/all/test_cmakedeps/conanfile.py @@ -1,7 +1,7 @@ import os from conans import ConanFile from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps -from conan import tools +from conan.tools.cross_building import cross_building as tools_cross_building class TestPackageConan(ConanFile): @@ -19,6 +19,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building.cross_building(self): + if not tools_cross_building(self): self.run("test_package", run_environment=True) self.run("test_ranges", run_environment=True) From 6367b7a5fed0fda886130cebadbfcb5b2d4042ad Mon Sep 17 00:00:00 2001 From: "Javier G. Sogo" Date: Thu, 30 Dec 2021 14:34:25 +0100 Subject: [PATCH 05/19] Update recipes/fmt/all/test_package/CMakeLists.txt Co-authored-by: SpaceIm <30052553+SpaceIm@users.noreply.github.com> --- recipes/fmt/all/test_package/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/fmt/all/test_package/CMakeLists.txt b/recipes/fmt/all/test_package/CMakeLists.txt index 9b19de012f8e0..5549fed6db6f3 100644 --- a/recipes/fmt/all/test_package/CMakeLists.txt +++ b/recipes/fmt/all/test_package/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1.2) +cmake_minimum_required(VERSION 3.15) project(test_package CXX) if(EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) From 90fe8263f0061409c54ccdc34e2a8999157f5bf3 Mon Sep 17 00:00:00 2001 From: jgsogo Date: Thu, 30 Dec 2021 15:35:39 +0100 Subject: [PATCH 06/19] VS output path for CMakeDeps uses configuration type --- recipes/fmt/all/test_cmakedeps/conanfile.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/recipes/fmt/all/test_cmakedeps/conanfile.py b/recipes/fmt/all/test_cmakedeps/conanfile.py index ff6dcbb372671..8f22edba78ab6 100644 --- a/recipes/fmt/all/test_cmakedeps/conanfile.py +++ b/recipes/fmt/all/test_cmakedeps/conanfile.py @@ -20,5 +20,6 @@ def build(self): def test(self): if not tools_cross_building(self): - self.run("test_package", run_environment=True) - self.run("test_ranges", run_environment=True) + folder = self.settings.build_type if self.settings.os == "Windows" else "" + self.run(os.path.join(folder, "test_package"), run_environment=True) + self.run(os.path.join(folder, "test_ranges"), run_environment=True) From a883211ff71ee7db120a1f751b1bc442d7071473 Mon Sep 17 00:00:00 2001 From: jgsogo Date: Thu, 30 Dec 2021 18:40:19 +0100 Subject: [PATCH 07/19] make it a string --- recipes/fmt/all/test_cmakedeps/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/fmt/all/test_cmakedeps/conanfile.py b/recipes/fmt/all/test_cmakedeps/conanfile.py index 8f22edba78ab6..a9c25ef53b772 100644 --- a/recipes/fmt/all/test_cmakedeps/conanfile.py +++ b/recipes/fmt/all/test_cmakedeps/conanfile.py @@ -20,6 +20,6 @@ def build(self): def test(self): if not tools_cross_building(self): - folder = self.settings.build_type if self.settings.os == "Windows" else "" + folder = str(self.settings.build_type) if self.settings.os == "Windows" else "" self.run(os.path.join(folder, "test_package"), run_environment=True) self.run(os.path.join(folder, "test_ranges"), run_environment=True) From e6d679489bd0a6766df135737e8477cbe11611b6 Mon Sep 17 00:00:00 2001 From: jgsogo Date: Wed, 12 Jan 2022 09:10:50 +0100 Subject: [PATCH 08/19] force output directory --- recipes/fmt/all/test_cmakedeps/conanfile.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/recipes/fmt/all/test_cmakedeps/conanfile.py b/recipes/fmt/all/test_cmakedeps/conanfile.py index a9c25ef53b772..bac4f832f1264 100644 --- a/recipes/fmt/all/test_cmakedeps/conanfile.py +++ b/recipes/fmt/all/test_cmakedeps/conanfile.py @@ -11,6 +11,7 @@ class TestPackageConan(ConanFile): def generate(self): tc = CMakeToolchain(self) tc.variables["FMT_HEADER_ONLY"] = self.dependencies["fmt"].options.header_only + tc.variables["CMAKE_RUNTIME_OUTPUT_DIRECTORY"] = "bin" tc.generate() def build(self): @@ -20,6 +21,5 @@ def build(self): def test(self): if not tools_cross_building(self): - folder = str(self.settings.build_type) if self.settings.os == "Windows" else "" - self.run(os.path.join(folder, "test_package"), run_environment=True) - self.run(os.path.join(folder, "test_ranges"), run_environment=True) + self.run(os.path.join("bin", "test_package"), run_environment=True) + self.run(os.path.join("bin", "test_ranges"), run_environment=True) From 6281ae1fae1d176c359ed817341f6d59a25fc8b4 Mon Sep 17 00:00:00 2001 From: jgsogo Date: Wed, 12 Jan 2022 11:53:12 +0100 Subject: [PATCH 09/19] force it for the configuration name \o/ --- recipes/fmt/all/test_cmakedeps/conanfile.py | 1 + 1 file changed, 1 insertion(+) diff --git a/recipes/fmt/all/test_cmakedeps/conanfile.py b/recipes/fmt/all/test_cmakedeps/conanfile.py index bac4f832f1264..7410323baa787 100644 --- a/recipes/fmt/all/test_cmakedeps/conanfile.py +++ b/recipes/fmt/all/test_cmakedeps/conanfile.py @@ -12,6 +12,7 @@ def generate(self): tc = CMakeToolchain(self) tc.variables["FMT_HEADER_ONLY"] = self.dependencies["fmt"].options.header_only tc.variables["CMAKE_RUNTIME_OUTPUT_DIRECTORY"] = "bin" + tc.variables["CMAKE_RUNTIME_OUTPUT_DIRECTORY_{}".format(str(self.settings.build_type).upper())] = "bin" tc.generate() def build(self): From a27e7ee2da2a54c2ea2c29a23e19880e074db383 Mon Sep 17 00:00:00 2001 From: jgsogo Date: Wed, 12 Jan 2022 12:15:26 +0100 Subject: [PATCH 10/19] following team feedback, this should be the way to go --- recipes/fmt/all/test_cmakedeps/conanfile.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/recipes/fmt/all/test_cmakedeps/conanfile.py b/recipes/fmt/all/test_cmakedeps/conanfile.py index 7410323baa787..34d054951fb3a 100644 --- a/recipes/fmt/all/test_cmakedeps/conanfile.py +++ b/recipes/fmt/all/test_cmakedeps/conanfile.py @@ -11,8 +11,6 @@ class TestPackageConan(ConanFile): def generate(self): tc = CMakeToolchain(self) tc.variables["FMT_HEADER_ONLY"] = self.dependencies["fmt"].options.header_only - tc.variables["CMAKE_RUNTIME_OUTPUT_DIRECTORY"] = "bin" - tc.variables["CMAKE_RUNTIME_OUTPUT_DIRECTORY_{}".format(str(self.settings.build_type).upper())] = "bin" tc.generate() def build(self): @@ -22,5 +20,5 @@ def build(self): def test(self): if not tools_cross_building(self): - self.run(os.path.join("bin", "test_package"), run_environment=True) - self.run(os.path.join("bin", "test_ranges"), run_environment=True) + 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) From 31b9e5adb0eaa75136c4cb98b2c130d04f7289d1 Mon Sep 17 00:00:00 2001 From: jgsogo Date: Wed, 12 Jan 2022 12:34:14 +0100 Subject: [PATCH 11/19] use cmake_layout explicitly --- recipes/fmt/all/test_cmakedeps/conanfile.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/recipes/fmt/all/test_cmakedeps/conanfile.py b/recipes/fmt/all/test_cmakedeps/conanfile.py index 34d054951fb3a..773029a2c1237 100644 --- a/recipes/fmt/all/test_cmakedeps/conanfile.py +++ b/recipes/fmt/all/test_cmakedeps/conanfile.py @@ -2,6 +2,7 @@ from conans import ConanFile from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps from conan.tools.cross_building import cross_building as tools_cross_building +from conan.tools.layout import cmake_layout class TestPackageConan(ConanFile): @@ -13,6 +14,9 @@ def generate(self): tc.variables["FMT_HEADER_ONLY"] = self.dependencies["fmt"].options.header_only tc.generate() + def layout(self): + cmake_layout(self) + def build(self): cmake = CMake(self) cmake.configure(build_script_folder=os.path.join("..", "test_package")) From 251189cd1e739e1662e1cec3d9087153350a4619 Mon Sep 17 00:00:00 2001 From: jgsogo Date: Wed, 12 Jan 2022 12:42:21 +0100 Subject: [PATCH 12/19] we can delegate the path to the source to the layout --- recipes/fmt/all/test_cmakedeps/conanfile.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/recipes/fmt/all/test_cmakedeps/conanfile.py b/recipes/fmt/all/test_cmakedeps/conanfile.py index 773029a2c1237..b462f622a0218 100644 --- a/recipes/fmt/all/test_cmakedeps/conanfile.py +++ b/recipes/fmt/all/test_cmakedeps/conanfile.py @@ -16,10 +16,11 @@ def generate(self): def layout(self): cmake_layout(self) + self.folders.source = os.path.join("..", "test_package") def build(self): cmake = CMake(self) - cmake.configure(build_script_folder=os.path.join("..", "test_package")) + cmake.configure() cmake.build() def test(self): From 78eff637c8ba39f86472bfdcedeb128807a9ca34 Mon Sep 17 00:00:00 2001 From: "Javier G. Sogo" Date: Sat, 5 Feb 2022 08:42:51 +0100 Subject: [PATCH 13/19] Update recipes/fmt/all/test_cmakedeps/conanfile.py Co-authored-by: Uilian Ries --- recipes/fmt/all/test_cmakedeps/conanfile.py | 1 + 1 file changed, 1 insertion(+) diff --git a/recipes/fmt/all/test_cmakedeps/conanfile.py b/recipes/fmt/all/test_cmakedeps/conanfile.py index b462f622a0218..90958ed290d36 100644 --- a/recipes/fmt/all/test_cmakedeps/conanfile.py +++ b/recipes/fmt/all/test_cmakedeps/conanfile.py @@ -4,6 +4,7 @@ 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" From e218ce7c7a27500c166d13c0e3f4736e872367d6 Mon Sep 17 00:00:00 2001 From: jgsogo Date: Sat, 5 Feb 2022 10:36:23 +0100 Subject: [PATCH 14/19] touch From 20100d53dd9dbbab27bc9a5b03af1c93f3c72ecd Mon Sep 17 00:00:00 2001 From: jgsogo Date: Sat, 5 Feb 2022 10:36:52 +0100 Subject: [PATCH 15/19] touch From 8a776c2794f9961803283ac87fedd4038211406e Mon Sep 17 00:00:00 2001 From: jgsogo Date: Sat, 5 Feb 2022 10:37:54 +0100 Subject: [PATCH 16/19] revert change --- recipes/fmt/all/test_package/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/fmt/all/test_package/CMakeLists.txt b/recipes/fmt/all/test_package/CMakeLists.txt index 17d797c7dd0ef..057ee9782db32 100644 --- a/recipes/fmt/all/test_package/CMakeLists.txt +++ b/recipes/fmt/all/test_package/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.15) +cmake_minimum_required(VERSION 3.1.2) project(test_package CXX) if(EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) From 33dc9fc7f20b5feafbc3d7b7196c3a1ad4af65bd Mon Sep 17 00:00:00 2001 From: jgsogo Date: Sat, 5 Feb 2022 15:43:03 +0100 Subject: [PATCH 17/19] revert back, explained in PR review --- recipes/fmt/all/test_package/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/fmt/all/test_package/CMakeLists.txt b/recipes/fmt/all/test_package/CMakeLists.txt index 057ee9782db32..17d797c7dd0ef 100644 --- a/recipes/fmt/all/test_package/CMakeLists.txt +++ b/recipes/fmt/all/test_package/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1.2) +cmake_minimum_required(VERSION 3.15) project(test_package CXX) if(EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) From 7d887a4023e29c20979cc762f7f7e76c9b73b19c Mon Sep 17 00:00:00 2001 From: "Javier G. Sogo" Date: Sat, 12 Feb 2022 18:31:34 +0100 Subject: [PATCH 18/19] Update recipes/fmt/all/test_cmakedeps/conanfile.py Co-authored-by: SpaceIm <30052553+SpaceIm@users.noreply.github.com> --- recipes/fmt/all/test_cmakedeps/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/fmt/all/test_cmakedeps/conanfile.py b/recipes/fmt/all/test_cmakedeps/conanfile.py index 90958ed290d36..12c6f95e3831d 100644 --- a/recipes/fmt/all/test_cmakedeps/conanfile.py +++ b/recipes/fmt/all/test_cmakedeps/conanfile.py @@ -1,6 +1,6 @@ import os from conans import ConanFile -from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps +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 From 18da51d56a5a625be943d4e867b949683ffa79bc Mon Sep 17 00:00:00 2001 From: jgsogo Date: Mon, 14 Feb 2022 08:24:37 +0100 Subject: [PATCH 19/19] touch