-
Notifications
You must be signed in to change notification settings - Fork 260
Compute CMAKE_PROGRAM_PATH from returned json #626
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop2
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -451,8 +451,45 @@ function(conan_install) | |
# success | ||
set_property(GLOBAL PROPERTY CONAN_INSTALL_SUCCESS TRUE) | ||
|
||
|
||
conan_set_program_path() | ||
|
||
list(PREPEND CMAKE_PROGRAM_PATH ${_CONAN_PROGRAM_PATH}) | ||
set(CMAKE_PROGRAM_PATH ${CMAKE_PROGRAM_PATH} PARENT_SCOPE) | ||
|
||
endfunction() | ||
|
||
macro(conan_set_program_path) | ||
set(_CONAN_PROGRAM_PATH "") | ||
|
||
message("${conan_stdout}") | ||
string(JSON _conan_graph_nodes_length LENGTH ${conan_stdout} graph nodes) | ||
math(EXPR _conan_graph_nodes_length "${_conan_graph_nodes_length} - 1") | ||
foreach(_node_number RANGE ${_conan_graph_nodes_length}) | ||
|
||
string(JSON _dep_binary GET ${conan_stdout} graph nodes ${_node_number} binary) | ||
string(JSON _dep_context GET ${conan_stdout} graph nodes ${_node_number} context) | ||
|
||
if(_dep_binary STREQUAL "Skip" OR NOT _dep_context STREQUAL "build") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't you play safer doing a comparison against a lowercase value?:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or even defining those There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this part of Conan's json formatter, so it's essentially a public API - if this ever changed in Conan, our tests (in Conan) would fail straight away so we would know that would be a breaking change (minimising the chance of this ever happening - so not sure we can something by doing lowercase). they could be constants but then we would have more indirection given how CMake expands variables but I'll consider that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the explanation! And roger that CMake code is by itself complicated enough to introduce further indirections. |
||
continue() | ||
endif() | ||
|
||
string(JSON _current_node_length LENGTH ${conan_stdout} graph nodes ${_node_number} cpp_info) | ||
math(EXPR _current_node_components "${_current_node_length} - 1") | ||
foreach(_component RANGE ${_current_node_components}) | ||
string(JSON _current_component_name MEMBER ${conan_stdout} graph nodes ${_node_number} cpp_info ${_component}) | ||
string(JSON _current_component_bindirs GET ${conan_stdout} graph nodes ${_node_number} cpp_info ${_current_component_name} bindirs) | ||
string(JSON _bindirs_length LENGTH ${_current_component_bindirs}) | ||
math(EXPR _bindirs_length "${_bindirs_length} - 1") | ||
foreach(_bindir_index RANGE ${_bindirs_length}) | ||
string(JSON _bindir GET ${_current_component_bindirs} ${_bindir_index}) | ||
list(APPEND _CONAN_PROGRAM_PATH ${_bindir}) | ||
Comment on lines
+479
to
+486
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Master of CMake! I am happy that I didn't have to write this code😄 |
||
endforeach() | ||
endforeach() | ||
endforeach() | ||
|
||
list(REMOVE_DUPLICATES _CONAN_PROGRAM_PATH) | ||
endmacro() | ||
|
||
function(conan_get_version conan_command conan_current_version) | ||
execute_process( | ||
|
@@ -542,6 +579,7 @@ macro(conan_provide_dependency method package_name) | |
if(NOT _multiconfig_generator) | ||
message(STATUS "CMake-Conan: Installing single configuration ${CMAKE_BUILD_TYPE}") | ||
conan_install(${_host_profile_flags} ${_build_profile_flags} ${CONAN_INSTALL_ARGS} ${generator}) | ||
message("CMAKE_PROGRAM_PATH yyy: ${CMAKE_PROGRAM_PATH}") | ||
else() | ||
message(STATUS "CMake-Conan: Installing both Debug and Release") | ||
conan_install(${_host_profile_flags} ${_build_profile_flags} -s build_type=Release ${CONAN_INSTALL_ARGS} ${generator}) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
[requires] | ||
fmt/9.1.0 | ||
fmt/[>10] | ||
|
||
[tool_requires] | ||
cppcheck/[>=2.13 <3] | ||
|
||
[layout] | ||
cmake_layout |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it would be a bit cleaner to do a function and "return" the variable to be used later