Skip to content

Commit

Permalink
proposal for loading conan_cmakedeps_paths.cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
memsharded committed Oct 4, 2024
1 parent c22bbf0 commit 4ec651c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions conan_provider.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,6 @@ function(conan_install)
# TODO: this can be made more robust if Conan can provide this in the json output
string(JSON conan_generators_folder GET "${conan_stdout}" graph nodes 0 generators_folder)
cmake_path(CONVERT ${conan_generators_folder} TO_CMAKE_PATH_LIST conan_generators_folder)

message(STATUS "CMake-Conan: CONAN_GENERATORS_FOLDER=${conan_generators_folder}")
set_property(GLOBAL PROPERTY CONAN_GENERATORS_FOLDER "${conan_generators_folder}")
# reconfigure on conanfile changes
Expand Down Expand Up @@ -594,6 +593,9 @@ macro(conan_provide_dependency method package_name)
conan_install(${_host_profile_flags} ${_build_profile_flags} -s build_type=Release ${CONAN_INSTALL_ARGS} ${generator})
conan_install(${_host_profile_flags} ${_build_profile_flags} -s build_type=Debug ${CONAN_INSTALL_ARGS} ${generator})
endif()
get_property(_conan_generators_folder GLOBAL PROPERTY CONAN_GENERATORS_FOLDER)
message(STATUS "CMake-Conan: Loading conan_cmakedeps_paths.cmake file")
include(${_conan_generators_folder}/conan_cmakedeps_paths.cmake)
unset(_host_profile_flags)
unset(_build_profile_flags)
unset(_multiconfig_generator)
Expand All @@ -604,7 +606,6 @@ macro(conan_provide_dependency method package_name)
endif()

get_property(_conan_generators_folder GLOBAL PROPERTY CONAN_GENERATORS_FOLDER)

# Ensure that we consider Conan-provided packages ahead of any other,
# irrespective of other settings that modify the search order or search paths
# This follows the guidelines from the find_package documentation
Expand All @@ -616,7 +617,7 @@ macro(conan_provide_dependency method package_name)
set(_find_args_${package_name} "${ARGN}")
list(REMOVE_ITEM _find_args_${package_name} "REQUIRED")
if(NOT "MODULE" IN_LIST _find_args_${package_name})
find_package(${package_name} ${_find_args_${package_name}} BYPASS_PROVIDER PATHS "${_conan_generators_folder}" NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
find_package(${package_name} ${_find_args_${package_name}} BYPASS_PROVIDER)
unset(_find_args_${package_name})
endif()

Expand Down

0 comments on commit 4ec651c

Please sign in to comment.