Skip to content

Commit

Permalink
Remove default cppinfo at the root (#10394)
Browse files Browse the repository at this point in the history
  • Loading branch information
lasote authored Jan 25, 2022
1 parent 5410368 commit f7f0605
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 26 deletions.
32 changes: 8 additions & 24 deletions conan/tools/cmake/toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,27 +383,18 @@ class FindFiles(Block):
{% endif %}
# Definition of CMAKE_MODULE_PATH
{% if build_build_paths %}
# Explicitly defined "buildirs" of "build" context dependencies
list(PREPEND CMAKE_MODULE_PATH {{ build_build_paths }})
{% endif %}
{% if host_build_paths_noroot %}
# Explicitly defined "builddirs" of "host" dependencies
list(PREPEND CMAKE_MODULE_PATH {{ host_build_paths_noroot }})
{% endif %}
{% if host_build_paths_root %}
# The root (which is the default builddirs) path of dependencies in the host context
list(PREPEND CMAKE_MODULE_PATH {{ host_build_paths_root }})
{% if build_paths %}
list(PREPEND CMAKE_MODULE_PATH {{ build_paths }})
{% endif %}
{% if generators_folder %}
# the generators folder (where conan generates files, like this toolchain)
list(PREPEND CMAKE_MODULE_PATH {{ generators_folder }})
{% endif %}
# Definition of CMAKE_PREFIX_PATH, CMAKE_XXXXX_PATH
{% if host_build_paths_noroot %}
{% if build_paths %}
# The explicitly defined "builddirs" of "host" context dependencies must be in PREFIX_PATH
list(PREPEND CMAKE_PREFIX_PATH {{ host_build_paths_noroot }})
list(PREPEND CMAKE_PREFIX_PATH {{ build_paths }})
{% endif %}
{% if generators_folder %}
# The Conan local "generators" folder, where this toolchain is saved.
Expand Down Expand Up @@ -462,37 +453,30 @@ def context(self):

# Read information from host context
host_req = self._conanfile.dependencies.host.values()
host_build_paths_root = []
host_build_paths_noroot = []
build_paths = []
host_lib_paths = []
host_framework_paths = []
host_include_paths = []
for req in host_req:
cppinfo = req.cpp_info.aggregated_components()
# If the builddir is the package_folder, then it is the default "root" one
nf = os.path.normpath(req.package_folder)
host_build_paths_root.extend(p for p in cppinfo.builddirs if os.path.normpath(p) == nf)
host_build_paths_noroot.extend(p for p in cppinfo.builddirs if os.path.normpath(p) != nf)
build_paths.extend(cppinfo.builddirs)
host_lib_paths.extend(cppinfo.libdirs)
if is_apple_:
host_framework_paths.extend(cppinfo.frameworkdirs)
host_include_paths.extend(cppinfo.includedirs)

# Read information from build context
build_req = self._conanfile.dependencies.build.values()
build_build_paths = []
build_bin_paths = []
for req in build_req:
cppinfo = req.cpp_info.aggregated_components()
build_build_paths.extend(cppinfo.builddirs)
build_paths.extend(cppinfo.builddirs)
build_bin_paths.extend(cppinfo.bindirs)

return {
"find_package_prefer_config": find_package_prefer_config,
"generators_folder": "${CMAKE_CURRENT_LIST_DIR}",
"host_build_paths_root": self._join_paths(host_build_paths_root),
"host_build_paths_noroot": self._join_paths(host_build_paths_noroot),
"build_build_paths": self._join_paths(build_build_paths),
"build_paths": self._join_paths(build_paths),
"cmake_program_path": self._join_paths(build_bin_paths),
"cmake_library_path": self._join_paths(host_lib_paths),
"cmake_framework_path": self._join_paths(host_framework_paths),
Expand Down
2 changes: 1 addition & 1 deletion conans/model/build_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def __init__(self, set_defaults=False):
self.libdirs = ["lib"]
self.resdirs = ["res"]
self.bindirs = ["bin"]
self.builddirs = [""]
self.builddirs = []
self.frameworkdirs = ["Frameworks"]

self._aggregated = None # A _NewComponent object with all the components aggregated
Expand Down
2 changes: 1 addition & 1 deletion conans/test/functional/layout/test_editables_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def build(self):
out = str(client2.out).replace(r"\\", "/").replace(package_folder, "")
assert "**includedirs:['package_include']**" in out
assert "**libdirs:['lib']**" in out
assert "**builddirs:['']**" in out
assert "**builddirs:[]**" in out
assert "**frameworkdirs:['Frameworks', 'package_frameworks_path']**" in out
assert "**libs:['lib_when_package', 'lib_when_package2']**" in out
assert "**objects:['myobject.o']**" in out
Expand Down

0 comments on commit f7f0605

Please sign in to comment.