-
Notifications
You must be signed in to change notification settings - Fork 3k
CMake: better detection of memap dependencies #14205
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
Changes from all commits
029486e
c193527
c667747
947c804
fafb08c
049f1a7
e61a45a
8eca0cf
df60d42
0a67fef
9e2b04e
7b03aea
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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Copyright (c) 2020 ARM Limited. All rights reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
# CMake functions for checking for Python packages | ||
# Requires PYTHON_EXECUTABLE to be defined. Call FindPython first! | ||
|
||
# set OUTPUT_VAR to whether PACKAGENAME was found | ||
function(check_python_package PACKAGENAME OUTPUT_VAR) | ||
# can't have Python packages without Python! | ||
if(NOT Python3_FOUND) | ||
set(${OUTPUT_VAR} FALSE PARENT_SCOPE) | ||
return() | ||
endif() | ||
|
||
set(NEED_TO_RUN_CHECK TRUE) | ||
|
||
if(DEFINED ${OUTPUT_VAR}) | ||
if(${OUTPUT_VAR}) | ||
# if the python interpreter changed, we need to recheck | ||
if("${PY_INTERP_FOR_${OUTPUT_VAR}}" STREQUAL "${Python3_EXECUTABLE}") | ||
set(NEED_TO_RUN_CHECK FALSE) | ||
endif() | ||
endif() | ||
endif() | ||
|
||
if(NEED_TO_RUN_CHECK) | ||
set(PY_INTERP_FOR_${OUTPUT_VAR} ${Python3_EXECUTABLE} CACHE INTERNAL "The python interpreter used to run the ${OUTPUT_VAR} check" FORCE) | ||
|
||
execute_process( | ||
COMMAND ${Python3_EXECUTABLE} -c "import ${PACKAGENAME}" RESULT_VARIABLE PACKAGECHECK_RESULT | ||
) | ||
|
||
if(${PACKAGECHECK_RESULT} EQUAL 0) | ||
set(HAVE_PACKAGE TRUE) | ||
else() | ||
set(HAVE_PACKAGE FALSE) | ||
endif() | ||
|
||
if(HAVE_PACKAGE) | ||
message(STATUS "Checking for Python package ${PACKAGENAME} -- found") | ||
else() | ||
message(STATUS "Checking for Python package ${PACKAGENAME} -- not found") | ||
endif() | ||
|
||
set(${OUTPUT_VAR} ${HAVE_PACKAGE} CACHE BOOL "Whether the Python package ${PACKAGENAME} was found" FORCE) | ||
mark_as_advanced(${OUTPUT_VAR}) | ||
endif() | ||
endfunction(check_python_package) | ||
|
||
# check that PACKAGENAME can be imported, and print an error if not | ||
function(verify_python_package PACKAGENAME) | ||
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. Where is this used? 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. Currently nowhere, but it can be a useful part of the module if we need it at some point. 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. I would also remove unused functionality, we can add it in the future if its needed (based on use case requirements). I'll send separate patches after this one gets in, for review. |
||
|
||
# we can just generate our own variable name | ||
string(TOUPPER "HAVE_${PACKAGENAME}" HAVE_VAR_NAME) | ||
|
||
check_python_package(${PACKAGENAME} ${HAVE_VAR_NAME}) | ||
|
||
if(NOT ${HAVE_VAR_NAME}) | ||
message(FATAL_ERROR "The required Python package ${PACKAGENAME} was not found in ${Python3_EXECUTABLE}. Please install it.") | ||
endif() | ||
|
||
endfunction(verify_python_package) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
prettytable==0.7.2 | ||
future==0.16.0 | ||
Jinja2>=2.10.1,<2.11 | ||
intelhex>=2.3.0,<3.0.0 |
Uh oh!
There was an error while loading. Please reload this page.