-
Notifications
You must be signed in to change notification settings - Fork 89
Speed up FindCSP / get all vars in one call and cache for subsequent … #745
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
Open
robambalu
wants to merge
1
commit into
main
Choose a base branch
from
rba/find_speedup
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,35 +36,39 @@ if(EXISTS "${CMAKE_SOURCE_DIR}/csp/__init__.py") | |
| set(__csp_base_path "${CMAKE_SOURCE_DIR}/csp") | ||
| set(__csp_include_path "${CMAKE_SOURCE_DIR}/cpp") | ||
| set(__csp_lib_path "${CMAKE_SOURCE_DIR}/") | ||
| set(__csp_base_path "${CMAKE_SOURCE_DIR}/csp") | ||
| set(__csp_base_path "${CMAKE_SOURCE_DIR}/csp") | ||
| set(__csp_version "0.0.0") | ||
| else() | ||
| set(CSP_IN_SOURCE_BUILD OFF) | ||
| # Find out the base path by interrogating the installed csp | ||
| find_package(Python ${CSP_PYTHON_VERSION} EXACT REQUIRED COMPONENTS Interpreter) | ||
| execute_process( | ||
| COMMAND "${Python_EXECUTABLE}" -c | ||
| "from __future__ import print_function;import os.path;import csp;print(os.path.dirname(csp.__file__), end='')" | ||
| OUTPUT_VARIABLE __csp_base_path) | ||
|
|
||
| # Find out the include path | ||
| execute_process( | ||
| COMMAND "${Python_EXECUTABLE}" -c | ||
| "from __future__ import print_function;import csp;print(csp.get_include_path(), end='')" | ||
| OUTPUT_VARIABLE __csp_include_path) | ||
|
|
||
| # Find out the lib path | ||
| execute_process( | ||
| COMMAND "${Python_EXECUTABLE}" -c | ||
| "from __future__ import print_function;import csp;print(csp.get_lib_path(), end='')" | ||
| OUTPUT_VARIABLE __csp_lib_path) | ||
|
|
||
| # And the version | ||
| execute_process( | ||
| COMMAND "${Python_EXECUTABLE}" -c | ||
| "from __future__ import print_function;import csp;print(csp.__version__, end='')" | ||
| OUTPUT_VARIABLE __csp_version) | ||
|
|
||
| # find_package(CSP) is invoked once per csp_autogen() call (see Findcsp_autogen.cmake), | ||
| # and MODULE-mode find scripts re-run their whole body every time. The find_* calls below | ||
| # are cache variables so they no-op after the first run, but execute_process is not cached. | ||
| # Query all the csp paths/version in a single python subprocess and cache the results so the | ||
| # python interpreter is only spawned once for the entire configure step. | ||
| if(NOT DEFINED __csp_base_path) | ||
| execute_process( | ||
| COMMAND "${Python_EXECUTABLE}" -c | ||
| "import os.path;import csp;print('\\n'.join([os.path.dirname(csp.__file__), csp.get_include_path(), csp.get_lib_path(), csp.__version__]))" | ||
| OUTPUT_VARIABLE __csp_query_output | ||
| OUTPUT_STRIP_TRAILING_WHITESPACE | ||
| RESULT_VARIABLE __csp_query_result) | ||
|
|
||
| if(NOT __csp_query_result EQUAL 0) | ||
| message(FATAL_ERROR "Failed to query csp package paths via ${Python_EXECUTABLE}") | ||
| endif() | ||
|
|
||
| string(REPLACE "\n" ";" __csp_query_list "${__csp_query_output}") | ||
| list(GET __csp_query_list 0 __csp_base_path) | ||
| list(GET __csp_query_list 1 __csp_include_path) | ||
| list(GET __csp_query_list 2 __csp_lib_path) | ||
| list(GET __csp_query_list 3 __csp_version) | ||
|
|
||
| set(__csp_base_path "${__csp_base_path}" CACHE INTERNAL "csp package base path") | ||
|
Collaborator
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. Note: |
||
| set(__csp_include_path "${__csp_include_path}" CACHE INTERNAL "csp include path") | ||
| set(__csp_lib_path "${__csp_lib_path}" CACHE INTERNAL "csp lib path") | ||
| set(__csp_version "${__csp_version}" CACHE INTERNAL "csp version") | ||
| endif() | ||
| endif() | ||
|
|
||
| # Now look for files | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
Note: Previously, a failed CSP import let
find_package(CSP REQUIRED)fail whilefind_package(CSP QUIET)returnedCSP_FOUND=FALSE. The newFATAL_ERRORaborts both. Can you please once verify if it even matters? Like do we need to support theREQUIRED/QUIETparamaters?