Skip to content

Commit

Permalink
Remove find_package generation on test_package of cmake_lib template
Browse files Browse the repository at this point in the history
On test_package/CMakeLists.txt should not appear any find_package of
transitive dependencies (dependencies of the currently tested package)
Delegate on conan cmake generators to find dependencies.

Also, ordered optional requirements and build_requirement methods on
template
  • Loading branch information
perseoGI committed Jun 10, 2024
1 parent 5b5015e commit 1c3b3b3
Showing 1 changed file with 12 additions and 21 deletions.
33 changes: 12 additions & 21 deletions conan/internal/api/new/cmake_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,18 @@ def configure(self):
def layout(self):
cmake_layout(self)
{% if requires is defined %}
def requirements(self):
{% for require in requires -%}
self.requires("{{ require }}")
{% endfor %}
{%- endif %}
{%- if tool_requires is defined %}
def build_requirements(self):
{% for require in tool_requires -%}
self.tool_requires("{{ require }}")
{% endfor %}
{%- endif %}
def generate(self):
deps = CMakeDeps(self)
deps.generate()
Expand All @@ -51,20 +62,6 @@ def package(self):
def package_info(self):
self.cpp_info.libs = ["{{name}}"]
{% if requires is defined -%}
def requirements(self):
{% for require in requires -%}
self.requires("{{ require }}")
{% endfor %}
{%- endif %}
{% if tool_requires is defined -%}
def build_requirements(self):
{% for require in tool_requires -%}
self.tool_requires("{{ require }}")
{% endfor %}
{%- endif %}
'''

cmake_v2 = """cmake_minimum_required(VERSION 3.15)
Expand Down Expand Up @@ -270,12 +267,6 @@ def test(self):
find_package({{name}} CONFIG REQUIRED)
{% if requires is defined -%}
{% for require in requires -%}
find_package({{as_name(require)}} CONFIG REQUIRED)
{% endfor %}
{%- endif %}
add_executable(example src/example.cpp)
target_link_libraries(example {{name}}::{{name}})
"""
Expand Down

0 comments on commit 1c3b3b3

Please sign in to comment.