diff --git a/examples/graph/tool_requires/cmake_modules/ci_test_example.py b/examples/graph/tool_requires/cmake_modules/ci_test_example.py new file mode 100644 index 00000000..26bb5bfa --- /dev/null +++ b/examples/graph/tool_requires/cmake_modules/ci_test_example.py @@ -0,0 +1,5 @@ +from conan import conan_version +from test.examples_tools import run + +run("conan create myfunctions") +run("conan build consumer") diff --git a/examples/graph/tool_requires/cmake_modules/consumer/CMakeLists.txt b/examples/graph/tool_requires/cmake_modules/consumer/CMakeLists.txt new file mode 100644 index 00000000..34ee0634 --- /dev/null +++ b/examples/graph/tool_requires/cmake_modules/consumer/CMakeLists.txt @@ -0,0 +1,4 @@ +cmake_minimum_required(VERSION 3.15) +project(test) +find_package(myfunctions CONFIG REQUIRED) +myfunction() \ No newline at end of file diff --git a/examples/graph/tool_requires/cmake_modules/consumer/conanfile.py b/examples/graph/tool_requires/cmake_modules/consumer/conanfile.py new file mode 100644 index 00000000..5c00c86b --- /dev/null +++ b/examples/graph/tool_requires/cmake_modules/consumer/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout + +class Conan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + tool_requires = "myfunctions/1.0" + + def layout(self): + cmake_layout(self) + + def generate(self): + tc = CMakeToolchain(self) + tc.generate() + + deps = CMakeDeps(self) + # By default 'myfunctions-config.cmake' is not created for tool_requires + # we need to explicitly activate it + deps.build_context_activated = ["myfunctions"] + # and we need to tell to automatically load 'myfunctions' modules + deps.build_context_build_modules = ["myfunctions"] + deps.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() \ No newline at end of file diff --git a/examples/graph/tool_requires/cmake_modules/myfunctions/conanfile.py b/examples/graph/tool_requires/cmake_modules/myfunctions/conanfile.py new file mode 100644 index 00000000..fe088bf3 --- /dev/null +++ b/examples/graph/tool_requires/cmake_modules/myfunctions/conanfile.py @@ -0,0 +1,14 @@ +import os +from conan import ConanFile +from conan.tools.files import copy + +class Conan(ConanFile): + name = "myfunctions" + version = "1.0" + exports_sources = ["*.cmake"] + + def package(self): + copy(self, "*.cmake", self.source_folder, self.package_folder) + + def package_info(self): + self.cpp_info.set_property("cmake_build_modules", ["myfunction.cmake"]) diff --git a/examples/graph/tool_requires/cmake_modules/myfunctions/myfunction.cmake b/examples/graph/tool_requires/cmake_modules/myfunctions/myfunction.cmake new file mode 100644 index 00000000..9a8708a6 --- /dev/null +++ b/examples/graph/tool_requires/cmake_modules/myfunctions/myfunction.cmake @@ -0,0 +1,3 @@ +function(myfunction) + message("Hello myfunction!!!!") +endfunction()