1+ import glob
12import os
23import re
34import textwrap
@@ -258,6 +259,14 @@ def generate(self):
258259 pkg_name = self ._cmakedeps .get_cmake_filename (dep )
259260 # https://cmake.org/cmake/help/v3.22/guide/using-dependencies/index.html
260261 if cmake_find_mode == FIND_MODE_NONE :
262+ cps = glob .glob (f"**/{ pkg_name } .cps" , root_dir = dep .package_folder , recursive = True )
263+ if cps :
264+ loc = os .path .dirname (os .path .join (dep .package_folder , cps [0 ]))
265+ loc = loc .replace ("\\ " , "/" )
266+ pkg_paths [pkg_name ] = relativize_path (loc , self ._conanfile ,
267+ "${CMAKE_CURRENT_LIST_DIR}" )
268+ continue
269+
261270 try :
262271 # This is irrespective of the components, it should be in the root cpp_info
263272 # To define the location of the pkg-config.cmake file
@@ -266,15 +275,11 @@ def generate(self):
266275 build_dir = dep .package_folder
267276 pkg_folder = build_dir .replace ("\\ " , "/" ) if build_dir else None
268277 if pkg_folder :
269- # prioritize cps if existing as CMake does
270- for filename in (f"{ pkg_name } .cps" , f"cps/{ pkg_name } .cps" ,
271- f"{ pkg_name } -config.cmake" , f"{ pkg_name } Config.cmake" ):
278+ f = self ._cmakedeps .get_cmake_filename (dep )
279+ for filename in (f"{ f } -config.cmake" , f"{ f } Config.cmake" ):
272280 if os .path .isfile (os .path .join (pkg_folder , filename )):
273- loc = os .path .dirname (os .path .join (pkg_folder , filename ))
274- loc = loc .replace ("\\ " , "/" )
275- pkg_paths [pkg_name ] = relativize_path (loc , self ._conanfile ,
281+ pkg_paths [pkg_name ] = relativize_path (pkg_folder , self ._conanfile ,
276282 "${CMAKE_CURRENT_LIST_DIR}" )
277- break
278283
279284 existing_paths = pkg_paths_multi .setdefault (pkg_name , [])
280285 if pkg_folder not in existing_paths :
0 commit comments