@@ -14,10 +14,11 @@ class TargetConfigurationTemplate2:
1414 """
1515 FooTarget-release.cmake
1616 """
17- def __init__ (self , cmakedeps , conanfile , require ):
17+ def __init__ (self , cmakedeps , conanfile , require , full_cpp_info ):
1818 self ._cmakedeps = cmakedeps
1919 self ._conanfile = conanfile # The dependency conanfile, not the consumer one
2020 self ._require = require
21+ self ._full_cpp_info = full_cpp_info
2122
2223 def content (self ):
2324 auto_link = self ._cmakedeps .get_property ("cmake_set_interface_link_directories" ,
@@ -102,7 +103,7 @@ def _requires(self, info, components):
102103
103104 @property
104105 def _context (self ):
105- cpp_info = self ._conanfile . cpp_info . deduce_full_cpp_info ( self . _conanfile )
106+ cpp_info = self ._full_cpp_info
106107 assert isinstance (cpp_info .type , PackageType )
107108 pkg_name = self ._conanfile .ref .name
108109 # fallback to consumer configuration if it doesn't have build_type
@@ -120,8 +121,6 @@ def _context(self):
120121 self ._add_root_lib_target (libs , pkg_name , cpp_info )
121122 exes = self ._get_exes (cpp_info , pkg_name , pkg_folder , pkg_folder_var )
122123
123- prefixes = self ._cmakedeps .get_property ("cmake_additional_variables_prefixes" ,
124- self ._conanfile , check_type = list ) or []
125124 seen_aliases = set ()
126125 root_target_name = self ._cmakedeps .get_property ("cmake_target_name" , self ._conanfile )
127126 root_target_name = root_target_name or f"{ pkg_name } ::{ pkg_name } "
@@ -139,20 +138,6 @@ def _context(self):
139138 raise ConanException (f"Alias '{ alias } ' already defined as a target in "
140139 f"{ self ._conanfile } . " )
141140
142- f = self ._cmakedeps .get_cmake_filename (self ._conanfile )
143- prefixes = [f ] + prefixes
144- include_dirs = definitions = libraries = None
145- if not self ._require .build : # To add global variables for try_compile and legacy
146- aggregated_cppinfo = cpp_info .aggregated_components ()
147- # FIXME: Proper escaping of paths for CMake
148- incdirs = [i .replace ("\\ " , "/" ) for i in aggregated_cppinfo .includedirs ]
149- incdirs = [relativize_path (i , self ._cmakedeps ._conanfile , "${CMAKE_CURRENT_LIST_DIR}" )
150- for i in incdirs ]
151- include_dirs = ";" .join (incdirs )
152- definitions = ""
153- root_target_name = self ._cmakedeps .get_property ("cmake_target_name" , self ._conanfile )
154- libraries = root_target_name or f"{ pkg_name } ::{ pkg_name } "
155-
156141 pkg_folder = relativize_path (pkg_folder , self ._cmakedeps ._conanfile ,
157142 "${CMAKE_CURRENT_LIST_DIR}" )
158143 dependencies = self ._get_dependencies ()
@@ -162,13 +147,7 @@ def _context(self):
162147 "config" : config ,
163148 "exes" : exes ,
164149 "libs" : libs ,
165- "context" : self ._conanfile .context ,
166- # Extra global variables
167- "additional_variables_prefixes" : prefixes ,
168- "version" : self ._conanfile .ref .version ,
169- "include_dirs" : include_dirs ,
170- "definitions" : definitions ,
171- "libraries" : libraries ,
150+ "context" : self ._conanfile .context
172151 }
173152
174153 def _get_libs (self , cpp_info , pkg_name , pkg_folder , pkg_folder_var ) -> dict :
@@ -467,21 +446,6 @@ def _template(self):
467446 {% endif %}
468447 {% endfor %}
469448
470- ################# Global variables for try compile and legacy ##############
471- {% for prefix in additional_variables_prefixes %}
472- set({{ prefix }}_VERSION_STRING "{{ version }}")
473- {% if include_dirs is not none %}
474- set({{ prefix }}_INCLUDE_DIRS "{{ include_dirs }}" )
475- set({{ prefix }}_INCLUDE_DIR "{{ include_dirs }}" )
476- {% endif %}
477- {% if libraries is not none %}
478- set({{ prefix }}_LIBRARIES {{ libraries }} )
479- {% endif %}
480- {% if definitions is not none %}
481- set({{ prefix }}_DEFINITIONS {{ definitions}} )
482- {% endif %}
483- {% endfor %}
484-
485449 ################# Exes information ##############
486450 {% for exe, location in exes.items() %}
487451 #################### {{exe}} ####################
0 commit comments