Skip to content

Commit

Permalink
conan.cmake: more robust generator output dir extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
valgur committed May 22, 2023
1 parent 7a4bfcd commit 3e3ecbf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 7 additions & 1 deletion cmake/conan.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ function(conan_cmake_install)
${OUTPUT_FOLDER} ${GENERATOR} ${BUILD}
${OPTIONS} ${OPTIONS_HOST} ${OPTIONS_BUILD} ${PROFILE} ${PROFILE_HOST}
${PROFILE_BUILD} ${SETTINGS} ${SETTINGS_HOST} ${SETTINGS_BUILD}
${CONF_HOST} ${CONF_BUILD})
${CONF_HOST} ${CONF_BUILD} --format=json)

string(REPLACE ";" " " _install_args "${install_args}")
message(STATUS "Conan executing: ${CONAN_CMD} ${_install_args}")
Expand All @@ -595,6 +595,8 @@ function(conan_cmake_install)

execute_process(COMMAND ${CONAN_CMD} ${install_args}
RESULT_VARIABLE return_code
OUTPUT_VARIABLE conan_stdout
ERROR_VARIABLE conan_stderr
${OUTPUT_OPT}
${ERROR_OPT}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
Expand All @@ -605,6 +607,10 @@ function(conan_cmake_install)
else()
message(FATAL_ERROR "Conan install failed='${return_code}'")
endif()
else()
string(REGEX MATCH "\"generators_folder\": *\"([^\"]*)\"" MATCHED_PATH "${conan_stdout}")
string(REGEX REPLACE "\"generators_folder\": *\"([^\"]*)\"" "\\1" CONAN_GENERATORS_FOLDER "${MATCHED_PATH}")
set(CONAN_GENERATORS_FOLDER "${CONAN_GENERATORS_FOLDER}" PARENT_SCOPE)
endif()

endfunction()
Expand Down
4 changes: 1 addition & 3 deletions cmake/conan_dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,7 @@ function(_custom_conan_cmake_install)
# Prepend to prioritize conan packages over system ones.
# Multiple paths are added due to the output directory of the generator depending on
# the layout() config in the used conanfile.py.
list(PREPEND CMAKE_PREFIX_PATH
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/build/${CMAKE_BUILD_TYPE}/generators)
list(PREPEND CMAKE_PREFIX_PATH ${CONAN_GENERATORS_FOLDER})
set(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH}" PARENT_SCOPE)
endfunction()

Expand Down

0 comments on commit 3e3ecbf

Please sign in to comment.